Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
cpufreq: schedutil: Fix race condition in computing hispeed_util
Browse files Browse the repository at this point in the history
hispeed_util can be changed in the context of the store function and
scheduler notifications. So, we need to grab the update_lock (used to
protect members of sg_policy) before changing it to avoid any race
conditions.

Change-Id: I0c6336bab0ec265d900d2e16df1fe95824d7b2e8
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
  • Loading branch information
Saravana Kannan committed Jul 7, 2017
1 parent 36faa28 commit 7493065
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/sched/cpufreq_schedutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,12 @@ static ssize_t hispeed_freq_store(struct gov_attr_set *attr_set,

tunables->hispeed_freq = val;
list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook) {
raw_spin_lock(&sg_policy->update_lock);
hs_util = freq_to_util(sg_policy,
sg_policy->tunables->hispeed_freq);
hs_util = mult_frac(hs_util, TARGET_LOAD, 100);
sg_policy->hispeed_util = hs_util;
raw_spin_unlock(&sg_policy->update_lock);
}

return count;
Expand Down

0 comments on commit 7493065

Please sign in to comment.