From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4152C433FF for ; Sun, 28 Jul 2019 14:19:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A420E214C6 for ; Sun, 28 Jul 2019 14:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbfG1OTa (ORCPT ); Sun, 28 Jul 2019 10:19:30 -0400 Received: from foss.arm.com ([217.140.110.172]:33064 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfG1OTa (ORCPT ); Sun, 28 Jul 2019 10:19:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3517E344; Sun, 28 Jul 2019 07:19:29 -0700 (PDT) Received: from [10.163.1.126] (unknown [10.163.1.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 698B53F575; Sun, 28 Jul 2019 07:19:22 -0700 (PDT) Subject: Re: [PATCH v9 12/21] mm: pagewalk: Allow walking without vma To: Steven Price , linux-mm@kvack.org Cc: Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Andrew Morton References: <20190722154210.42799-1-steven.price@arm.com> <20190722154210.42799-13-steven.price@arm.com> From: Anshuman Khandual Message-ID: <7fc50563-7d5d-7270-5a6a-63769e9c335a@arm.com> Date: Sun, 28 Jul 2019 19:50:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190722154210.42799-13-steven.price@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/22/2019 09:12 PM, Steven Price wrote: > Since 48684a65b4e3: "mm: pagewalk: fix misbehavior of walk_page_range > for vma(VM_PFNMAP)", page_table_walk() will report any kernel area as > a hole, because it lacks a vma. > > This means each arch has re-implemented page table walking when needed, > for example in the per-arch ptdump walker. > > Remove the requirement to have a vma except when trying to split huge > pages. > > Signed-off-by: Steven Price > --- > mm/pagewalk.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index 98373a9f88b8..1cbef99e9258 100644 > --- a/mm/pagewalk.c > +++ b/mm/pagewalk.c > @@ -36,7 +36,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > do { > again: > next = pmd_addr_end(addr, end); > - if (pmd_none(*pmd) || !walk->vma) { > + if (pmd_none(*pmd)) { > if (walk->pte_hole) > err = walk->pte_hole(addr, next, walk); > if (err) > @@ -59,9 +59,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > if (!walk->pte_entry) > continue; > > - split_huge_pmd(walk->vma, pmd, addr); > - if (pmd_trans_unstable(pmd)) > - goto again; > + if (walk->vma) { > + split_huge_pmd(walk->vma, pmd, addr); Check for a PMD THP entry before attempting to split it ? > + if (pmd_trans_unstable(pmd)) > + goto again; > + } else if (pmd_leaf(*pmd)) { > + continue; > + } > + > err = walk_pte_range(pmd, addr, next, walk); > if (err) > break; > @@ -81,7 +86,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, > do { > again: > next = pud_addr_end(addr, end); > - if (pud_none(*pud) || !walk->vma) { > + if (pud_none(*pud)) { > if (walk->pte_hole) > err = walk->pte_hole(addr, next, walk); > if (err) > @@ -95,9 +100,13 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, > break; > } > > - split_huge_pud(walk->vma, pud, addr); > - if (pud_none(*pud)) > - goto again; > + if (walk->vma) { > + split_huge_pud(walk->vma, pud, addr); Check for a PUD THP entry before attempting to split it ? > + if (pud_none(*pud)) > + goto again; > + } else if (pud_leaf(*pud)) { > + continue; > + } This is bit cryptic. walk->vma check should be inside a helper is_user_page_table() or similar to make things clear. p4d_leaf() check missing in walk_p4d_range() for kernel page table walk ? Wondering if p?d_leaf() test should be moved earlier while calling p?d_entry() for kernel page table walk. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A05FAC433FF for ; Sun, 28 Jul 2019 14:19:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75616214C6 for ; Sun, 28 Jul 2019 14:19:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dge0xLTw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75616214C6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R/lnh0iTiEx7fH7MjX65E8QpIVV1nKn+SXNekefSK7Q=; b=dge0xLTwRFS43k c3MVK1BzMmh3aqQ1jpSoBO2GjUsE1s81XuF0rJLHgKe/DWfqqT7Xq/zVq8yTF1IOLhFOA2pe6/Hh8 uWiEvdft69Dr92GjoUbXKvZoIwpVWpaix9TEiqErD2YQZO7OhMFIo914ePolE+H1pgljbCrtiVDlC A7UIlbej9pMDuMq3IHH9WUyVVTS241SZ+Yr/FNIZX9cgnRKt19pEkt+r3TXZUgaSDJQMw3KvjgaR8 UKkKgfxesC1yA1a53iRArjTK8/ueakGI/8mU61GxL++OQ7IAdK/yHhPxoulCePNBhQTDQ8ckx3nUz KQ3Oy4rCiZKxyJuOH3zg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hrk1P-0005Ty-2Q; Sun, 28 Jul 2019 14:19:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hrk1L-0005Te-G5 for linux-arm-kernel@lists.infradead.org; Sun, 28 Jul 2019 14:19:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3517E344; Sun, 28 Jul 2019 07:19:29 -0700 (PDT) Received: from [10.163.1.126] (unknown [10.163.1.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 698B53F575; Sun, 28 Jul 2019 07:19:22 -0700 (PDT) Subject: Re: [PATCH v9 12/21] mm: pagewalk: Allow walking without vma To: Steven Price , linux-mm@kvack.org References: <20190722154210.42799-1-steven.price@arm.com> <20190722154210.42799-13-steven.price@arm.com> From: Anshuman Khandual Message-ID: <7fc50563-7d5d-7270-5a6a-63769e9c335a@arm.com> Date: Sun, 28 Jul 2019 19:50:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190722154210.42799-13-steven.price@arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190728_071931_626355_F183B27E X-CRM114-Status: GOOD ( 20.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , x86@kernel.org, Arnd Bergmann , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-kernel@vger.kernel.org, =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , James Morse , Thomas Gleixner , Will Deacon , Andrew Morton , linux-arm-kernel@lists.infradead.org, "Liang, Kan" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 07/22/2019 09:12 PM, Steven Price wrote: > Since 48684a65b4e3: "mm: pagewalk: fix misbehavior of walk_page_range > for vma(VM_PFNMAP)", page_table_walk() will report any kernel area as > a hole, because it lacks a vma. > > This means each arch has re-implemented page table walking when needed, > for example in the per-arch ptdump walker. > > Remove the requirement to have a vma except when trying to split huge > pages. > > Signed-off-by: Steven Price > --- > mm/pagewalk.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index 98373a9f88b8..1cbef99e9258 100644 > --- a/mm/pagewalk.c > +++ b/mm/pagewalk.c > @@ -36,7 +36,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > do { > again: > next = pmd_addr_end(addr, end); > - if (pmd_none(*pmd) || !walk->vma) { > + if (pmd_none(*pmd)) { > if (walk->pte_hole) > err = walk->pte_hole(addr, next, walk); > if (err) > @@ -59,9 +59,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > if (!walk->pte_entry) > continue; > > - split_huge_pmd(walk->vma, pmd, addr); > - if (pmd_trans_unstable(pmd)) > - goto again; > + if (walk->vma) { > + split_huge_pmd(walk->vma, pmd, addr); Check for a PMD THP entry before attempting to split it ? > + if (pmd_trans_unstable(pmd)) > + goto again; > + } else if (pmd_leaf(*pmd)) { > + continue; > + } > + > err = walk_pte_range(pmd, addr, next, walk); > if (err) > break; > @@ -81,7 +86,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, > do { > again: > next = pud_addr_end(addr, end); > - if (pud_none(*pud) || !walk->vma) { > + if (pud_none(*pud)) { > if (walk->pte_hole) > err = walk->pte_hole(addr, next, walk); > if (err) > @@ -95,9 +100,13 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, > break; > } > > - split_huge_pud(walk->vma, pud, addr); > - if (pud_none(*pud)) > - goto again; > + if (walk->vma) { > + split_huge_pud(walk->vma, pud, addr); Check for a PUD THP entry before attempting to split it ? > + if (pud_none(*pud)) > + goto again; > + } else if (pud_leaf(*pud)) { > + continue; > + } This is bit cryptic. walk->vma check should be inside a helper is_user_page_table() or similar to make things clear. p4d_leaf() check missing in walk_p4d_range() for kernel page table walk ? Wondering if p?d_leaf() test should be moved earlier while calling p?d_entry() for kernel page table walk. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel