Between v4.14-rt and v5.10-rt, allocate_slab() is responsible for enabling IRQ before running the following SLAB allocation functions if system_state >= SYSTEM_SCHEDULING However, SYSTEM_SCHEDULING is introduced[1] in the mainline v4.13 and it's not reasonable to backport all related changes into older RT kernels from functional compatibility and longer term maintenance perspectives. Thus, as an alternative (but non-mainline) way, introduce an extra flag "system_scheduling" which becomes true at the same point as system_state = SYSTEM_SCHEDULING in the mainline, so that the existing system_states and users of them are not affected. allocate_slab() will use this flag for its IRQ control by the upcoming change. [1] https://lore.kernel.org/all/20170516184231.564888231@xxxxxxxxxxxxx/ Signed-off-by: Kazuhiro Hayashi <kazuhiro3.hayashi@xxxxxxxxxxxxx> Reviewed-by: Pavel Machek <pavel@xxxxxxx> --- include/linux/kernel.h | 1 + init/main.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d68f639f7330..2a15e829aaec 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -490,6 +490,7 @@ extern enum system_states { SYSTEM_RESTART, SYSTEM_SUSPEND, } system_state; +extern bool system_scheduling; #define TAINT_PROPRIETARY_MODULE 0 #define TAINT_FORCED_MODULE 1 diff --git a/init/main.c b/init/main.c index 9933fca3a5c8..4f382179b61e 100644 --- a/init/main.c +++ b/init/main.c @@ -110,6 +110,14 @@ bool early_boot_irqs_disabled __read_mostly; enum system_states system_state __read_mostly; EXPORT_SYMBOL(system_state); +/* + * This corresponds to system_state >= SYSTEM_SCHEDULING in the mainline. + * On PREEMPT_RT kernels, slab allocator requires this state to check if + * the allocation must be run with IRQ enabled or not. + */ +bool system_scheduling __read_mostly = false; +EXPORT_SYMBOL(system_scheduling); + /* * Boot command-line arguments */ @@ -401,6 +409,10 @@ static noinline void __init_refok rest_init(void) rcu_read_lock(); kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); rcu_read_unlock(); + + /* Corresponds to system_state = SYSTEM_SCHEDULING in the mainline */ + system_scheduling = true; + complete(&kthreadd_done); /* -- 2.30.2