thermal: Fix CPU mask truncation in power limit trace event
PATCH 1/1 thermal: Fix CPU mask truncation in power limit trace event
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.
--- drivers/thermal/thermal_trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/thermal_trace.h +2 -2
@@ -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
Signature · 1 line
2.43.0
Quoted 37 lines · Hungyu Lin
num_possible_cpus()counts CPUs, but CPU IDs need not be contiguous. Using it to size thethermal_power_cpu_limitbitmap 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_bitsfor both sizing and copying the bitmap.Fixes 6828a4711f99 ("thermal: add trace events to the power allocator governor")Signed-off-by Hungyu Lin <[email protected]>--- drivers/thermal/thermal_trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/thermal/thermal_trace.h +2
-2@@ -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;
Quoted 2 lines
base-commit:
503bb6e70bbf6304b8113373d09dfffcc4aa9183--
Applied as 7.4-rc material, thanks!