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

Commit 5e900d48 authored by Juri Lelli's avatar Juri Lelli Committed by Dmitry Shmidt
Browse files

ANDROID: arm64: Cpu invariant scheduler load-tracking and capacity support



Provides the scheduler with a cpu scaling correction factor for more
accurate load-tracking and cpu capacity handling.

The Energy Model (EM) (in fact the capacity value of the last element
of the capacity states vector of the core (MC) level sched_group_energy
structure) is used as the source for this cpu scaling factor.

The cpu capacity value depends on the micro-architecture and the
maximum frequency of the cpu.

The maximum frequency part should not be confused with the frequency
invariant scheduler load-tracking support which deals with frequency
related scaling due to DFVS functionality.

Signed-off-by: default avatarJuri Lelli <juri.lelli@arm.com>
Signed-off-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: default avatarAndres Oportus <andresoportus@google.com>
parent b4ca4bcf
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -31,11 +31,13 @@ int pcibus_to_node(struct pci_bus *bus);
				 cpumask_of_node(pcibus_to_node(bus)))
				 cpumask_of_node(pcibus_to_node(bus)))


#endif /* CONFIG_NUMA */
#endif /* CONFIG_NUMA */
struct sched_domain;
#ifdef CONFIG_CPU_FREQ
#ifdef CONFIG_CPU_FREQ
#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
struct sched_domain;
extern unsigned long cpufreq_scale_freq_capacity(struct sched_domain *sd, int cpu);
extern unsigned long cpufreq_scale_freq_capacity(struct sched_domain *sd, int cpu);
#endif
#endif
#define arch_scale_cpu_capacity scale_cpu_capacity
extern unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu);


#include <asm-generic/topology.h>
#include <asm-generic/topology.h>


+42 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,18 @@
#include <asm/cputype.h>
#include <asm/cputype.h>
#include <asm/topology.h>
#include <asm/topology.h>


static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;

unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu)
{
	return per_cpu(cpu_scale, cpu);
}

static void set_capacity_scale(unsigned int cpu, unsigned long capacity)
{
	per_cpu(cpu_scale, cpu) = capacity;
}

static int __init get_cpu_for_node(struct device_node *node)
static int __init get_cpu_for_node(struct device_node *node)
{
{
	struct device_node *cpu_node;
	struct device_node *cpu_node;
@@ -211,6 +223,35 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
	return &cpu_topology[cpu].core_sibling;
	return &cpu_topology[cpu].core_sibling;
}
}


static inline int cpu_corepower_flags(void)
{
	return SD_SHARE_PKG_RESOURCES  | SD_SHARE_POWERDOMAIN | \
	       SD_SHARE_CAP_STATES;
}

static struct sched_domain_topology_level arm64_topology[] = {
#ifdef CONFIG_SCHED_MC
	{ cpu_coregroup_mask, cpu_corepower_flags, cpu_core_energy, SD_INIT_NAME(MC) },
#endif
	{ cpu_cpu_mask, NULL, cpu_cluster_energy, SD_INIT_NAME(DIE) },
	{ NULL, },
};

static void update_cpu_capacity(unsigned int cpu)
{
	unsigned long capacity = SCHED_CAPACITY_SCALE;

	if (cpu_core_energy(cpu)) {
		int max_cap_idx = cpu_core_energy(cpu)->nr_cap_states - 1;
		capacity = cpu_core_energy(cpu)->cap_states[max_cap_idx].cap;
	}

	set_capacity_scale(cpu, capacity);

	pr_info("CPU%d: update cpu_capacity %lu\n",
		cpu, arch_scale_cpu_capacity(NULL, cpu));
}

static void update_siblings_masks(unsigned int cpuid)
static void update_siblings_masks(unsigned int cpuid)
{
{
	struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
	struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
@@ -272,6 +313,7 @@ void store_cpu_topology(unsigned int cpuid)


topology_populated:
topology_populated:
	update_siblings_masks(cpuid);
	update_siblings_masks(cpuid);
	update_cpu_capacity(cpuid);
}
}


static void __init reset_cpu_topology(void)
static void __init reset_cpu_topology(void)