lkml.org 
[lkml]   [2009]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] sched: Let sched_class handle effective_prio calculation
Date
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


\
 
 \ /
  Last update: 2009-04-07 15:53    [W:0.060 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site