Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7493065a authored by Saravana Kannan's avatar Saravana Kannan
Browse files

cpufreq: schedutil: Fix race condition in computing hispeed_util



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: default avatarSaravana Kannan <skannan@codeaurora.org>
parent 36faa288
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;