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

Commit 86916de3 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

sched/cpufreq_schedutil: create a function for common steps



There are many callsites that do exactly same steps as

hs_util = freq_to_util(sg_policy,
		sg_policy->tunables->hispeed_freq);
hs_util = mult_frac(hs_util, TARGET_LOAD, 100);

Capture them in a function and change all callsites to use it.

Change-Id: Ie7138de7942c51027309101eb6429208a711da74
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent c5d09a49
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -607,6 +607,16 @@ static inline void ignore_dl_rate_limit(struct sugov_cpu *sg_cpu, struct sugov_p
		sg_policy->need_freq_update = true;
}

static inline unsigned long target_util(struct sugov_policy *sg_policy,
				  unsigned int freq)
{
	unsigned long util;

	util = freq_to_util(sg_policy, freq);
	util = mult_frac(util, TARGET_LOAD, 100);
	return util;
}

static void sugov_update_single(struct update_util_data *hook, u64 time,
				unsigned int flags)
{
@@ -635,14 +645,12 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

	if (sg_policy->max != max) {
		sg_policy->max = max;
		hs_util = freq_to_util(sg_policy,
		hs_util = target_util(sg_policy,
				       sg_policy->tunables->hispeed_freq);
		hs_util = mult_frac(hs_util, TARGET_LOAD, 100);
		sg_policy->hispeed_util = hs_util;

		boost_util = freq_to_util(sg_policy,
		boost_util = target_util(sg_policy,
				    sg_policy->tunables->rtg_boost_freq);
		boost_util = mult_frac(boost_util, TARGET_LOAD, 100);
		sg_policy->rtg_boost_util = boost_util;
	}

@@ -748,14 +756,12 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags)

	if (sg_policy->max != sg_cpu->max) {
		sg_policy->max = sg_cpu->max;
		hs_util = freq_to_util(sg_policy,
		hs_util = target_util(sg_policy,
					sg_policy->tunables->hispeed_freq);
		hs_util = mult_frac(hs_util, TARGET_LOAD, 100);
		sg_policy->hispeed_util = hs_util;

		boost_util = freq_to_util(sg_policy,
		boost_util = target_util(sg_policy,
				    sg_policy->tunables->rtg_boost_freq);
		boost_util = mult_frac(boost_util, TARGET_LOAD, 100);
		sg_policy->rtg_boost_util = boost_util;
	}

@@ -941,9 +947,8 @@ 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_irqsave(&sg_policy->update_lock, flags);
		hs_util = freq_to_util(sg_policy,
		hs_util = target_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_irqrestore(&sg_policy->update_lock, flags);
	}
@@ -973,9 +978,8 @@ static ssize_t rtg_boost_freq_store(struct gov_attr_set *attr_set,
	tunables->rtg_boost_freq = val;
	list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook) {
		raw_spin_lock_irqsave(&sg_policy->update_lock, flags);
		boost_util = freq_to_util(sg_policy,
		boost_util = target_util(sg_policy,
					  sg_policy->tunables->rtg_boost_freq);
		boost_util = mult_frac(boost_util, TARGET_LOAD, 100);
		sg_policy->rtg_boost_util = boost_util;
		raw_spin_unlock_irqrestore(&sg_policy->update_lock, flags);
	}
@@ -1220,8 +1224,7 @@ static int sugov_init(struct cpufreq_policy *policy)
	policy->governor_data = sg_policy;
	sg_policy->tunables = tunables;

	util = freq_to_util(sg_policy, sg_policy->tunables->rtg_boost_freq);
	util = mult_frac(util, TARGET_LOAD, 100);
	util = target_util(sg_policy, sg_policy->tunables->rtg_boost_freq);
	sg_policy->rtg_boost_util = util;

	stale_ns = sched_ravg_window + (sched_ravg_window >> 3);