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

Commit 72395648 authored by Lingutla Chandrasekhar's avatar Lingutla Chandrasekhar
Browse files

sched: core: Fix usage of cpu core group mask



To find number of clusters, we depend on topology_core_cpumask(),
but that returns current online sibling cpus, if cluster have
offlined cpus, then finding no. of clusters could go wrong.

If system booted with less no. of cpus and others comes online after
bootup, then sched_up/down migrate setup breaks.

Fix this by using core's possible sibling mask.

While at it, refactor cpu possible siblings mask API to avoid other
architecture compilation errors.

Change-Id: I4543ad5b711181e60271fa887bb7d5855a55ba90
Signed-off-by: default avatarLingutla Chandrasekhar <clingutla@codeaurora.org>
parent adee9374
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -20,14 +20,11 @@ extern struct cputopo_arm cpu_topology[NR_CPUS];
#define topology_core_id(cpu)		(cpu_topology[cpu].core_id)
#define topology_core_cpumask(cpu)	(&cpu_topology[cpu].core_sibling)
#define topology_sibling_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
#define topology_possible_sibling_cpumask topology_core_cpumask

void init_cpu_topology(void);
void store_cpu_topology(unsigned int cpuid);
const struct cpumask *cpu_coregroup_mask(int cpu);
static inline const struct cpumask *cpu_possible_coregroup_mask(int cpu)
{
	return cpu_coregroup_mask(cpu);
}

#include <linux/arch_topology.h>

+2 −1
Original line number Diff line number Diff line
@@ -22,12 +22,13 @@ extern struct cpu_topology cpu_topology[NR_CPUS];
#define topology_core_cpumask(cpu)	(&cpu_topology[cpu].core_sibling)
#define topology_sibling_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
#define topology_llc_cpumask(cpu)	(&cpu_topology[cpu].llc_sibling)
#define topology_possible_sibling_cpumask(cpu)		\
				(&cpu_topology[cpu].core_possible_sibling)

void init_cpu_topology(void);
void store_cpu_topology(unsigned int cpuid);
void remove_cpu_topology(unsigned int cpuid);
const struct cpumask *cpu_coregroup_mask(int cpu);
const struct cpumask *cpu_possible_coregroup_mask(int cpu);

#ifdef CONFIG_NUMA

+0 −5
Original line number Diff line number Diff line
@@ -213,11 +213,6 @@ static int __init parse_dt_topology(void)
struct cpu_topology cpu_topology[NR_CPUS];
EXPORT_SYMBOL_GPL(cpu_topology);

const struct cpumask *cpu_possible_coregroup_mask(int cpu)
{
	return &cpu_topology[cpu].core_possible_sibling;
}

const struct cpumask *cpu_coregroup_mask(int cpu)
{
	const cpumask_t *core_mask = cpumask_of_node(cpu_to_node(cpu));
+3 −0
Original line number Diff line number Diff line
@@ -193,6 +193,9 @@ static inline int cpu_to_mem(int cpu)
#ifndef topology_core_cpumask
#define topology_core_cpumask(cpu)		cpumask_of(cpu)
#endif
#ifndef topology_possible_sibling_cpumask
#define topology_possible_sibling_cpumask(cpu)	cpumask_of(cpu)
#endif

#ifdef CONFIG_SCHED_SMT
static inline const struct cpumask *cpu_smt_mask(int cpu)
+3 −3
Original line number Diff line number Diff line
@@ -6824,7 +6824,7 @@ static int find_capacity_margin_levels(void)
	int cpu, max_clusters;

	for (cpu = max_clusters = 0; cpu < num_possible_cpus();) {
		cpu += cpumask_weight(topology_core_cpumask(cpu));
		cpu += cpumask_weight(topology_possible_sibling_cpumask(cpu));
		max_clusters++;
	}

@@ -6886,8 +6886,8 @@ static void sched_update_updown_migrate_values(unsigned int *data,

	for (i = cpu = 0; (!cluster_cpus[i]) &&
				cpu < num_possible_cpus(); i++) {
		cluster_cpus[i] = topology_core_cpumask(cpu);
		cpu += cpumask_weight(topology_core_cpumask(cpu));
		cluster_cpus[i] = topology_possible_sibling_cpumask(cpu);
		cpu += cpumask_weight(topology_possible_sibling_cpumask(cpu));
	}

	if (data == &sysctl_sched_capacity_margin_up[0])
Loading