Re: [PATCH v3 07/26] x86/mm: introduce mm-local region

"Brendan Jackman" <[email protected]>
Newsgroups org.kvack.linux-mm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Sun Aug 2, 2026 at 5:27 PM BST, Mike Rapoport wrote:
...
>> +#if defined(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION) && defined(CONFIG_X86_PAE)
>> +static inline pmd_t *pgd_to_pmd_walk(pgd_t *pgd, unsigned long va)
>
> There's very similar mm_find_pmd() in mm/rmap.c and I bet a bunch of other
> places walk from PGD to PMD and return PMD in the end.
>
> Can we put this function into, say, mm/pgtable-generic.c?
> Finding all the places that do such walk and sticking it there should not
> be a part of this set IMNHO, but having it in the generic code is a good
> start for a future cleanup.

Yeah, this is the kinda subtlety I always run into when trying to play
with pagetable code, and I end up being timid. The thing is that
mm_find_pmd() bails when it finds a non-present entry.

I think in this case it's fine, so yeah we could at least move
mm_find_pmd(), change the mm arg to a pgd_t*, rename it, and call it
from here.

>> +{
>> +	p4d_t *p4d;
>> +	pud_t *pud;
>> +
>> +	if (pgd->pgd == 0)
>> +		return NULL;
>> +
>> +	p4d = p4d_offset(pgd, va);
>> +	if (p4d_none(*p4d))
>> +		return NULL;
>> +
>> +	pud = pud_offset(p4d, va);
>> +	if (pud_none(*pud))
>> +		return NULL;
>> +
>> +	return pmd_offset(pud, va);
>> +}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.