s390/topology: honour nr_cpu_ids when adding CPUs
[ Upstream commit a33239be2d
]
When SMT thread CPUs are added to CPU masks the nr_cpu_ids
limit is not checked and could be exceeded. This leads to
a warning for example if CONFIG_DEBUG_PER_CPU_MAPS is set
and the command line parameter nr_cpus is set to 1.
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
7980368542
Коммит
66f05cf2b2
|
@ -96,7 +96,7 @@ out:
|
|||
static void cpu_thread_map(cpumask_t *dst, unsigned int cpu)
|
||||
{
|
||||
static cpumask_t mask;
|
||||
int i;
|
||||
unsigned int max_cpu;
|
||||
|
||||
cpumask_clear(&mask);
|
||||
if (!cpumask_test_cpu(cpu, &cpu_setup_mask))
|
||||
|
@ -105,9 +105,10 @@ static void cpu_thread_map(cpumask_t *dst, unsigned int cpu)
|
|||
if (topology_mode != TOPOLOGY_MODE_HW)
|
||||
goto out;
|
||||
cpu -= cpu % (smp_cpu_mtid + 1);
|
||||
for (i = 0; i <= smp_cpu_mtid; i++) {
|
||||
if (cpumask_test_cpu(cpu + i, &cpu_setup_mask))
|
||||
cpumask_set_cpu(cpu + i, &mask);
|
||||
max_cpu = min(cpu + smp_cpu_mtid, nr_cpu_ids - 1);
|
||||
for (; cpu <= max_cpu; cpu++) {
|
||||
if (cpumask_test_cpu(cpu, &cpu_setup_mask))
|
||||
cpumask_set_cpu(cpu, &mask);
|
||||
}
|
||||
out:
|
||||
cpumask_copy(dst, &mask);
|
||||
|
@ -124,25 +125,26 @@ static void add_cpus_to_mask(struct topology_core *tl_core,
|
|||
unsigned int core;
|
||||
|
||||
for_each_set_bit(core, &tl_core->mask, TOPOLOGY_CORE_BITS) {
|
||||
unsigned int rcore;
|
||||
int lcpu, i;
|
||||
unsigned int max_cpu, rcore;
|
||||
int cpu;
|
||||
|
||||
rcore = TOPOLOGY_CORE_BITS - 1 - core + tl_core->origin;
|
||||
lcpu = smp_find_processor_id(rcore << smp_cpu_mt_shift);
|
||||
if (lcpu < 0)
|
||||
cpu = smp_find_processor_id(rcore << smp_cpu_mt_shift);
|
||||
if (cpu < 0)
|
||||
continue;
|
||||
for (i = 0; i <= smp_cpu_mtid; i++) {
|
||||
topo = &cpu_topology[lcpu + i];
|
||||
max_cpu = min(cpu + smp_cpu_mtid, nr_cpu_ids - 1);
|
||||
for (; cpu <= max_cpu; cpu++) {
|
||||
topo = &cpu_topology[cpu];
|
||||
topo->drawer_id = drawer->id;
|
||||
topo->book_id = book->id;
|
||||
topo->socket_id = socket->id;
|
||||
topo->core_id = rcore;
|
||||
topo->thread_id = lcpu + i;
|
||||
topo->thread_id = cpu;
|
||||
topo->dedicated = tl_core->d;
|
||||
cpumask_set_cpu(lcpu + i, &drawer->mask);
|
||||
cpumask_set_cpu(lcpu + i, &book->mask);
|
||||
cpumask_set_cpu(lcpu + i, &socket->mask);
|
||||
smp_cpu_set_polarization(lcpu + i, tl_core->pp);
|
||||
cpumask_set_cpu(cpu, &drawer->mask);
|
||||
cpumask_set_cpu(cpu, &book->mask);
|
||||
cpumask_set_cpu(cpu, &socket->mask);
|
||||
smp_cpu_set_polarization(cpu, tl_core->pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче