Re: [RFC PATCH 10/34] x86: mm: carve out the generic compile-time folded pgtable case in effective_prot()
Geert Uytterhoeven <[email protected]> Wed, 15 Jul 2026 12:34:29 +0200
| Newsgroups | org.kernel.vger.linux-csky,dev.linux.lists.loongarch,org.infradead.lists.kvm-riscv,org.infradead.lists.linux-riscv,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.linux-m68k,org.kernel.vger.linux-mips,org.kernel.vger.linux-openrisc,org.kvack.linux-mm |
|---|---|
| Message-ID | <CAMuHMdVOHm6MmP9QsNVvxLsGp1e0jC9u9RGb6+xee0ZBs4Zwfw@mail.gmail.com> |
Hi Yeoreum, On Wed, 15 Jul 2026 at 11:42, Yeoreum Yun <[email protected]> wrote: > > On Tue, 14 Jul 2026 at 18:51, Yeoreum Yun <[email protected]> wrote: > > > --- a/mm/ptdump.c > > > +++ b/mm/ptdump.c > > > @@ -190,6 +190,23 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd) > > > st->note_page_flush(st); > > > } > > > > > > +bool pdtump_pt_level_first(struct mm_struct *mm, int level) > > > +{ > > > + if (!mm || level > CONFIG_PGTABLE_LEVELS) > > > + return false; > > > + > > > + if (mm_pmd_folded(mm) && level == 3) > > > + return true; > > > + if (mm_pud_folded(mm) && level == 2) > > > + return true; > > > + if (mm_p4d_folded(mm) && level == 1) > > > + return true; > > > > Is this order (... && level == ...) the optimal order? > > On arm64, mm_pud_folded() and mm_p4d_folded() perform several checks. > > > > > + if (level == 0) > > > + return true; > > > + > > > + return false; > > > +} > > It is. since the purpose of ptdump_pt_level_first is designed to be used > in the *callback* of pXd_entry(). IOW, if we check level 0 first, > it always returns wrong return in folded case. I meant the order inside the if () conditions. E.g. "if (mm_pud_folded(mm) && level == 2)" does the expensive check first. "if (level == 2 && mm_pud_folded(mm))" does the cheap check first. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds