diff mbox series

[RFC,3/3] powerpc/kho: exclude THP and HUGETLB_PAGE

Message ID 20260821105609.983622-4-sourabhjain@linux.ibm.com (mailing list archive)
State New
Headers show
Series powerpc: initial support for Kexec HandOver (KHO) | expand

Commit Message

Sourabh Jain Aug. 21, 2026, 10:56 a.m. UTC
Enabling CONFIG_KEXEC_HANDOVER together with CONFIG_TRANSPARENT_HUGEPAGE
or CONFIG_HUGETLB_PAGE on powerpc fails to build:

    kernel/liveupdate/kexec_handover.c:49:39: error: expression in static assertion is not constant
       49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);
    ./include/linux/build_bug.h:80:56: note: in definition of macro '__static_assert'
       80 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
          |                                                        ^~~~
    kernel/liveupdate/kexec_handover.c:49:1: note: in expansion of macro 'static_assert'
       49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);

CMA_MIN_ALIGNMENT_BYTES is derived from pageblock_order, which on
powerpc is not a compile-time constant when THP or HUGETLB_PAGE is
enabled -- powerpc can determine huge page size at runtime in that
configuration, so pageblock_order becomes a variable rather than a
constant expression. KHO's static_assert() on
SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES then fails to
compile, since it requires both sides to be constant expressions.

Until CMA_MIN_ALIGNMENT_BYTES (or KHO's use of it) is made to handle
the non-constant pageblock_order case on powerpc, exclude
TRANSPARENT_HUGEPAGE and HUGETLB_PAGE from ARCH_SUPPORTS_KEXEC_HANDOVER
so the two can't be enabled together and hit this build failure.

Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: kexec@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 arch/powerpc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Comments

Pratyush Yadav Aug. 21, 2026, 11:34 a.m. UTC | #1
On Fri, Aug 21 2026, Sourabh Jain wrote:

> Enabling CONFIG_KEXEC_HANDOVER together with CONFIG_TRANSPARENT_HUGEPAGE
> or CONFIG_HUGETLB_PAGE on powerpc fails to build:
>
>     kernel/liveupdate/kexec_handover.c:49:39: error: expression in static assertion is not constant
>        49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);
>     ./include/linux/build_bug.h:80:56: note: in definition of macro '__static_assert'
>        80 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>           |                                                        ^~~~
>     kernel/liveupdate/kexec_handover.c:49:1: note: in expansion of macro 'static_assert'
>        49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);
>
> CMA_MIN_ALIGNMENT_BYTES is derived from pageblock_order, which on
> powerpc is not a compile-time constant when THP or HUGETLB_PAGE is
> enabled -- powerpc can determine huge page size at runtime in that
> configuration, so pageblock_order becomes a variable rather than a
> constant expression. KHO's static_assert() on
> SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES then fails to
> compile, since it requires both sides to be constant expressions.
>
> Until CMA_MIN_ALIGNMENT_BYTES (or KHO's use of it) is made to handle
> the non-constant pageblock_order case on powerpc, exclude
> TRANSPARENT_HUGEPAGE and HUGETLB_PAGE from ARCH_SUPPORTS_KEXEC_HANDOVER
> so the two can't be enabled together and hit this build failure.

This should be a part of patch 2 I think. It is not a good idea to break
the build in one patch and fix it in the next.

That said, this is a debug check of sorts since SCRATCH_ALIGNMENT_BYTES
is of MAX_ORDER_NR_PAGES, and pageblocks _should_ always be smaller of
equal to this.

Anyway, I don't think this is something you should gate by a config. I
think you should either remove the static_assert(), or turn it into a
runtime check.

+Cc Michal.

>
> Cc: Aditya Gupta <adityag@linux.ibm.com>
> Cc: Alexander Graf <graf@amazon.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Baoquan He <baoquan.he@linux.dev>
> Cc: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Cc: Hari Bathini <hbathini@linux.ibm.com>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
> Cc: Pratyush Yadav <pratyush@kernel.org>
> Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: kexec@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> ---
>  arch/powerpc/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 61350d3e7a19..f68b9fc883ba 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -720,6 +720,7 @@ config ARCH_SUPPORTS_KEXEC_HANDOVER
>  	def_bool y
>  	depends on PPC64
>  	depends on !CRASH_DUMP
> +	depends on !TRANSPARENT_HUGEPAGE && !HUGETLB_PAGE
>  
>  config ARCH_SUPPORTS_CRASH_HOTPLUG
>  	def_bool y
Sourabh Jain Aug. 23, 2026, 1:52 p.m. UTC | #2
On 21/08/26 17:04, Pratyush Yadav wrote:
> On Fri, Aug 21 2026, Sourabh Jain wrote:
>
>> Enabling CONFIG_KEXEC_HANDOVER together with CONFIG_TRANSPARENT_HUGEPAGE
>> or CONFIG_HUGETLB_PAGE on powerpc fails to build:
>>
>>      kernel/liveupdate/kexec_handover.c:49:39: error: expression in static assertion is not constant
>>         49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);
>>      ./include/linux/build_bug.h:80:56: note: in definition of macro '__static_assert'
>>         80 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
>>            |                                                        ^~~~
>>      kernel/liveupdate/kexec_handover.c:49:1: note: in expansion of macro 'static_assert'
>>         49 | static_assert(SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES);
>>
>> CMA_MIN_ALIGNMENT_BYTES is derived from pageblock_order, which on
>> powerpc is not a compile-time constant when THP or HUGETLB_PAGE is
>> enabled -- powerpc can determine huge page size at runtime in that
>> configuration, so pageblock_order becomes a variable rather than a
>> constant expression. KHO's static_assert() on
>> SCRATCH_ALIGNMENT_BYTES >= CMA_MIN_ALIGNMENT_BYTES then fails to
>> compile, since it requires both sides to be constant expressions.
>>
>> Until CMA_MIN_ALIGNMENT_BYTES (or KHO's use of it) is made to handle
>> the non-constant pageblock_order case on powerpc, exclude
>> TRANSPARENT_HUGEPAGE and HUGETLB_PAGE from ARCH_SUPPORTS_KEXEC_HANDOVER
>> so the two can't be enabled together and hit this build failure.
> This should be a part of patch 2 I think. It is not a good idea to break
> the build in one patch and fix it in the next.

Agree. Since this is an RFC patch series, I kept it separate so that 
this issue could
be reviewed independently from patch 2. Going forward, I will merge them.


>
> That said, this is a debug check of sorts since SCRATCH_ALIGNMENT_BYTES
> is of MAX_ORDER_NR_PAGES, and pageblocks _should_ always be smaller of
> equal to this.
>
> Anyway, I don't think this is something you should gate by a config. I
> think you should either remove the static_assert(), or turn it into a
> runtime check.

Agreed. I will evaluate both options and decide which approach makes 
more sense.

Thanks for the review Pratyush.

- Sourabh Jain


>
> +Cc Michal.
>
>> Cc: Aditya Gupta <adityag@linux.ibm.com>
>> Cc: Alexander Graf <graf@amazon.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Baoquan He <baoquan.he@linux.dev>
>> Cc: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
>> Cc: Hari Bathini <hbathini@linux.ibm.com>
>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Mike Rapoport <rppt@kernel.org>
>> Cc: Nicholas Piggin <npiggin@gmail.com>
>> Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
>> Cc: Pratyush Yadav <pratyush@kernel.org>
>> Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
>> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
>> Cc: kexec@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> ---
>>   arch/powerpc/Kconfig | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 61350d3e7a19..f68b9fc883ba 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -720,6 +720,7 @@ config ARCH_SUPPORTS_KEXEC_HANDOVER
>>   	def_bool y
>>   	depends on PPC64
>>   	depends on !CRASH_DUMP
>> +	depends on !TRANSPARENT_HUGEPAGE && !HUGETLB_PAGE
>>   
>>   config ARCH_SUPPORTS_CRASH_HOTPLUG
>>   	def_bool y
diff mbox series

Patch

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 61350d3e7a19..f68b9fc883ba 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -720,6 +720,7 @@  config ARCH_SUPPORTS_KEXEC_HANDOVER
 	def_bool y
 	depends on PPC64
 	depends on !CRASH_DUMP
+	depends on !TRANSPARENT_HUGEPAGE && !HUGETLB_PAGE
 
 config ARCH_SUPPORTS_CRASH_HOTPLUG
 	def_bool y