s390: preempt: Fix preempt_count initialization
PATCH 1/1 s390: preempt: Fix preempt_count initialization
S390's init_idle_preempt_count(p, cpu) doesn't actually let us initialize the preempt_count of the requested CPU's idle task: it unconditionally writes to the current CPU's. This clearly conflicts with idle_threads_init(), which intends to initialize *all* the idle tasks, including their preempt_count (or their CPU's, if the arch uses a per-CPU preempt_count).
Unfortunately, it seems the way s390 does things doesn't let us initialize every possible CPU's preempt_count early on, as the pages where this resides are only allocated when a CPU is brought up and are freed when it is brought down.
Let the arch-specific code set a CPU's preempt_count when its lowcore is allocated, and turn init_idle_preempt_count() into an empty stub.
--- arch/s390/include/asm/preempt.h | 16 ++++------------ arch/s390/kernel/setup.c | 1 + arch/s390/kernel/smp.c | 1 + 3 files changed, 6 insertions(+), 12 deletions(-)
arch/s390/include/asm/preempt.h +4 -12
@@ -29,12 +29,6 @@ static inline void preempt_count_set(int pc) old, new) != old); } -#define init_task_preempt_count (p) do { } while (0) - -#define init_idle_preempt_count (p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_DISABLED; \ -} while (0) -static inline void set_preempt_need_resched (void ) {__atomic_and (~PREEMPT_NEED_RESCHED , &S390_lowcore.preempt_count);
@@ -88,12 +82,6 @@ static inline void preempt_count_set(int pc) S390_lowcore.preempt_count = pc; } -#define init_task_preempt_count (p) do { } while (0) - -#define init_idle_preempt_count (p, cpu) do { \ - S390_lowcore.preempt_count = PREEMPT_DISABLED; \ -} while (0) -static inline void set_preempt_need_resched (void ) { }
@@ -130,6 +118,10 @@ static inline bool should_resched(int preempt_offset)#endif /* CONFIG_HAVE_MARCH_Z196_FEATURES */ +#define init_task_preempt_count (p) do { } while (0) +/* Deferred to CPU bringup time */ +#define init_idle_preempt_count (p, cpu) do { } while (0) +#ifdef CONFIG_PREEMPTION extern void preempt_schedule (void );#define __preempt_schedule () preempt_schedule()
arch/s390/kernel/setup.c +1 -0
@@ -466,6 +466,7 @@ static void __init setup_lowcore_dat_off(void) lc->br_r1_trampoline =0x07f1 ;/* br %r1 */ lc->return_lpswe =gen_lpswe (__LC_RETURN_PSW); lc->return_mcck_lpswe =gen_lpswe (__LC_RETURN_MCCK_PSW); + lc->preempt_count =PREEMPT_DISABLED ;set_prefix ((u32 )(unsigned long ) lc); lowcore_ptr[0 ] = lc;
arch/s390/kernel/smp.c +1 -0
@@ -219,6 +219,7 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) lc->br_r1_trampoline =0x07f1 ;/* br %r1 */ lc->return_lpswe =gen_lpswe (__LC_RETURN_PSW); lc->return_mcck_lpswe =gen_lpswe (__LC_RETURN_MCCK_PSW); + lc->preempt_count =PREEMPT_DISABLED ;if (nmi_alloc_per_cpu (lc)) goto out_stack; lowcore_ptr[cpu] = lc;
Signature · 1 line
2.25.1
Quoted 14 lines · Valentin Schneider
S390's
init_idle_preempt_count(p, cpu)doesn't actually let us initialize thepreempt_countof the requested CPU's idle task: it unconditionally writes to the current CPU's. This clearly conflicts withidle_threads_init(), which intends to initialize *all* the idle tasks, including theirpreempt_count(or their CPU's, if the arch uses a per-CPUpreempt_count).Unfortunately, it seems the way s390 does things doesn't let us initialize every possible CPU's
preempt_countearly on, as the pages where this resides are only allocated when a CPU is brought up and are freed when it is brought down.Let the arch-specific code set a CPU's
preempt_countwhen its lowcore is allocated, and turninit_idle_preempt_count()into an empty stub.
Quoted 8 lines
Fixes f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")Reported-by Guenter Roeck <[email protected]>Signed-off-by Valentin Schneider <[email protected]>--- arch/s390/include/asm/preempt.h | 16 ++++------------ arch/s390/kernel/setup.c | 1 + arch/s390/kernel/smp.c | 1 + 3 files changed, 6 insertions(+), 12 deletions(-)
Vasily, can you pick this one up, please?
Vasily Gorbik
maintainerQuoted 24 lines · Heiko Carstens
Quoted 14 lines · Valentin Schneider
S390's
init_idle_preempt_count(p, cpu)doesn't actually let us initialize thepreempt_countof the requested CPU's idle task: it unconditionally writes to the current CPU's. This clearly conflicts withidle_threads_init(), which intends to initialize *all* the idle tasks, including theirpreempt_count(or their CPU's, if the arch uses a per-CPUpreempt_count).Unfortunately, it seems the way s390 does things doesn't let us initialize every possible CPU's
preempt_countearly on, as the pages where this resides are only allocated when a CPU is brought up and are freed when it is brought down.Let the arch-specific code set a CPU's
preempt_countwhen its lowcore is allocated, and turninit_idle_preempt_count()into an empty stub.Quoted 8 lines
Fixes f1a0a376ca0c ("sched/core: Initialize the idle task with preemption disabled")Reported-by Guenter Roeck <[email protected]>Signed-off-by Valentin Schneider <[email protected]>--- arch/s390/include/asm/preempt.h | 16 ++++------------ arch/s390/kernel/setup.c | 1 + arch/s390/kernel/smp.c | 1 + 3 files changed, 6 insertions(+), 12 deletions(-)
Quoted 3 lines
Reviewed-by Heiko Carstens <[email protected]>Vasily, can you pick this one up, please?
Will pick it up right away for rc1, thanks!