[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+ZOyahE7Z8jw60iu__wE5eeBSvmE57eAY8XY4q3fDdJb6gDrQ@mail.gmail.com>
Date: Thu, 24 Oct 2019 21:06:25 +0800
From: Zong Li <zongbox@...il.com>
To: Steven Price <steven.price@....com>
Cc: linux-mm@...ck.org, Andy Lutomirski <luto@...nel.org>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Arnd Bergmann <arnd@...db.de>, Borislav Petkov <bp@...en8.de>,
Catalin Marinas <catalin.marinas@....com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
James Morse <james.morse@....com>,
Jérôme Glisse <jglisse@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <will@...nel.org>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
linux-arm-kernel@...ts.infradead.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Mark Rutland <Mark.Rutland@....com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v12 13/22] mm: pagewalk: Add test_p?d callbacks
Steven Price <steven.price@....com> 於 2019年10月19日 週六 下午4:12寫道:
>
> 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 <steven.price@....com>
> ---
> 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);
> };
>
> /**
> 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 addr, unsigned long end,
> const struct mm_walk_ops *ops = walk->ops;
> int err = 0;
>
> + if (ops->test_pmd) {
> + err = ops->test_pmd(addr, end, pmd_offset(pud, 0UL), walk);
> + if (err < 0)
> + return err;
> + if (err > 0)
> + return 0;
> + }
> +
> pmd = pmd_offset(pud, addr);
> do {
> again:
> @@ -85,6 +93,14 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
> const struct mm_walk_ops *ops = walk->ops;
> int err = 0;
>
> + if (ops->test_pud) {
> + err = ops->test_pud(addr, end, pud_offset(p4d, 0UL), walk);
> + if (err < 0)
> + return err;
> + if (err > 0)
> + return 0;
> + }
> +
> pud = 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 = walk->ops;
> int err = 0;
>
> + if (ops->test_p4d) {
> + err = ops->test_p4d(addr, end, p4d_offset(pgd, 0UL), walk);
> + if (err < 0)
> + return err;
> + if (err > 0)
> + return 0;
> + }
> +
> p4d = p4d_offset(pgd, addr);
> do {
> next = p4d_addr_end(addr, end);
> --
> 2.20.1
>
It's good to me.
Tested-by: Zong Li <zong.li@...ive.com>
Powered by blists - more mailing lists