Skip to content

Commit a3e5d10

Browse files
avaginIngo Molnar
authored and
Ingo Molnar
committed
sched: Don't call task_group() too many times in set_task_rq()
It improves perfomance, especially if autogroup is enabled. The size of set_task_rq() was 0x180 and now it is 0xa0. Signed-off-by: Andrew Vagin <[email protected]> Acked-by: Paul Turner <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f4d6f6c commit a3e5d10

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kernel/sched.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,14 +793,18 @@ static inline struct task_group *task_group(struct task_struct *p)
793793
/* Change a task's cfs_rq and parent entity if it moves across CPUs/groups */
794794
static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
795795
{
796+
#if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED)
797+
struct task_group *tg = task_group(p);
798+
#endif
799+
796800
#ifdef CONFIG_FAIR_GROUP_SCHED
797-
p->se.cfs_rq = task_group(p)->cfs_rq[cpu];
798-
p->se.parent = task_group(p)->se[cpu];
801+
p->se.cfs_rq = tg->cfs_rq[cpu];
802+
p->se.parent = tg->se[cpu];
799803
#endif
800804

801805
#ifdef CONFIG_RT_GROUP_SCHED
802-
p->rt.rt_rq = task_group(p)->rt_rq[cpu];
803-
p->rt.parent = task_group(p)->rt_se[cpu];
806+
p->rt.rt_rq = tg->rt_rq[cpu];
807+
p->rt.parent = tg->rt_se[cpu];
804808
#endif
805809
}
806810

0 commit comments

Comments
 (0)