Skip to content

Commit cff9b23

Browse files
howlettPeter Zijlstra
authored andcommitted
kernel/sched: Modify initial boot task idle setup
Initial booting is setting the task flag to idle (PF_IDLE) by the call path sched_init() -> init_idle(). Having the task idle and calling call_rcu() in kernel/rcu/tiny.c means that TIF_NEED_RESCHED will be set. Subsequent calls to any cond_resched() will enable IRQs, potentially earlier than the IRQ setup has completed. Recent changes have caused just this scenario and IRQs have been enabled early. This causes a warning later in start_kernel() as interrupts are enabled before they are fully set up. Fix this issue by setting the PF_IDLE flag later in the boot sequence. Although the boot task was marked as idle since (at least) d80e4fda576d, I am not sure that it is wrong to do so. The forced context-switch on idle task was introduced in the tiny_rcu update, so I'm going to claim this fixes 5f6130f. Fixes: 5f6130f ("tiny_rcu: Directly force QS when call_rcu_[bh|sched]() on idle_task") Signed-off-by: Liam R. Howlett <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/linux-mm/CAMuHMdWpvpWoDa=Ox-do92czYRvkok6_x6pYUH+ZouMcJbXy+Q@mail.gmail.com/
1 parent ce9ecca commit cff9b23

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9269,7 +9269,7 @@ void __init init_idle(struct task_struct *idle, int cpu)
92699269
* PF_KTHREAD should already be set at this point; regardless, make it
92709270
* look like a proper per-CPU kthread.
92719271
*/
9272-
idle->flags |= PF_IDLE | PF_KTHREAD | PF_NO_SETAFFINITY;
9272+
idle->flags |= PF_KTHREAD | PF_NO_SETAFFINITY;
92739273
kthread_set_per_cpu(idle, cpu);
92749274

92759275
#ifdef CONFIG_SMP

kernel/sched/idle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ EXPORT_SYMBOL_GPL(play_idle_precise);
373373

374374
void cpu_startup_entry(enum cpuhp_state state)
375375
{
376+
current->flags |= PF_IDLE;
376377
arch_cpu_idle_prepare();
377378
cpuhp_online_idle(state);
378379
while (1)

0 commit comments

Comments
 (0)