Re: [PATCH] leds: trigger: ledtrig-cpu:: enforce NR_CPUS limit in Kconfig

From: Lee Jones
Date: Wed Jun 25 2025 - 05:40:05 EST


On Fri, 20 Jun 2025, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> This driver fails build testing with larger values of CONFIG_NR_CPUS:
>
> drivers/leds/trigger/ledtrig-cpu.c: In function ‘ledtrig_cpu_init’:
> include/linux/compiler_types.h:571:45: error: call to ‘__compiletime_assert_726’ declared with attribute error: BUILD_BUG_ON failed: CONFIG_NR_CPUS > 9999
> drivers/leds/trigger/ledtrig-cpu.c:137:9: note: in expansion of macro ‘BUILD_BUG_ON’
> 137 | BUILD_BUG_ON(CONFIG_NR_CPUS > 9999);
>
> Enforce this limit in Kconfig instead to avoid the build failure.

I have so many questions!

- This number seems arbitrary - what is the limiting factor?
- Character size for printing?
- What platform did you test this on to blow through that number?
- What if we really do want 10000+ CPUs?
- And what will that LED array look like to support them all?
- If we're enforcing here, is the BUILD_BUG_ON() now superfluous?

> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> drivers/leds/trigger/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
> index c11282a74b5a..e07bd17cfe35 100644
> --- a/drivers/leds/trigger/Kconfig
> +++ b/drivers/leds/trigger/Kconfig
> @@ -65,6 +65,7 @@ config LEDS_TRIGGER_BACKLIGHT
> config LEDS_TRIGGER_CPU
> bool "LED CPU Trigger"
> depends on !PREEMPT_RT
> + depends on NR_CPUS <= 9999
> help
> This allows LEDs to be controlled by active CPUs. This shows
> the active CPUs across an array of LEDs so you can see which
> --
> 2.39.5
>

--
Lee Jones [李琼斯]