Re: [PATCH RFC v2 13/20] x86: mm: carve out the generic compile-time folded pgtable case in effective_prot()
From: Dave Hansen
Date: Wed Jul 22 2026 - 16:21:16 EST
On 7/22/26 10:37, Yeoreum Yun wrote:
>> On 7/22/26 08:30, Yeoreum Yun wrote:
>>> struct pg_state {
>>> struct ptdump_state ptdump;
>>> + int first_level;
>>> int level;
>>> pgprotval_t current_prot;
>>> pgprotval_t effective_prot;
>> There is zero reason on x86 to hold this value in a data structure. It
>> is 100% determined at boot time or earlier. Pre-5-level-paging it's a
>> compile-time constant.
>>
>> On x86, it never varies per-mm.
> However, mm_pXd_folded() requires to mm for other architecture like
> s390. might save the mm instead of first_level and calls the
> ptdump_pt_level_first() with static inline version would make the
> constant comparison. So it requires to save *mm* structure in here.
I'm having a really hard time parsing that.
I think you're trying to say that the effective_prot_p*() functions need
to know the first level but they don't (today) need the mm_struct. If
they don't get the (calculated) first_level passed in, they need the
mm_struct instead.
I think you're arguing 'pg_state' needs a ->first_level or a ->mm.
Having a pg_state->mm doesn't seem bad to me at all.
But, it's also a little bit silly. It would not be rocket science to
pass an mm_struct down to the effective_prot_p*() functions. It makes a
whole lot of sense to me for a page table walking function to need
metadata from the mm_struct to walk correctly.