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

Commit 912b94f9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "cpufreq: interactive: Modifying sync_freq implementation"

parents 93e3cc29 878010b9
Loading
Loading
Loading
Loading
+63 −31
Original line number Diff line number Diff line
@@ -125,11 +125,14 @@ static int timer_slack_val = DEFAULT_TIMER_SLACK;
static bool io_is_busy;

/*
 * If the max load among the other CPUs is higher than sync_freq_load_threshold
 * then do not let the frequency to drop below sync_freq
 * If the max load among other CPUs is higher than up_threshold_any_cpu_load
 * and if the highest frequency among the other CPUs is higher than
 * up_threshold_any_cpu_freq then do not let the frequency to drop below
 * sync_freq
 */
static unsigned int sync_freq_load_threshold;
static unsigned int up_threshold_any_cpu_load;
static unsigned int sync_freq;
static unsigned int up_threshold_any_cpu_freq;

static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
		unsigned int event);
@@ -359,8 +362,9 @@ static void cpufreq_interactive_timer(unsigned long data)
	unsigned long flags;
	bool boosted;
	unsigned long mod_min_sample_time;
	int i, max_load_other_cpu;
	unsigned int max_freq_other_cpu;
	int i, max_load;
	unsigned int max_freq;
	struct cpufreq_interactive_cpuinfo *picpu;

	if (!down_read_trylock(&pcpu->enable_sem))
		return;
@@ -382,20 +386,6 @@ static void cpufreq_interactive_timer(unsigned long data)
	pcpu->prev_load = cpu_load;
	boosted = boost_val || now < boostpulse_endtime;

	max_load_other_cpu = 0;
	max_freq_other_cpu = 0;
	for_each_online_cpu(i) {
		struct cpufreq_interactive_cpuinfo *picpu =
						&per_cpu(cpuinfo, i);
		if (i == data)
			continue;
		if (max_load_other_cpu < picpu->prev_load)
			max_load_other_cpu = picpu->prev_load;

		if (picpu->target_freq > max_freq_other_cpu)
			max_freq_other_cpu = picpu->target_freq;
	}

	if (cpu_load >= go_hispeed_load || boosted) {
		if (pcpu->target_freq < hispeed_freq) {
			new_freq = hispeed_freq;
@@ -407,11 +397,28 @@ static void cpufreq_interactive_timer(unsigned long data)
		}
	} else {
		new_freq = choose_freq(pcpu, loadadjfreq);
		if (sync_freq && (max_freq_other_cpu > sync_freq) &&
			(max_load_other_cpu > sync_freq_load_threshold) &&
				(new_freq < sync_freq))

		if (sync_freq && new_freq < sync_freq) {

			max_load = 0;
			max_freq = 0;

			for_each_online_cpu(i) {
				picpu = &per_cpu(cpuinfo, i);

				if (i == data || picpu->prev_load <
						up_threshold_any_cpu_load)
					continue;

				max_load = max(max_load, picpu->prev_load);
				max_freq = max(max_freq, picpu->target_freq);
			}

			if (max_freq > up_threshold_any_cpu_freq &&
				max_load >= up_threshold_any_cpu_load)
				new_freq = sync_freq;
		}
	}

	if (pcpu->target_freq >= hispeed_freq &&
	    new_freq > pcpu->target_freq &&
@@ -1086,13 +1093,13 @@ static ssize_t store_sync_freq(struct kobject *kobj,
static struct global_attr sync_freq_attr = __ATTR(sync_freq, 0644,
		show_sync_freq, store_sync_freq);

static ssize_t show_sync_freq_load_threshold(struct kobject *kobj,
static ssize_t show_up_threshold_any_cpu_load(struct kobject *kobj,
			struct attribute *attr, char *buf)
{
	return sprintf(buf, "%u\n", sync_freq_load_threshold);
	return snprintf(buf, PAGE_SIZE, "%u\n", up_threshold_any_cpu_load);
}

static ssize_t store_sync_freq_load_threshold(struct kobject *kobj,
static ssize_t store_up_threshold_any_cpu_load(struct kobject *kobj,
			struct attribute *attr, const char *buf, size_t count)
{
	int ret;
@@ -1101,14 +1108,38 @@ static ssize_t store_sync_freq_load_threshold(struct kobject *kobj,
	ret = kstrtoul(buf, 0, &val);
	if (ret < 0)
		return ret;
	sync_freq_load_threshold = val;
	up_threshold_any_cpu_load = val;
	return count;
}

static struct global_attr sync_freq_load_threshold_attr =
		__ATTR(sync_freq_load_threshold, 0644,
		show_sync_freq_load_threshold, store_sync_freq_load_threshold);
static struct global_attr up_threshold_any_cpu_load_attr =
		__ATTR(up_threshold_any_cpu_load, 0644,
		show_up_threshold_any_cpu_load,
				store_up_threshold_any_cpu_load);

static ssize_t show_up_threshold_any_cpu_freq(struct kobject *kobj,
			struct attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%u\n", up_threshold_any_cpu_freq);
}

static ssize_t store_up_threshold_any_cpu_freq(struct kobject *kobj,
			struct attribute *attr, const char *buf, size_t count)
{
	int ret;
	unsigned long val;

	ret = kstrtoul(buf, 0, &val);
	if (ret < 0)
		return ret;
	up_threshold_any_cpu_freq = val;
	return count;
}

static struct global_attr up_threshold_any_cpu_freq_attr =
		__ATTR(up_threshold_any_cpu_freq, 0644,
		show_up_threshold_any_cpu_freq,
				store_up_threshold_any_cpu_freq);

static struct attribute *interactive_attributes[] = {
	&target_loads_attr.attr,
@@ -1124,7 +1155,8 @@ static struct attribute *interactive_attributes[] = {
	&io_is_busy_attr.attr,
	&sampling_down_factor_attr.attr,
	&sync_freq_attr.attr,
	&sync_freq_load_threshold_attr.attr,
	&up_threshold_any_cpu_load_attr.attr,
	&up_threshold_any_cpu_freq_attr.attr,
	NULL,
};