[PATCH RFC v3 15/21] x86: mm: skip collapse_pud_page() when CONFIG_X86_DIRECT_GBPAGES disabled

Dave Hansen dave.hansen at intel.com
Wed Sep 2 08:38:12 PDT 2026


On 9/2/26 04:56, Yeoreum Yun wrote:
> The behaviour of pXd_page() will change with generic compile-time folded
> page tables by disallowing its use and triggering a compile-time error
> when it's used improperly, ensuring that the actual pXd_page() is used
> instead.
> 
> To prepare fot that, skip collapse_pud_page() when
> CONFIG_X86_DIRECT_GBPAGES is disabled.

Nit: this doesn't explain how the change actually fixes anything or what
the specific problem being solved is.

I think you want to say something along the lines of:

	collapse_pud_page() uses pud_page() in a way which will soon
	trigger a compile-time error on configs that have a folded pud.

	The code which will generate that error is actually unreachable
	on those configs because 'direct_gbpages' is always 0 there.
	However, the compiler does not know that because
	'direct_gbpages' is a normal integer from a separate compilation
	unit.

	Make the compiler aware when most of collapse_pud_page() is
	unreachable by adding a Kconfig check. This ensures it will not
	trip the errors when they are introduced. It probably also trims
	the kernel image down a wee bit too as a side benefit.

Maybe I should just merge something like the attached patch. I think it
would solve your problem and make things generally cleaner too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: direct_gbpages-compiletime.patch
Type: text/x-patch
Size: 4323 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20260902/1fd65640/attachment.bin>


More information about the linux-riscv mailing list