Skip to contentSkip to conversation

sched/core: really pretend early bootup to be a normal task

PATCH In review Konstantin Khlebnikov 2 participants 3 messages Jul 5, 2016 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: really pretend early bootup to be a normal task

Commit 1b537c7d1e58 ("sched/core: Remove check of p->sched_class") placed "current->sched_class = &fair_sched_class" before call of init_idle() which immediately set sched_class back to idle_sched_class.

This patch reverts this piece because after commit de9b8f5dcbd9 ("sched:
Fix crash trying to dequeue/enqueue the idle thread") init_idle() doesn't call do_set_cpus_allowed() and nobody will dereference ->sched_class.

[ Probably this pretending is no longer required and could be removed,
or maybe it helps in catching bugs like sleeping during early bootup? ]

Fixes 1b537c7d1e58 ("sched/core: Remove check of p->sched_class")
Cc Yao Dongdong <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Sasha Levin <[email protected]>
---
 kernel/sched/core.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/sched/core.c +5 -5
index 51d7105f529a..c23aee77d10d 100644
@@ -7481,11 +7481,6 @@ void __init sched_init(void)
 	enter_lazy_tlb(&init_mm, current);
 
 	/*
-	 * During early bootup we pretend to be a normal task:
-	 */
-	current->sched_class = &fair_sched_class;
-
-	/*
 	 * Make us the idle thread. Technically, schedule() should not be
 	 * called from this thread, however somewhere below it might be,
 	 * but because we are the idle thread, we just pick up running again
@@ -7495,6 +7490,11 @@ void __init sched_init(void)
 
 	calc_load_update = jiffies + LOAD_FREQ;
 
+	/*
+	 * During early bootup we pretend to be a normal task:
+	 */
+	current->sched_class = &fair_sched_class;
+
 #ifdef CONFIG_SMP
 	zalloc_cpumask_var(&sched_domains_tmpmask, GFP_NOWAIT);
 	/* May be allocated at isolcpus cmdline parse time */
maintainer
#1 lore raw
Quoted 7 lines · Konstantin Khlebnikov

Commit 1b537c7d1e58 ("sched/core: Remove check of p->sched_class") placed "current->sched_class = &fair_sched_class" before call of init_idle() which immediately set sched_class back to idle_sched_class.

This patch reverts this piece because after commit de9b8f5dcbd9 ("sched:
Fix crash trying to dequeue/enqueue the idle thread") init_idle() doesn't call do_set_cpus_allowed() and nobody will dereference ->sched_class.

I don't understand, what is broken?

#2 lore raw
Quoted 11 lines · Peter Zijlstra
Quoted 7 lines · Konstantin Khlebnikov

Commit 1b537c7d1e58 ("sched/core: Remove check of p->sched_class") placed "current->sched_class = &fair_sched_class" before call of init_idle() which immediately set sched_class back to idle_sched_class.

This patch reverts this piece because after commit de9b8f5dcbd9 ("sched:
Fix crash trying to dequeue/enqueue the idle thread") init_idle() doesn't call do_set_cpus_allowed() and nobody will dereference ->sched_class.

I don't understand, what is broken?

"pretending" hack is broken. As I wrote maybe it is not needed any more.

Signature · 1 line
Konstantin