On Tue, Jul 14, 2026 at 06:31:22PM +0200, David Hildenbrand (Arm) wrote: > > >> This makes a *ton* of sense in effective_prot() especially. Its entire > >> job is mirroring the hardware's job of inheriting permissions from > >> higher levels of the page tables and enforcing them on lower level leaf > >> entries. If a higher level is folded, there's nothing to inherit. > >> > >> I also think it's worth taking a brief pause on the coding to think > >> about what kind of design would actually be nice here. If the design > >> really is that the pgd is folded, the 'struct mm_walk_ops' code would > >> ideally not even call ->pgd_entry(). It would just (for example) *start* > >> at ->pud_entry() for a 3-level hardware page table. > >> > >> If there are no pgds, why bother calling ->pgd_entry()? It couldn't be > >> done transparently to mm_walk users of course but it could be done > >> incrementally where users move one at a time over to a new scheme. > > > > Agree. Calling a pXd_entry() about folded one seems meaningless. > > But seems enough to check mm_pXd_folded() before calling pXd_entry() > > in each walk_pXd_range(). > > Needs some double-checking that callers can handle it (like effective_prot() > would currently not), but certainly something to look into!
Most of mm_walk_ops *implicitly* handles the folded pgtable case (e.x) pXd_none() / pXd_present() and other can handle explicitly in its own handler. But, IMHO, It would be better to skip calling pXd_entry() in the walk_pXd_range() by checking the folded and this is clearer conceptually. For this, it requires the rewrite the walk_mm() where use only *p4d_entry()* to gather the leaf/non-leaf information for MGLRU. -- Sincerely, Yeoreum Yun
