Re: [PATCH 03/21] x86/mm: factor out phys_pgd_init()
From: Borislav Petkov
Date: Sat Oct 25 2025 - 07:48:57 EST
On Wed, Sep 24, 2025 at 02:59:38PM +0000, Brendan Jackman wrote:
> +static unsigned long __meminit
> +__kernel_physical_mapping_init(unsigned long paddr_start,
> + unsigned long paddr_end,
> + unsigned long page_size_mask,
> + pgprot_t prot, bool init)
> +{
> + bool pgd_changed;
I have to say, that pgd_changed is yuck but I don't have a better idea and
this has happened a long time ago anyway.
How about you have the caller pass in false:
bool pgd_changed = false;
and then callee sets it to true when it does so?
> + unsigned long paddr_last;
The tip-tree preferred ordering of variable declarations at the
beginning of a function is reverse fir tree order::
struct long_struct_name *descriptive_name;
unsigned long foo, bar;
unsigned int tmp;
int ret;
The above is faster to parse than the reverse ordering::
int ret;
unsigned int tmp;
unsigned long foo, bar;
struct long_struct_name *descriptive_name;
And even more so than random ordering::
unsigned long foo, bar;
int ret;
struct long_struct_name *descriptive_name;
unsigned int tmp;
> +
> + paddr_last = phys_pgd_init(init_mm.pgd, paddr_start, paddr_end, page_size_mask,
> + prot, init, &pgd_changed);
> + if (pgd_changed)
> + sync_global_pgds((unsigned long)__va(paddr_start),
> + (unsigned long)__va(paddr_end) - 1);
> +
> + return paddr_last;
> +}
>
> /*
> * Create page table mapping for the physical memory for specific physical
>
> --
> 2.50.1
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette