Skip to content

Commit

Permalink
thermal: intel_powerclamp: Use first online CPU as control_cpu
Browse files Browse the repository at this point in the history
Commit 68b99e9 ("thermal: intel_powerclamp: Use get_cpu() instead
of smp_processor_id() to avoid crash") fixed an issue related to using
smp_processor_id() in preemptible context by replacing it with a pair
of get_cpu()/put_cpu(), but what is needed there really is any online
CPU and not necessarily the one currently running the code.  Arguably,
getting the one that's running the code in there is confusing.

For this reason, simply give the control CPU role to the first online
one which automatically will be CPU0 if it is online, so one check
can be dropped from the code for an added benefit.

Link: https://lore.kernel.org/linux-pm/20221011113646.GA12080@duo.ucw.cz/
Fixes: 68b99e9 ("thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
  • Loading branch information
Rafael J. Wysocki committed Oct 15, 2022
1 parent aa512c1 commit 4bb7f6c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions drivers/thermal/intel/intel_powerclamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,7 @@ static int start_power_clamp(void)
cpus_read_lock();

/* prefer BSP */
control_cpu = 0;
if (!cpu_online(control_cpu)) {
control_cpu = get_cpu();
put_cpu();
}
control_cpu = cpumask_first(cpu_online_mask);

clamping = true;
schedule_delayed_work(&poll_pkg_cstate_work, 0);
Expand Down

0 comments on commit 4bb7f6c

Please sign in to comment.