Skip to content

Commit 6ba6883

Browse files
Mikulas Patockahdeller
authored andcommitted
parisc: fix a crash with multicore scheduler
With the kernel 5.18, the system will hang on boot if it is compiled with CONFIG_SCHED_MC. The last printed message is "Brought up 1 node, 1 CPU". The crash happens in sd_init tl->mask (which is cpu_coregroup_mask) returns an empty mask. This happens because cpu_topology[0].core_sibling is empty. Consequently, sd_span is set to an empty mask sd_id = cpumask_first(sd_span) sets sd_id == NR_CPUS (because the mask is empty) sd->shared = *per_cpu_ptr(sdd->sds, sd_id); sets sd->shared to NULL because sd_id is out of range atomic_inc(&sd->shared->ref); crashes without printing anything We can fix it by calling reset_cpu_topology() from init_cpu_topology() - this will initialize the sibling masks on CPUs, so that they're not empty. This patch also removes the variable "dualcores_found", it is useless, because during boot, init_cpu_topology is called before store_cpu_topology. Thus, set_sched_topology(parisc_mc_topology) is never called. We don't need to call it at all because default_topology in kernel/sched/topology.c contains the same items as parisc_mc_topology. Note that we should not call store_cpu_topology() from init_per_cpu() because it is called too early in the kernel initialization process and it results in the message "Failure to register CPU0 device". Before this patch, store_cpu_topology() would exit immediatelly because cpuid_topo->core id was uninitialized and it was 0. Signed-off-by: Mikulas Patocka <[email protected]> Cc: [email protected] # v5.18 Signed-off-by: Helge Deller <[email protected]>
1 parent 4b0986a commit 6ba6883

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

arch/parisc/kernel/processor.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ int init_per_cpu(int cpunum)
327327
set_firmware_width();
328328
ret = pdc_coproc_cfg(&coproc_cfg);
329329

330-
store_cpu_topology(cpunum);
331-
332330
if(ret >= 0 && coproc_cfg.ccr_functional) {
333331
mtctl(coproc_cfg.ccr_functional, 10); /* 10 == Coprocessor Control Reg */
334332

arch/parisc/kernel/topology.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
static DEFINE_PER_CPU(struct cpu, cpu_devices);
2222

23-
static int dualcores_found;
24-
2523
/*
2624
* store_cpu_topology is called at boot when only one cpu is running
2725
* and with the mutex cpu_hotplug.lock locked, when several cpus have booted,
@@ -60,7 +58,6 @@ void store_cpu_topology(unsigned int cpuid)
6058
if (p->cpu_loc) {
6159
cpuid_topo->core_id++;
6260
cpuid_topo->package_id = cpu_topology[cpu].package_id;
63-
dualcores_found = 1;
6461
continue;
6562
}
6663
}
@@ -80,22 +77,11 @@ void store_cpu_topology(unsigned int cpuid)
8077
cpu_topology[cpuid].package_id);
8178
}
8279

83-
static struct sched_domain_topology_level parisc_mc_topology[] = {
84-
#ifdef CONFIG_SCHED_MC
85-
{ cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) },
86-
#endif
87-
88-
{ cpu_cpu_mask, SD_INIT_NAME(DIE) },
89-
{ NULL, },
90-
};
91-
9280
/*
9381
* init_cpu_topology is called at boot when only one cpu is running
9482
* which prevent simultaneous write access to cpu_topology array
9583
*/
9684
void __init init_cpu_topology(void)
9785
{
98-
/* Set scheduler topology descriptor */
99-
if (dualcores_found)
100-
set_sched_topology(parisc_mc_topology);
86+
reset_cpu_topology();
10187
}

0 commit comments

Comments
 (0)