Commit 8e7ff35f authored by Morten Rasmussen's avatar Morten Rasmussen Committed by Morten Rasmussen
Browse files

arm: Frequency invariant scheduler load-tracking support



Implements arch-specific function to provide the scheduler with a
frequency scaling correction factor for more accurate load-tracking. The
factor is:

	current_freq(cpu) * SCHED_CAPACITY_SCALE / max_freq(cpu)

This implementation only provides frequency invariance. No
micro-architecture invariance yet.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Morten Rasmussen's avatarMorten Rasmussen <morten.rasmussen@arm.com>
parent 59b95da9
......@@ -24,6 +24,10 @@ void init_cpu_topology(void);
void store_cpu_topology(unsigned int cpuid);
const struct cpumask *cpu_coregroup_mask(int cpu);
#define arch_scale_freq_capacity arm_arch_scale_freq_capacity
struct sched_domain;
extern unsigned long arm_arch_scale_freq_capacity(struct sched_domain *sd, int cpu);
#else
static inline void init_cpu_topology(void) { }
......
......@@ -169,6 +169,47 @@ static void update_cpu_capacity(unsigned int cpu)
cpu, arch_scale_cpu_capacity(NULL, cpu));
}
/*
* Scheduler load-tracking scale-invariance
*
* Provides the scheduler with a scale-invariance correction factor that
* compensates for frequency scaling.
*/
static DEFINE_PER_CPU(atomic_long_t, cpu_freq_capacity);
static DEFINE_PER_CPU(atomic_long_t, cpu_max_freq);
/* cpufreq callback function setting current cpu frequency */
void arch_scale_set_curr_freq(int cpu, unsigned long freq)
{
unsigned long max = atomic_long_read(&per_cpu(cpu_max_freq, cpu));
unsigned long curr;
if (!max)
return;
curr = (freq * SCHED_CAPACITY_SCALE) / max;
atomic_long_set(&per_cpu(cpu_freq_capacity, cpu), curr);
}
/* cpufreq callback function setting max cpu frequency */
void arch_scale_set_max_freq(int cpu, unsigned long freq)
{
atomic_long_set(&per_cpu(cpu_max_freq, cpu), freq);
}
/* arch_scale_freq_capacity() implementation called from scheduler */
unsigned long arm_arch_scale_freq_capacity(struct sched_domain *sd, int cpu)
{
unsigned long curr = atomic_long_read(&per_cpu(cpu_freq_capacity, cpu));
if (!curr)
return SCHED_CAPACITY_SCALE;
return curr;
}
#else
static inline void parse_dt_topology(void) {}
static inline void update_cpu_capacity(unsigned int cpuid) {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment