Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706906 > unrolled thread

[PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic

Started byjglisse@redhat.com
First post2017-08-09 00:10 +0200
Last post2017-08-09 12:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic jglisse@redhat.com - 2017-08-09 00:10 +0200
    Re: [PATCH] mm/rmap/mmu_notifier: restore  mmu_notifier_invalidate_page() semantic "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-08-09 12:30 +0200

#1706906 — [PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic

Fromjglisse@redhat.com
Date2017-08-09 00:10 +0200
Subject[PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic
Message-ID<uckRk-6mw-21@gated-at.bofh.it>
From: Jérôme Glisse <jglisse@redhat.com>

Commit c7ab0d2fdc840266b39db94538f74207ec2afbf6 silently modified
semantic of mmu_notifier_invalidate_page() this patch restore it
to its previous semantic ie allowing to sleep inside invalidate_page()
callback.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/rmap.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 92070cfd63e9..fc1e2ab194c0 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -888,6 +888,8 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
 		.address = address,
 		.flags = PVMW_SYNC,
 	};
+	unsigned long start = address, end = address;
+	bool invalidate = false;
 	int *cleaned = arg;
 
 	while (page_vma_mapped_walk(&pvmw)) {
@@ -927,11 +929,17 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
 		}
 
 		if (ret) {
-			mmu_notifier_invalidate_page(vma->vm_mm, address);
+			invalidate = true;
+			end = address;
 			(*cleaned)++;
 		}
 	}
 
+	if (invalidate) {
+		for (address = start; address <= end; address += PAGE_SIZE)
+			mmu_notifier_invalidate_page(vma->vm_mm, address);
+	}
+
 	return true;
 }
 
@@ -1324,7 +1332,8 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 	};
 	pte_t pteval;
 	struct page *subpage;
-	bool ret = true;
+	bool ret = true, invalidate = false;
+	unsigned long start = address, end = address;
 	enum ttu_flags flags = (enum ttu_flags)arg;
 
 	/* munlock has nothing to gain from examining un-locked vmas */
@@ -1528,8 +1537,15 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 discard:
 		page_remove_rmap(subpage, PageHuge(page));
 		put_page(page);
-		mmu_notifier_invalidate_page(mm, address);
+		end = address;
+		invalidate = true;
 	}
+
+	if (invalidate) {
+		for (address = start; address <= end; address += PAGE_SIZE)
+			mmu_notifier_invalidate_page(mm, address);
+	}
+
 	return ret;
 }
 
-- 
2.13.4

[toc] | [next] | [standalone]


#1707253 — Re: [PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic

From"Kirill A. Shutemov" <kirill@shutemov.name>
Date2017-08-09 12:30 +0200
SubjectRe: [PATCH] mm/rmap/mmu_notifier: restore mmu_notifier_invalidate_page() semantic
Message-ID<ucwpr-5Qr-3@gated-at.bofh.it>
In reply to#1706906
On Tue, Aug 08, 2017 at 06:08:20PM -0400, jglisse@redhat.com wrote:
> From: Jérôme Glisse <jglisse@redhat.com>
> 
> Commit c7ab0d2fdc840266b39db94538f74207ec2afbf6 silently modified
> semantic of mmu_notifier_invalidate_page() this patch restore it
> to its previous semantic ie allowing to sleep inside invalidate_page()
> callback.
> 
> Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

The issue in page_mkclean_one() was addressed recently by this:

http://lkml.kernel.org/r/20170804134928.l4klfcnqatni7vsc@black.fi.intel.com

(I think mmu_notifier_invalidate_range() it better in the situation, right?)

But I've missed try_to_unmap_one(). Could you prepare patch for this one?

-- 
 Kirill A. Shutemov

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web