Re: [PATCH v2 01/22] x86/mm: split out preallocate_sub_pgd()
From: Brendan Jackman
Date: Mon Mar 23 2026 - 07:13:30 EST
On Fri Mar 20, 2026 at 7:42 PM UTC, Dave Hansen wrote:
> On 3/20/26 11:23, Brendan Jackman wrote:
>> - /*
>> - * The goal here is to allocate all possibly required
>> - * hardware page tables pointed to by the top hardware
>> - * level.
>
> This comment is pretty important, IMNHO, and you zapped it.
>
> The problem here is that the per-MM carved out space is PGD-sized. You
> want to make sure there are page tables allocated for that space. But,
> if you say "go allocate a p4d" then that will collapse down to doing
> nothing on a 4-level system.
>
> So, this is effectively:
>
> Go allocate a p4d or pud, depending on if it's 4 or 5 level.
> Basically, always allocate the level that the hardware PGD
> points to.
>
> Could we put a comment to that effect around somewhere, please?
Hm I kinda thought the comments I left in there captured all this stuff,
but yeah I can see this is a bit of a weird function so more commentary
makes sense. How about I just put a few more words into the top comment:
/*
* Allocate all possibly requried hardware page tables pointed to ths
* top hardware level. In other words, allocate a p4d on 5-level or a
* pud on 4-level.
*/
And then just leave the internal one as it is:
/*
* On 4-level systems, the P4D layer is folded away and
* the above code does no preallocation. Below, go down
* to the pud _software_ level to ensure the second
* hardware level is allocated on 4-level systems too.
*/