Commit 4578ee7e authored by Chen Yu's avatar Chen Yu Committed by Rafael J. Wysocki

intel_pstate: Avoid unnecessary synchronize_sched() during initialization

Currently, in intel_pstate_clear_update_util_hook(), after
clearing the utilization update hook, we leverage
synchronize_sched() to deal with synchronization, which
is a little bit time-costly because synchronize_sched()
has to wait for all the CPUs to go through a grace period.

Actually, the synchronize_sched() is not necessary if the utilization
update hook has not been set for the given CPU yet, so make the driver
check if that's the case and avoid the synchronize_sched() call then.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=116371Tested-by: default avatarTian Ye <yex.tian@intel.com>
Signed-off-by: default avatarChen Yu <yu.c.chen@intel.com>
[ rjw : Rebase ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c29af6f1
...@@ -168,6 +168,7 @@ struct _pid { ...@@ -168,6 +168,7 @@ struct _pid {
* struct cpudata - Per CPU instance data storage * struct cpudata - Per CPU instance data storage
* @cpu: CPU number for this instance data * @cpu: CPU number for this instance data
* @update_util: CPUFreq utility callback information * @update_util: CPUFreq utility callback information
* @update_util_set: CPUFreq utility callback is set
* @pstate: Stores P state limits for this CPU * @pstate: Stores P state limits for this CPU
* @vid: Stores VID limits for this CPU * @vid: Stores VID limits for this CPU
* @pid: Stores PID parameters for this CPU * @pid: Stores PID parameters for this CPU
...@@ -187,6 +188,7 @@ struct cpudata { ...@@ -187,6 +188,7 @@ struct cpudata {
int cpu; int cpu;
struct update_util_data update_util; struct update_util_data update_util;
bool update_util_set;
struct pstate_data pstate; struct pstate_data pstate;
struct vid_data vid; struct vid_data vid;
...@@ -1417,11 +1419,18 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num) ...@@ -1417,11 +1419,18 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
cpu->sample.time = 0; cpu->sample.time = 0;
cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, cpufreq_add_update_util_hook(cpu_num, &cpu->update_util,
intel_pstate_update_util); intel_pstate_update_util);
cpu->update_util_set = true;
} }
static void intel_pstate_clear_update_util_hook(unsigned int cpu) static void intel_pstate_clear_update_util_hook(unsigned int cpu)
{ {
struct cpudata *cpu_data = all_cpu_data[cpu];
if (!cpu_data->update_util_set)
return;
cpufreq_remove_update_util_hook(cpu); cpufreq_remove_update_util_hook(cpu);
cpu_data->update_util_set = false;
synchronize_sched(); synchronize_sched();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment