Re: [PATCH] thermal: Fix CPU mask truncation in power limit trace event

From: Rafael J. Wysocki (Intel)

Date: Mon Oct 26 2026 - 15:23:26 EST


On Fri, Oct 23, 2026 at 8:08 AM Hungyu Lin <dennylin0707@xxxxxxxxx> wrote:
>
> num_possible_cpus() counts CPUs, but CPU IDs need not be contiguous.
> Using it to size the thermal_power_cpu_limit bitmap can omit CPUs with
> higher IDs. For example, possible CPUs 0 and 64 produce an eight-byte
> bitmap on a 64-bit system, dropping CPU 64.
>
> Use nr_cpumask_bits for both sizing and copying the bitmap.
>
> Fixes: 6828a4711f99 ("thermal: add trace events to the power allocator governor")
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
> ---
> drivers/thermal/thermal_trace.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/thermal_trace.h b/drivers/thermal/thermal_trace.h
> index df8f4edd6068..2f953fd8289d 100644
> --- a/drivers/thermal/thermal_trace.h
> +++ b/drivers/thermal/thermal_trace.h
> @@ -119,7 +119,7 @@ TRACE_EVENT(thermal_power_cpu_limit,
> TP_ARGS(cpus, freq, cdev_state, power),
>
> TP_STRUCT__entry(
> - __bitmask(cpumask, num_possible_cpus())
> + __bitmask(cpumask, nr_cpumask_bits)
> __field(unsigned int, freq )
> __field(unsigned long, cdev_state)
> __field(u32, power )
> @@ -127,7 +127,7 @@ TRACE_EVENT(thermal_power_cpu_limit,
>
> TP_fast_assign(
> __assign_bitmask(cpumask, cpumask_bits(cpus),
> - num_possible_cpus());
> + nr_cpumask_bits);
> __entry->freq = freq;
> __entry->cdev_state = cdev_state;
> __entry->power = power;
>
> base-commit: 503bb6e70bbf6304b8113373d09dfffcc4aa9183
> --

Applied as 7.4-rc material, thanks!