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