---
 include/linux/sched.h |    2 +-
 kernel/sched.c        |   21 ++++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)

Index: linux-2.6.21-ck3/include/linux/sched.h
===================================================================
--- linux-2.6.21-ck3.orig/include/linux/sched.h	2007-05-25 16:19:02.000000000 +1000
+++ linux-2.6.21-ck3/include/linux/sched.h	2007-05-25 16:21:04.000000000 +1000
@@ -1245,7 +1245,7 @@
 #endif
 
 extern void set_user_nice(struct task_struct *p, long nice);
-extern int task_prio(const struct task_struct *p);
+extern int task_prio(struct task_struct *p);
 extern int task_nice(const struct task_struct *p);
 extern int can_nice(const struct task_struct *p, const int nice);
 extern int task_curr(const struct task_struct *p);
Index: linux-2.6.21-ck3/kernel/sched.c
===================================================================
--- linux-2.6.21-ck3.orig/kernel/sched.c	2007-05-25 16:19:01.000000000 +1000
+++ linux-2.6.21-ck3/kernel/sched.c	2007-05-25 16:20:48.000000000 +1000
@@ -97,7 +97,7 @@
 
 /*
  * This is the time all tasks within the same priority round robin.
- * Value is in ms and set to a minimum of 8ms. Scales with number of cpus.
+ * Value is in ms and set to a minimum of 10ms. Scales with number of cpus.
  * Tunable via /proc interface.
  */
 int rr_interval __read_mostly = 6;
@@ -4193,18 +4193,29 @@
 }
 
 #endif
-
 /**
  * task_prio - return the priority value of a given task.
  * @p: the task in question.
  *
  * This is the priority value as seen by users in /proc.
  * RT tasks are offset by -200. Normal tasks are centered
- * around 0, value goes from 0 to +39.
+ * around 1, value goes from 0 to +79. Values higher than
+ * 39 indicate task is on the expired array. This is done
+ * lockless and may rarely return an active instead of
+ * expired value.
  */
-int task_prio(const struct task_struct *p)
+int task_prio(struct task_struct *p)
 {
-	return p->prio - MAX_RT_PRIO;
+	int prio = p->prio - MAX_RT_PRIO;
+
+	if (task_queued(p)) {
+		struct rq *rq = task_rq(p);
+		struct prio_array *array = p->array;
+
+		if (rq && rq->expired == array)
+			prio += PRIO_RANGE;
+	}
+	return prio;
 }
 
 /**
