Skip to contentSkip to conversation

sched/core: remove check of p->sched_class

PATCH In review Yao Dongdong 3 participants 3 messages Dec 29, 2014 – Jan 14, 2015 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: remove check of p->sched_class

Search all usage of p->sched_class in sched/core.c, no one check it before use, so it seems that every task must belong to one sched_class.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index b5797b7..bdab49b 100644
@@ -4740,7 +4740,7 @@ static struct rq *move_queued_task(struct task_struct *p, int new_cpu)
 
 void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
 {
-	if (p->sched_class && p->sched_class->set_cpus_allowed)
+	if (p->sched_class->set_cpus_allowed)
 		p->sched_class->set_cpus_allowed(p, new_mask);
 
 	cpumask_copy(&p->cpus_allowed, new_mask);
Signature · 1 line
2.1.0
maintainer
#1 lore raw
Quoted 3 lines · Yao Dongdong

Search all usage of p->sched_class in sched/core.c, no one check it before use, so it seems that every task must belong to one sched_class.

Thanks

#2 lore raw

[tip:sched/core] sched/core: Remove check of p->sched_class

In reply to Yao Dongdong
sched/core: Remove check of p->sched_class
Commit-ID:  1b537c7d1e58c761212a193085f9049b58f672e6
Gitweb:     http://git.kernel.org/tip/1b537c7d1e58c761212a193085f9049b58f672e6
Author:     Yao Dongdong <[email protected]>
AuthorDate: Mon, 29 Dec 2014 14:41:43 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jan 2015 13:34:17 +0100

sched/core: Remove check of p->sched_class

Search all usage of p->sched_class in sched/core.c, no one check it before use, so it seems that every task must belong to one sched_class.

[ Moved the early class assignment to make it boot. ]
Cc Linus Torvalds <[email protected]>
---
 kernel/sched/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/sched/core.c +6 -6
index 95ac795..46a2345 100644
@@ -4744,7 +4744,7 @@ static struct rq *move_queued_task(struct task_struct *p, int new_cpu)
 
 void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
 {
-	if (p->sched_class && p->sched_class->set_cpus_allowed)
+	if (p->sched_class->set_cpus_allowed)
 		p->sched_class->set_cpus_allowed(p, new_mask);
 
 	cpumask_copy(&p->cpus_allowed, new_mask);
@@ -7254,6 +7254,11 @@ 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
@@ -7263,11 +7268,6 @@ 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 */