From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753658AbdHIUnV (ORCPT ); Wed, 9 Aug 2017 16:43:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40834 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753640AbdHIUnS (ORCPT ); Wed, 9 Aug 2017 16:43:18 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B42C61459F3 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jglisse@redhat.com Date: Wed, 9 Aug 2017 16:43:16 -0400 From: Jerome Glisse To: Andrew Morton Cc: "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" Subject: Re: [PATCH] mm/rmap: try_to_unmap_one() do not call mmu_notifier under ptl Message-ID: <20170809204315.GB27149@redhat.com> References: <20170809161709.9278-1-jglisse@redhat.com> <20170809163434.p356oyarqpqh52hu@node.shutemov.name> <88997080.69197246.1502297566486.JavaMail.zimbra@redhat.com> <20170809131742.303dfdc5730d8a8bba62a7cb@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170809131742.303dfdc5730d8a8bba62a7cb@linux-foundation.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 09 Aug 2017 20:43:18 +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 01:17:42PM -0700, Andrew Morton wrote: > On Wed, 9 Aug 2017 12:52:46 -0400 (EDT) Jerome Glisse wrote: > > > > 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. > > > > So we need this patch in addition to Kirrill's "rmap: do not call > mmu_notifier_invalidate_page() under ptl". Yes we need both to restore mmu_notifier. > > Jerome, I'm seeing a bunch of rejects applying this patch to current > mainline. It's unclear which kernel you're patching but we'll need > something which can go into Linus soon and which is backportable (with > mimimal fixups) into -stable kernels, please. > Sorry this was on top of one of my HMM branches. I am reposting with Kirill end address computation as it is not a big optimization if pte are already invalid then invalidating them once more should not trigger any more work. Jérôme