From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751878AbdH2ULs (ORCPT ); Tue, 29 Aug 2017 16:11:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45098 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbdH2ULo (ORCPT ); Tue, 29 Aug 2017 16:11:44 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A6497F6AC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jglisse@redhat.com From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Linus Torvalds , Bernhard Held , Adam Borowski , Andrea Arcangeli , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Wanpeng Li , Paolo Bonzini , Takashi Iwai , Nadav Amit , Mike Galbraith , "Kirill A . Shutemov" , axie , Andrew Morton Subject: [PATCH 3/4] mm/rmap: update to new mmu_notifier_invalidate_page() semantic Date: Tue, 29 Aug 2017 16:11:31 -0400 Message-Id: <20170829201132.9292-4-jglisse@redhat.com> In-Reply-To: <20170829201132.9292-1-jglisse@redhat.com> References: <20170829201132.9292-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 29 Aug 2017 20:11:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Linus Torvalds Cc: Bernhard Held Cc: Adam Borowski Cc: Andrea Arcangeli Cc: Radim Krčmář Cc: Wanpeng Li Cc: Paolo Bonzini Cc: Takashi Iwai Cc: Nadav Amit Cc: Mike Galbraith Cc: Kirill A. Shutemov Cc: axie Cc: Andrew Morton --- 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