Re: [RFC PATCH 19/34] x86: power: use proper set_pXd() for generic compile-time folded patable in resume_one_md_table_init()

Dave Hansen <[email protected]>
Newsgroups org.kernel.vger.linux-arch,dev.linux.lists.loongarch,org.infradead.lists.kvm-riscv,org.infradead.lists.linux-riscv,org.kernel.vger.linux-csky,org.kernel.vger.linux-kernel,org.kernel.vger.linux-m68k,org.kernel.vger.linux-mips,org.kernel.vger.linux-openrisc
Message-ID <[email protected]>
On 7/13/26 06:55, Yeoreum Yun wrote:
> @@ -134,11 +129,12 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir)
>  {
>  #ifdef CONFIG_X86_PAE
>  	int i;
> +	pud_t *pud = pud_offset(p4d_offset(pg_dir, 0), 0);
>  
>  	/* Init entries of the first-level page table to the zero page */
>  	for (i = 0; i < PTRS_PER_PGD; i++)
> -		set_pgd(pg_dir + i,
> -			__pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
> +		set_pud(pud + i,
> +			__pud(__pa(empty_zero_page) | _PAGE_PRESENT));
>  #endif
>  }

If this is the way forward, it's going to require the retraining of some
awfully old brain cells.

It also doesn't really read correctly. Loop over each PGD entry:

	for (i = 0; i < PTRS_PER_PGD; i++)

... and set a pud?

		set_pud(...)

I'm not sure how I'd ever learn the rules to write this code from
scratch. Right now, the code says: "The pgd_t is the top level of the
page tables. I know there are PTRS_PER_PGD of those top level entries
entries I need to 'zero'."

You don't have to know what is folded, just that you're dealing with the
top level.

But *this* code says:

1. The pgd_t is the top level of the page tables. Start there.
2. "Walk" down *two* (folded) levels
3. Set the third-level (pud) entries to 'zero'

So the code now *has* to know how the folding occurs.

This seems really hard to work with to me.
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.