From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbdHIQwv convert rfc822-to-8bit (ORCPT ); Wed, 9 Aug 2017 12:52:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751523AbdHIQwu (ORCPT ); Wed, 9 Aug 2017 12:52:50 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5E37810128F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jglisse@redhat.com Date: Wed, 9 Aug 2017 12:52:46 -0400 (EDT) From: Jerome Glisse To: "Kirill A. Shutemov" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" , Andrew Morton Message-ID: <88997080.69197246.1502297566486.JavaMail.zimbra@redhat.com> In-Reply-To: <20170809163434.p356oyarqpqh52hu@node.shutemov.name> References: <20170809161709.9278-1-jglisse@redhat.com> <20170809163434.p356oyarqpqh52hu@node.shutemov.name> Subject: Re: [PATCH] mm/rmap: try_to_unmap_one() do not call mmu_notifier under ptl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.10.123.206, 10.4.195.9] Thread-Topic: mm/rmap: try_to_unmap_one() do not call mmu_notifier under ptl Thread-Index: HMEjBwSpuLpeC8UhJ0kty6Ov99JbkQ== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 09 Aug 2017 16:52:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Wed, Aug 09, 2017 at 12:17:09PM -0400, jglisse@redhat.com wrote: > > From: Jérôme Glisse > > > > MMU notifiers can sleep, but in try_to_unmap_one() we call > > mmu_notifier_invalidate_page() under page table lock. > > > > Let's instead use mmu_notifier_invalidate_range() outside > > page_vma_mapped_walk() loop. > > > > Signed-off-by: Jérôme Glisse > > Cc: Kirill A. Shutemov > > Cc: Andrew Morton > > Fixes: c7ab0d2fdc84 ("mm: convert try_to_unmap_one() to use > > page_vma_mapped_walk()") > > --- > > mm/rmap.c | 36 +++++++++++++++++++++--------------- > > 1 file changed, 21 insertions(+), 15 deletions(-) > > > > diff --git a/mm/rmap.c b/mm/rmap.c > > index aff607d5f7d2..d60e887f1cda 100644 > > --- a/mm/rmap.c > > +++ b/mm/rmap.c > > @@ -1329,7 +1329,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, invalidation_needed = false; > > + unsigned long end = address + PAGE_SIZE; > > I think it should be 'address + (1UL << compound_order(page))'. Can't address point to something else than first page in huge page ? Also i did use end as an optimization ie maybe not all the pte in the range are valid and thus they not all need to be invalidated hence by tracking the last one that needs invalidation i am limiting the range. But it is a small optimization so i am not attach to it. Jérôme