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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 A5248C2D0D9 for ; Fri, 6 Dec 2019 13:54:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6ED6320706 for ; Fri, 6 Dec 2019 13:54:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ED6320706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 050216B162E; Fri, 6 Dec 2019 08:54:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 027566B162F; Fri, 6 Dec 2019 08:54:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7EB26B1630; Fri, 6 Dec 2019 08:54:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id D30166B162E for ; Fri, 6 Dec 2019 08:54:28 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 94E2C689B for ; Fri, 6 Dec 2019 13:54:28 +0000 (UTC) X-FDA: 76234861416.22.fifth36_4420d6536504a X-HE-Tag: fifth36_4420d6536504a X-Filterd-Recvd-Size: 5162 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Dec 2019 13:54:28 +0000 (UTC) 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 7078411D4; Fri, 6 Dec 2019 05:54:27 -0800 (PST) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CA94D3F718; Fri, 6 Dec 2019 05:54:24 -0800 (PST) From: Steven Price To: Andrew Morton , linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , 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" , Zong Li Subject: [PATCH v16 15/25] mm: pagewalk: Add test_p?d callbacks Date: Fri, 6 Dec 2019 13:53:06 +0000 Message-Id: <20191206135316.47703-16-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191206135316.47703-1-steven.price@arm.com> References: <20191206135316.47703-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It is useful to be able to skip parts of the page table tree even when walking without VMAs. Add test_p?d callbacks similar to test_walk but which are called just before a table at that level is walked. If the callback returns non-zero then the entire table is skipped. Tested-by: Zong Li Signed-off-by: Steven Price --- include/linux/pagewalk.h | 11 +++++++++++ mm/pagewalk.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h index 2c9725bdcf1f..84ac77620bfc 100644 --- a/include/linux/pagewalk.h +++ b/include/linux/pagewalk.h @@ -24,6 +24,11 @@ struct mm_walk; * "do page table walk over the current vma", returning * a negative value means "abort current page table walk * right now" and returning 1 means "skip the current vma" + * @test_pmd: similar to test_walk(), but called for every pmd. + * @test_pud: similar to test_walk(), but called for every pud. + * @test_p4d: similar to test_walk(), but called for every p4d. + * Returning 0 means walk this part of the page tables, + * returning 1 means to skip this range. * @pre_vma: if set, called before starting walk on a non-nul= l vma. * @post_vma: if set, called after a walk on a non-null vma, p= rovided * that @pre_vma and the vma walk succeeded. @@ -49,6 +54,12 @@ struct mm_walk_ops { struct mm_walk *walk); int (*test_walk)(unsigned long addr, unsigned long next, struct mm_walk *walk); + int (*test_pmd)(unsigned long addr, unsigned long next, + pmd_t *pmd_start, struct mm_walk *walk); + int (*test_pud)(unsigned long addr, unsigned long next, + pud_t *pud_start, struct mm_walk *walk); + int (*test_p4d)(unsigned long addr, unsigned long next, + p4d_t *p4d_start, struct mm_walk *walk); int (*pre_vma)(unsigned long start, unsigned long end, struct mm_walk *walk); void (*post_vma)(struct mm_walk *walk); diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 88104ab00a97..83ab6c1ebf9b 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -38,6 +38,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long ad= dr, unsigned long end, const struct mm_walk_ops *ops =3D walk->ops; int err =3D 0; =20 + if (ops->test_pmd) { + err =3D ops->test_pmd(addr, end, pmd_offset(pud, 0UL), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pmd =3D pmd_offset(pud, addr); do { again: @@ -89,6 +97,14 @@ static int walk_pud_range(p4d_t *p4d, unsigned long ad= dr, unsigned long end, const struct mm_walk_ops *ops =3D walk->ops; int err =3D 0; =20 + if (ops->test_pud) { + err =3D ops->test_pud(addr, end, pud_offset(p4d, 0UL), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pud =3D pud_offset(p4d, addr); do { again: @@ -132,6 +148,14 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long = addr, unsigned long end, const struct mm_walk_ops *ops =3D walk->ops; int err =3D 0; =20 + if (ops->test_p4d) { + err =3D ops->test_p4d(addr, end, p4d_offset(pgd, 0UL), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + p4d =3D p4d_offset(pgd, addr); do { next =3D p4d_addr_end(addr, end); --=20 2.20.1