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=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 867F1C47404 for ; Mon, 7 Oct 2019 15:39:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4942320700 for ; Mon, 7 Oct 2019 15:39:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4942320700 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 EA5CB8E0014; Mon, 7 Oct 2019 11:39:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2DED8E0003; Mon, 7 Oct 2019 11:39:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA6148E0014; Mon, 7 Oct 2019 11:39:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id A61D08E0003 for ; Mon, 7 Oct 2019 11:39:21 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 5556B181AC9B4 for ; Mon, 7 Oct 2019 15:39:21 +0000 (UTC) X-FDA: 76017397722.22.rock56_6ebd883147346 X-HE-Tag: rock56_6ebd883147346 X-Filterd-Recvd-Size: 4827 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Oct 2019 15:39:20 +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 20FFF15AB; Mon, 7 Oct 2019 08:39:20 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [10.1.197.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89C2E3F6C4; Mon, 7 Oct 2019 08:39:17 -0700 (PDT) From: Steven Price To: 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" , Andrew Morton Subject: [PATCH v11 13/22] mm: pagewalk: Add test_p?d callbacks Date: Mon, 7 Oct 2019 16:38:13 +0100 Message-Id: <20191007153822.16518-14-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007153822.16518-1-steven.price@arm.com> References: <20191007153822.16518-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. 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 12004b097eae..df424197a25a 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. * * p?d_entry callbacks are called even if those levels are folded on a * particular architecture/configuration. @@ -46,6 +51,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); }; =20 /** diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 4139e9163aee..43acffefd43f 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -34,6 +34,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: @@ -85,6 +93,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: @@ -128,6 +144,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