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


Groups > linux.kernel > #1722815

[PATCH 3/4] mm/rmap: update to new mmu_notifier_invalidate_page() semantic

From Jérôme Glisse <jglisse@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 3/4] mm/rmap: update to new mmu_notifier_invalidate_page() semantic
Date 2017-08-29 22:20 +0200
Message-ID <ujV9o-7fs-27@gated-at.bofh.it> (permalink)
References <ujV9o-7fs-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


mmu_notifier_invalidate_page() is now be call from under the spinlock.
Add a call to mmu_notifier_invalidate_range() for user that need to be
able to sleep.

Relevent threads:
https://lkml.kernel.org/r/20170809204333.27485-1-jglisse@redhat.com
https://lkml.kernel.org/r/20170804134928.l4klfcnqatni7vsc@black.fi.intel.com
https://marc.info/?l=kvm&m=150327081325160&w=2

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Bernhard Held <berny156@gmx.de>
Cc: Adam Borowski <kilobyte@angband.pl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Wanpeng Li <kernellwp@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: axie <axie@amd.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/rmap.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index c8993c63eb25..06792e28093c 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -887,6 +887,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,10 +929,16 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
 
 		if (ret) {
 			mmu_notifier_invalidate_page(vma->vm_mm, address);
+			/* range is exclusive */
+			end = address + PAGE_SIZE;
+			invalidate = true;
 			(*cleaned)++;
 		}
 	}
 
+	if (invalidate)
+		mmu_notifier_invalidate_range(vma->vm_mm, start, end);
+
 	return true;
 }
 
@@ -1323,8 +1331,9 @@ 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;
 	enum ttu_flags flags = (enum ttu_flags)arg;
+	unsigned long start = address, end = address;
 
 	/* munlock has nothing to gain from examining un-locked vmas */
 	if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED))
@@ -1491,7 +1500,14 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 		page_remove_rmap(subpage, PageHuge(page));
 		put_page(page);
 		mmu_notifier_invalidate_page(mm, address);
+		/* range is exclusive */
+		end = address + PAGE_SIZE;
+		invalidate = true;
 	}
+
+	if (invalidate)
+		mmu_notifier_invalidate_range(vma->vm_mm, start, end);
+
 	return ret;
 }
 
-- 
2.13.5

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] mmu_notifier semantic update Jérôme Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200
  Re: [PATCH 0/4] mmu_notifier semantic update Jerome Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200
  [PATCH 4/4] iommu/amd: update to new mmu_notifier_invalidate_page() semantic Jérôme Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200
  [PATCH 2/4] dax/mmu_notifier: update to new mmu_notifier semantic Jérôme Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200
  [PATCH 1/4] mm/mmu_notifier: document new behavior for mmu_notifier_invalidate_page() Jérôme Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200
  [PATCH 3/4] mm/rmap: update to new mmu_notifier_invalidate_page() semantic Jérôme Glisse <jglisse@redhat.com> - 2017-08-29 22:20 +0200

csiph-web