Skip to content

Commit

Permalink
cpufreq: pcc: Fix the potentinal scheduling delays in target_index()
Browse files Browse the repository at this point in the history
pcc_cpufreq_target():
	cpufreq_freq_transition_begin();
	spin_lock(&pcc_lock);
	[critical section]
	cpufreq_freq_transition_end();
	spin_unlock(&pcc_lock);

Above code has a performance issue, consider that Task0 executes
'cpufreq_freq_transition_end()' to wake Task1 and preempted imediatedly
without releasing 'pcc_lock', then Task1 needs to wait for Task0 to
release 'pcc_lock'. In the worst case, this locking order can result in
Task1 wasting two scheduling rounds before it can enter the critical
section.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Liao Chang authored and Rafael J. Wysocki committed Aug 29, 2023
1 parent 916f138 commit 4c2fdf7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/cpufreq/pcc-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy,
status = ioread16(&pcch_hdr->status);
iowrite16(0, &pcch_hdr->status);

cpufreq_freq_transition_end(policy, &freqs, status != CMD_COMPLETE);
spin_unlock(&pcc_lock);
cpufreq_freq_transition_end(policy, &freqs, status != CMD_COMPLETE);

if (status != CMD_COMPLETE) {
pr_debug("target: FAILED for cpu %d, with status: 0x%x\n",
Expand Down

0 comments on commit 4c2fdf7

Please sign in to comment.