diff options
author | Chen Yu <yu.c.chen@intel.com> | 2016-05-11 02:33:08 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-05-11 16:56:34 -0400 |
commit | 4578ee7e1defe534582fe3afdb747b86023207f0 (patch) | |
tree | 2857ab0921181c08f60d3030ba8e04656f063e53 | |
parent | c29af6f1a4e6f54e806fed1c40e7d338650b7791 (diff) |
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=116371
Tested-by: Tian Ye <yex.tian@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
[ rjw : Rebase ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index cde1a4ecaa6e..36953b5f18de 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -168,6 +168,7 @@ struct _pid { | |||
168 | * struct cpudata - Per CPU instance data storage | 168 | * struct cpudata - Per CPU instance data storage |
169 | * @cpu: CPU number for this instance data | 169 | * @cpu: CPU number for this instance data |
170 | * @update_util: CPUFreq utility callback information | 170 | * @update_util: CPUFreq utility callback information |
171 | * @update_util_set: CPUFreq utility callback is set | ||
171 | * @pstate: Stores P state limits for this CPU | 172 | * @pstate: Stores P state limits for this CPU |
172 | * @vid: Stores VID limits for this CPU | 173 | * @vid: Stores VID limits for this CPU |
173 | * @pid: Stores PID parameters for this CPU | 174 | * @pid: Stores PID parameters for this CPU |
@@ -187,6 +188,7 @@ struct cpudata { | |||
187 | int cpu; | 188 | int cpu; |
188 | 189 | ||
189 | struct update_util_data update_util; | 190 | struct update_util_data update_util; |
191 | bool update_util_set; | ||
190 | 192 | ||
191 | struct pstate_data pstate; | 193 | struct pstate_data pstate; |
192 | struct vid_data vid; | 194 | struct vid_data vid; |
@@ -1417,11 +1419,18 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num) | |||
1417 | cpu->sample.time = 0; | 1419 | cpu->sample.time = 0; |
1418 | cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, | 1420 | cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, |
1419 | intel_pstate_update_util); | 1421 | intel_pstate_update_util); |
1422 | cpu->update_util_set = true; | ||
1420 | } | 1423 | } |
1421 | 1424 | ||
1422 | static void intel_pstate_clear_update_util_hook(unsigned int cpu) | 1425 | static void intel_pstate_clear_update_util_hook(unsigned int cpu) |
1423 | { | 1426 | { |
1427 | struct cpudata *cpu_data = all_cpu_data[cpu]; | ||
1428 | |||
1429 | if (!cpu_data->update_util_set) | ||
1430 | return; | ||
1431 | |||
1424 | cpufreq_remove_update_util_hook(cpu); | 1432 | cpufreq_remove_update_util_hook(cpu); |
1433 | cpu_data->update_util_set = false; | ||
1425 | synchronize_sched(); | 1434 | synchronize_sched(); |
1426 | } | 1435 | } |
1427 | 1436 | ||