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

Commit 4bd4e428 authored by Stratos Karafotis's avatar Stratos Karafotis Committed by Rafael J. Wysocki
Browse files

cpufreq: ondemand: Replace down_differential tuner with adj_up_threshold



In order to avoid the calculation of up_threshold - down_differential
every time that the frequency must be decreased, we replace the
down_differential tuner with the adj_up_threshold which keeps the
difference across multiple checks.

Update the adj_up_threshold only when the up_theshold is also updated.

Signed-off-by: default avatarStratos Karafotis <stratosk@semaphore.gr>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent df18e504
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ struct od_dbs_tuners {
	unsigned int sampling_rate;
	unsigned int sampling_rate;
	unsigned int sampling_down_factor;
	unsigned int sampling_down_factor;
	unsigned int up_threshold;
	unsigned int up_threshold;
	unsigned int down_differential;
	unsigned int adj_up_threshold;
	unsigned int powersave_bias;
	unsigned int powersave_bias;
	unsigned int io_is_busy;
	unsigned int io_is_busy;
};
};
+10 −6
Original line number Original line Diff line number Diff line
@@ -47,7 +47,8 @@ static struct cpufreq_governor cpufreq_gov_ondemand;
static struct od_dbs_tuners od_tuners = {
static struct od_dbs_tuners od_tuners = {
	.up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
	.up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
	.sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
	.sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
	.down_differential = DEF_FREQUENCY_DOWN_DIFFERENTIAL,
	.adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD -
			    DEF_FREQUENCY_DOWN_DIFFERENTIAL,
	.ignore_nice = 0,
	.ignore_nice = 0,
	.powersave_bias = 0,
	.powersave_bias = 0,
};
};
@@ -192,11 +193,9 @@ static void od_check_cpu(int cpu, unsigned int load_freq)
	 * support the current CPU usage without triggering the up policy. To be
	 * support the current CPU usage without triggering the up policy. To be
	 * safe, we focus 10 points under the threshold.
	 * safe, we focus 10 points under the threshold.
	 */
	 */
	if (load_freq < (od_tuners.up_threshold - od_tuners.down_differential) *
	if (load_freq < od_tuners.adj_up_threshold * policy->cur) {
			policy->cur) {
		unsigned int freq_next;
		unsigned int freq_next;
		freq_next = load_freq / (od_tuners.up_threshold -
		freq_next = load_freq / od_tuners.adj_up_threshold;
				od_tuners.down_differential);


		/* No longer fully busy, reset rate_mult */
		/* No longer fully busy, reset rate_mult */
		dbs_info->rate_mult = 1;
		dbs_info->rate_mult = 1;
@@ -359,6 +358,10 @@ static ssize_t store_up_threshold(struct kobject *a, struct attribute *b,
			input < MIN_FREQUENCY_UP_THRESHOLD) {
			input < MIN_FREQUENCY_UP_THRESHOLD) {
		return -EINVAL;
		return -EINVAL;
	}
	}
	/* Calculate the new adj_up_threshold */
	od_tuners.adj_up_threshold += input;
	od_tuners.adj_up_threshold -= od_tuners.up_threshold;

	od_tuners.up_threshold = input;
	od_tuners.up_threshold = input;
	return count;
	return count;
}
}
@@ -515,7 +518,8 @@ static int __init cpufreq_gov_dbs_init(void)
	if (idle_time != -1ULL) {
	if (idle_time != -1ULL) {
		/* Idle micro accounting is supported. Use finer thresholds */
		/* Idle micro accounting is supported. Use finer thresholds */
		od_tuners.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
		od_tuners.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
		od_tuners.down_differential = MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
		od_tuners.adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD -
					     MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
		/*
		/*
		 * In nohz/micro accounting case we set the minimum frequency
		 * In nohz/micro accounting case we set the minimum frequency
		 * not depending on HZ, but fixed (very low). The deferred
		 * not depending on HZ, but fixed (very low). The deferred