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

Commit 53994155 authored by Junjie Wu's avatar Junjie Wu
Browse files

cpufreq: interactive: Cache tunables when they are created



Currently, tunables are only saved to per_cpu field when
CPUFREQ_GOV_POLICY_EXIT event happens. Save tunables the moment they
are created so that per_cpu cached_tunables field always matches
the tunables in use. This is useful for modifying tunable values
across clusters.

Change-Id: I9e30d5e93d6fde1282b5450458d8a605d568a0f5
Signed-off-by: default avatarJunjie Wu <junjiew@codeaurora.org>
parent 1045189e
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -1140,6 +1140,22 @@ static struct notifier_block cpufreq_interactive_idle_nb = {
	.notifier_call = cpufreq_interactive_idle_notifier,
};

static void save_tunables(struct cpufreq_policy *policy,
			  struct cpufreq_interactive_tunables *tunables)
{
	int cpu;
	struct cpufreq_interactive_cpuinfo *pcpu;

	if (have_governor_per_policy())
		cpu = cpumask_first(policy->related_cpus);
	else
		cpu = 0;

	pcpu = &per_cpu(cpuinfo, cpu);
	WARN_ON(pcpu->cached_tunables && pcpu->cached_tunables != tunables);
	pcpu->cached_tunables = tunables;
}

static struct cpufreq_interactive_tunables *alloc_tunable(
					struct cpufreq_policy *policy)
{
@@ -1165,25 +1181,10 @@ static struct cpufreq_interactive_tunables *alloc_tunable(
	spin_lock_init(&tunables->target_loads_lock);
	spin_lock_init(&tunables->above_hispeed_delay_lock);

	save_tunables(policy, tunables);
	return tunables;
}

static void save_tunables(struct cpufreq_policy *policy,
			  struct cpufreq_interactive_tunables *tunables)
{
	int cpu;
	struct cpufreq_interactive_cpuinfo *pcpu;

	if (have_governor_per_policy())
		cpu = cpumask_first(policy->related_cpus);
	else
		cpu = 0;

	pcpu = &per_cpu(cpuinfo, cpu);
	WARN_ON(pcpu->cached_tunables && pcpu->cached_tunables != tunables);
	pcpu->cached_tunables = tunables;
}

static struct cpufreq_interactive_tunables *restore_tunables(
						struct cpufreq_policy *policy)
{
@@ -1270,7 +1271,6 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
					get_sysfs_attr());
			if (!have_governor_per_policy())
				cpufreq_put_global_kobject();
			save_tunables(policy, tunables);
			common_tunables = NULL;
		}