thermal/intel_powerclamp: Remove duplicated code that starts the kthread
This patch removes code duplication. It does not modify the functionality. Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
c1de45ca83
commit
14f3f7d8cb
@ -508,10 +508,27 @@ static void poll_pkg_cstate(struct work_struct *dummy)
|
|||||||
schedule_delayed_work(&poll_pkg_cstate_work, HZ);
|
schedule_delayed_work(&poll_pkg_cstate_work, HZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void start_power_clamp_thread(unsigned long cpu)
|
||||||
|
{
|
||||||
|
struct task_struct **p = per_cpu_ptr(powerclamp_thread, cpu);
|
||||||
|
struct task_struct *thread;
|
||||||
|
|
||||||
|
thread = kthread_create_on_node(clamp_thread,
|
||||||
|
(void *) cpu,
|
||||||
|
cpu_to_node(cpu),
|
||||||
|
"kidle_inject/%ld", cpu);
|
||||||
|
if (IS_ERR(thread))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* bind to cpu here */
|
||||||
|
kthread_bind(thread, cpu);
|
||||||
|
wake_up_process(thread);
|
||||||
|
*p = thread;
|
||||||
|
}
|
||||||
|
|
||||||
static int start_power_clamp(void)
|
static int start_power_clamp(void)
|
||||||
{
|
{
|
||||||
unsigned long cpu;
|
unsigned long cpu;
|
||||||
struct task_struct *thread;
|
|
||||||
|
|
||||||
set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
|
set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
|
||||||
/* prevent cpu hotplug */
|
/* prevent cpu hotplug */
|
||||||
@ -527,20 +544,7 @@ static int start_power_clamp(void)
|
|||||||
|
|
||||||
/* start one thread per online cpu */
|
/* start one thread per online cpu */
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
struct task_struct **p =
|
start_power_clamp_thread(cpu);
|
||||||
per_cpu_ptr(powerclamp_thread, cpu);
|
|
||||||
|
|
||||||
thread = kthread_create_on_node(clamp_thread,
|
|
||||||
(void *) cpu,
|
|
||||||
cpu_to_node(cpu),
|
|
||||||
"kidle_inject/%ld", cpu);
|
|
||||||
/* bind to cpu here */
|
|
||||||
if (likely(!IS_ERR(thread))) {
|
|
||||||
kthread_bind(thread, cpu);
|
|
||||||
wake_up_process(thread);
|
|
||||||
*p = thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
put_online_cpus();
|
put_online_cpus();
|
||||||
|
|
||||||
@ -572,7 +576,6 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb,
|
|||||||
unsigned long action, void *hcpu)
|
unsigned long action, void *hcpu)
|
||||||
{
|
{
|
||||||
unsigned long cpu = (unsigned long)hcpu;
|
unsigned long cpu = (unsigned long)hcpu;
|
||||||
struct task_struct *thread;
|
|
||||||
struct task_struct **percpu_thread =
|
struct task_struct **percpu_thread =
|
||||||
per_cpu_ptr(powerclamp_thread, cpu);
|
per_cpu_ptr(powerclamp_thread, cpu);
|
||||||
|
|
||||||
@ -581,15 +584,7 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb,
|
|||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CPU_ONLINE:
|
case CPU_ONLINE:
|
||||||
thread = kthread_create_on_node(clamp_thread,
|
start_power_clamp_thread(cpu);
|
||||||
(void *) cpu,
|
|
||||||
cpu_to_node(cpu),
|
|
||||||
"kidle_inject/%lu", cpu);
|
|
||||||
if (likely(!IS_ERR(thread))) {
|
|
||||||
kthread_bind(thread, cpu);
|
|
||||||
wake_up_process(thread);
|
|
||||||
*percpu_thread = thread;
|
|
||||||
}
|
|
||||||
/* prefer BSP as controlling CPU */
|
/* prefer BSP as controlling CPU */
|
||||||
if (cpu == 0) {
|
if (cpu == 0) {
|
||||||
control_cpu = 0;
|
control_cpu = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user