Skip to content

Commit a052096

Browse files
svens-s390hcahca
authored andcommitted
s390/topology: fix topology information when calling cpu hotplug notifiers
The cpu hotplug notifiers are called without updating the core/thread masks when a new CPU is added. This causes problems with code setting up data structures in a cpu hotplug notifier, and relying on that later in normal code. This caused a crash in the new core scheduling code (SCHED_CORE), where rq->core was set up in a notifier depending on cpu masks. To fix this, add a cpu_setup_mask which is used in update_cpu_masks() instead of the cpu_online_mask to determine whether the cpu masks should be set for a certain cpu. Also move update_cpu_masks() to update the masks before calling notify_cpu_starting() so that the notifiers are seeing the updated masks. Signed-off-by: Sven Schnelle <[email protected]> Cc: <[email protected]> [[email protected]: get rid of cpu_online_mask handling] Signed-off-by: Heiko Carstens <[email protected]>
1 parent 88b6042 commit a052096

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

arch/s390/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern struct mutex smp_cpu_state_mutex;
1818
extern unsigned int smp_cpu_mt_shift;
1919
extern unsigned int smp_cpu_mtid;
2020
extern __vector128 __initdata boot_cpu_vector_save_area[__NUM_VXRS];
21+
extern cpumask_t cpu_setup_mask;
2122

2223
extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
2324

arch/s390/kernel/smp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ __vector128 __initdata boot_cpu_vector_save_area[__NUM_VXRS];
9595
#endif
9696

9797
static unsigned int smp_max_threads __initdata = -1U;
98+
cpumask_t cpu_setup_mask;
9899

99100
static int __init early_nosmt(char *s)
100101
{
@@ -902,13 +903,14 @@ static void smp_start_secondary(void *cpuvoid)
902903
vtime_init();
903904
vdso_getcpu_init();
904905
pfault_init();
906+
cpumask_set_cpu(cpu, &cpu_setup_mask);
907+
update_cpu_masks();
905908
notify_cpu_starting(cpu);
906909
if (topology_cpu_dedicated(cpu))
907910
set_cpu_flag(CIF_DEDICATED_CPU);
908911
else
909912
clear_cpu_flag(CIF_DEDICATED_CPU);
910913
set_cpu_online(cpu, true);
911-
update_cpu_masks();
912914
inc_irq_stat(CPU_RST);
913915
local_irq_enable();
914916
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
@@ -950,10 +952,13 @@ early_param("possible_cpus", _setup_possible_cpus);
950952
int __cpu_disable(void)
951953
{
952954
unsigned long cregs[16];
955+
int cpu;
953956

954957
/* Handle possible pending IPIs */
955958
smp_handle_ext_call();
956-
set_cpu_online(smp_processor_id(), false);
959+
cpu = smp_processor_id();
960+
set_cpu_online(cpu, false);
961+
cpumask_clear_cpu(cpu, &cpu_setup_mask);
957962
update_cpu_masks();
958963
/* Disable pseudo page faults on this cpu. */
959964
pfault_fini();

arch/s390/kernel/topology.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int c
6767
static cpumask_t mask;
6868

6969
cpumask_clear(&mask);
70-
if (!cpu_online(cpu))
70+
if (!cpumask_test_cpu(cpu, &cpu_setup_mask))
7171
goto out;
7272
cpumask_set_cpu(cpu, &mask);
7373
switch (topology_mode) {
@@ -88,7 +88,7 @@ static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int c
8888
case TOPOLOGY_MODE_SINGLE:
8989
break;
9090
}
91-
cpumask_and(&mask, &mask, cpu_online_mask);
91+
cpumask_and(&mask, &mask, &cpu_setup_mask);
9292
out:
9393
cpumask_copy(dst, &mask);
9494
}
@@ -99,16 +99,16 @@ static void cpu_thread_map(cpumask_t *dst, unsigned int cpu)
9999
int i;
100100

101101
cpumask_clear(&mask);
102-
if (!cpu_online(cpu))
102+
if (!cpumask_test_cpu(cpu, &cpu_setup_mask))
103103
goto out;
104104
cpumask_set_cpu(cpu, &mask);
105105
if (topology_mode != TOPOLOGY_MODE_HW)
106106
goto out;
107107
cpu -= cpu % (smp_cpu_mtid + 1);
108-
for (i = 0; i <= smp_cpu_mtid; i++)
109-
if (cpu_present(cpu + i))
108+
for (i = 0; i <= smp_cpu_mtid; i++) {
109+
if (cpumask_test_cpu(cpu + i, &cpu_setup_mask))
110110
cpumask_set_cpu(cpu + i, &mask);
111-
cpumask_and(&mask, &mask, cpu_online_mask);
111+
}
112112
out:
113113
cpumask_copy(dst, &mask);
114114
}
@@ -569,6 +569,7 @@ void __init topology_init_early(void)
569569
alloc_masks(info, &book_info, 2);
570570
alloc_masks(info, &drawer_info, 3);
571571
out:
572+
cpumask_set_cpu(0, &cpu_setup_mask);
572573
__arch_update_cpu_topology();
573574
__arch_update_dedicated_flag(NULL);
574575
}

0 commit comments

Comments
 (0)