* [PATCH 0/2] sched: make the scheduler (even) more modular @ 2009-04-07 13:36 Henrik Austad 2009-04-07 13:36 ` [PATCH 1/2] sched: Move priority calculation into sched_class Henrik Austad 2009-04-07 16:47 ` [PATCH 0/2] sched: make the scheduler (even) more modular Américo Wang 0 siblings, 2 replies; 4+ messages in thread From: Henrik Austad @ 2009-04-07 13:36 UTC (permalink / raw) To: Ingo Molnar; +Cc: LKML, Peter Ziljstra Several of the functions in the core scheduler tests explicitly for class and then to class-specific operations. This should be handled by the sched_class interface. This patch-series moves 2 such elements over to sched_entity, or more precisely, the priority part. Ingo, Peter: I forgot to CC lkml the last time around, sorry about this resend. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] sched: Move priority calculation into sched_class. 2009-04-07 13:36 [PATCH 0/2] sched: make the scheduler (even) more modular Henrik Austad @ 2009-04-07 13:36 ` Henrik Austad 2009-04-07 13:36 ` [PATCH 2/2] sched: Let sched_class handle effective_prio calculation Henrik Austad 2009-04-07 16:47 ` [PATCH 0/2] sched: make the scheduler (even) more modular Américo Wang 1 sibling, 1 reply; 4+ messages in thread From: Henrik Austad @ 2009-04-07 13:36 UTC (permalink / raw) To: Ingo Molnar; +Cc: LKML, Peter Ziljstra, Henrik Austad When calculating the normal priority of a task, sched.c tested to see if the task was an RT-task, before doing scheduling-class specific operations. By moving this into sched_class, the calculation becomes more modular, and the core scheduler becomes less aware of sched-class' internals. Signed-off-by: Henrik Austad <henrik@austad.us> Acked-by: Peter Zijlstra <peterz@infradead.org> --- include/linux/sched.h | 1 + kernel/sched.c | 16 +--------------- kernel/sched_fair.c | 7 +++++++ kernel/sched_idletask.c | 6 ++++++ kernel/sched_rt.c | 6 ++++++ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index b94f354..6dc6591 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1014,6 +1014,7 @@ struct sched_class { int running); void (*prio_changed) (struct rq *this_rq, struct task_struct *task, int oldprio, int running); + int (*normal_prio) (struct task_struct *task); #ifdef CONFIG_FAIR_GROUP_SCHED void (*moved_group) (struct task_struct *p); diff --git a/kernel/sched.c b/kernel/sched.c index 6cc1fd5..da13af5 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1794,14 +1794,6 @@ static void dequeue_task(struct rq *rq, struct task_struct *p, int sleep) } /* - * __normal_prio - return the priority that is based on the static prio - */ -static inline int __normal_prio(struct task_struct *p) -{ - return p->static_prio; -} - -/* * Calculate the expected normal priority: i.e. priority * without taking RT-inheritance into account. Might be * boosted by interactivity modifiers. Changes upon fork, @@ -1810,13 +1802,7 @@ static inline int __normal_prio(struct task_struct *p) */ static inline int normal_prio(struct task_struct *p) { - int prio; - - if (task_has_rt_policy(p)) - prio = MAX_RT_PRIO-1 - p->rt_priority; - else - prio = __normal_prio(p); - return prio; + return p->sched_class->normal_prio(p); } /* diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 3816f21..c94519a 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -1749,6 +1749,12 @@ static void prio_changed_fair(struct rq *rq, struct task_struct *p, check_preempt_curr(rq, p, 0); } +/* Return the expected, normal priority */ +static int normal_prio_fair(struct task_struct *p) +{ + return p->static_prio; +} + /* * We switched to the sched_fair class. */ @@ -1815,6 +1821,7 @@ static const struct sched_class fair_sched_class = { .task_new = task_new_fair, .prio_changed = prio_changed_fair, + .normal_prio = normal_prio_fair, .switched_to = switched_to_fair, #ifdef CONFIG_FAIR_GROUP_SCHED diff --git a/kernel/sched_idletask.c b/kernel/sched_idletask.c index 8a21a2e..e52ae7c 100644 --- a/kernel/sched_idletask.c +++ b/kernel/sched_idletask.c @@ -96,6 +96,11 @@ static void prio_changed_idle(struct rq *rq, struct task_struct *p, check_preempt_curr(rq, p, 0); } +static int normal_prio_idle(struct task_struct *p) +{ + return p->static_prio; +} + /* * Simple, special scheduling class for the per-CPU idle tasks: */ @@ -122,6 +127,7 @@ static const struct sched_class idle_sched_class = { .task_tick = task_tick_idle, .prio_changed = prio_changed_idle, + .normal_prio = normal_prio_idle, .switched_to = switched_to_idle, /* no .task_new for idle tasks */ diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 299d012..ec966b7 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c @@ -1671,6 +1671,11 @@ static void prio_changed_rt(struct rq *rq, struct task_struct *p, } } +static int normal_prio_rt(struct task_struct *p) +{ + return MAX_RT_PRIO-1 - p->rt_priority; +} + static void watchdog(struct rq *rq, struct task_struct *p) { unsigned long soft, hard; @@ -1759,6 +1764,7 @@ static const struct sched_class rt_sched_class = { .task_tick = task_tick_rt, .prio_changed = prio_changed_rt, + .normal_prio = normal_prio_rt, .switched_to = switched_to_rt, }; -- 1.6.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] sched: Let sched_class handle effective_prio calculation 2009-04-07 13:36 ` [PATCH 1/2] sched: Move priority calculation into sched_class Henrik Austad @ 2009-04-07 13:36 ` Henrik Austad 0 siblings, 0 replies; 4+ messages in thread From: Henrik Austad @ 2009-04-07 13:36 UTC (permalink / raw) To: Ingo Molnar; +Cc: LKML, Peter Ziljstra, Henrik Austad Instead of testing for sched_class in the core scheduler, the calculation of the class-specific effective priority should be handled by the scheduling class. Signed-off-by: Henrik Austad <henrik@austad.us> Acked-by: Peter Zijlstra <peterz@infradead.org> --- include/linux/sched.h | 1 + kernel/sched.c | 11 +++-------- kernel/sched_fair.c | 1 + kernel/sched_idletask.c | 1 + kernel/sched_rt.c | 6 ++++++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 6dc6591..c98e912 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1015,6 +1015,7 @@ struct sched_class { void (*prio_changed) (struct rq *this_rq, struct task_struct *task, int oldprio, int running); int (*normal_prio) (struct task_struct *task); + int (*effective_prio) (struct task_struct *task); #ifdef CONFIG_FAIR_GROUP_SCHED void (*moved_group) (struct task_struct *p); diff --git a/kernel/sched.c b/kernel/sched.c index da13af5..5a6d4bd 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1814,15 +1814,10 @@ static inline int normal_prio(struct task_struct *p) */ static int effective_prio(struct task_struct *p) { + /* update normal prio */ p->normal_prio = normal_prio(p); - /* - * If we are RT tasks or we were boosted to RT priority, - * keep the priority unchanged. Otherwise, update priority - * to the normal priority: - */ - if (!rt_prio(p->prio)) - return p->normal_prio; - return p->prio; + + return p->sched_class->effective_prio(p); } /* diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index c94519a..42af406 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -1822,6 +1822,7 @@ static const struct sched_class fair_sched_class = { .prio_changed = prio_changed_fair, .normal_prio = normal_prio_fair, + .effective_prio = normal_prio_fair, .switched_to = switched_to_fair, #ifdef CONFIG_FAIR_GROUP_SCHED diff --git a/kernel/sched_idletask.c b/kernel/sched_idletask.c index e52ae7c..675de4e 100644 --- a/kernel/sched_idletask.c +++ b/kernel/sched_idletask.c @@ -128,6 +128,7 @@ static const struct sched_class idle_sched_class = { .prio_changed = prio_changed_idle, .normal_prio = normal_prio_idle, + .effective_prio = normal_prio_idle, .switched_to = switched_to_idle, /* no .task_new for idle tasks */ diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index ec966b7..6426ced 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c @@ -1676,6 +1676,11 @@ static int normal_prio_rt(struct task_struct *p) return MAX_RT_PRIO-1 - p->rt_priority; } +static int effective_prio_rt(struct task_struct *p) +{ + return p->prio; +} + static void watchdog(struct rq *rq, struct task_struct *p) { unsigned long soft, hard; @@ -1765,6 +1770,7 @@ static const struct sched_class rt_sched_class = { .prio_changed = prio_changed_rt, .normal_prio = normal_prio_rt, + .effective_prio = effective_prio_rt, .switched_to = switched_to_rt, }; -- 1.6.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] sched: make the scheduler (even) more modular 2009-04-07 13:36 [PATCH 0/2] sched: make the scheduler (even) more modular Henrik Austad 2009-04-07 13:36 ` [PATCH 1/2] sched: Move priority calculation into sched_class Henrik Austad @ 2009-04-07 16:47 ` Américo Wang 1 sibling, 0 replies; 4+ messages in thread From: Américo Wang @ 2009-04-07 16:47 UTC (permalink / raw) To: Henrik Austad; +Cc: Ingo Molnar, LKML, Peter Ziljstra On Tue, Apr 07, 2009 at 03:36:11PM +0200, Henrik Austad wrote: >Several of the functions in the core scheduler tests explicitly for class and >then to class-specific operations. This should be handled by the sched_class >interface. > >This patch-series moves 2 such elements over to sched_entity, or more precisely, >the priority part. > >Ingo, Peter: I forgot to CC lkml the last time around, sorry about this resend. > I like these two patches! Really nice! You can add my reviewed-by if you need: Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com> Thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-07 16:46 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-07 13:36 [PATCH 0/2] sched: make the scheduler (even) more modular Henrik Austad 2009-04-07 13:36 ` [PATCH 1/2] sched: Move priority calculation into sched_class Henrik Austad 2009-04-07 13:36 ` [PATCH 2/2] sched: Let sched_class handle effective_prio calculation Henrik Austad 2009-04-07 16:47 ` [PATCH 0/2] sched: make the scheduler (even) more modular Américo Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox