This patch adds an RT overload accounting system. When a runqueue has
more than one RT task queued, it is marked as overloaded. That is that it
is a candidate to have RT tasks pulled from it.

Along with the rt_overload counter (number of overloaded runqueues) a
bit mask of overloaded runqueues with RT tasks is set.

Signed-off-by: Steven Rostedt <[EMAIL PROTECTED]>
---
 kernel/sched_rt.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Index: linux-test.git/kernel/sched_rt.c
===================================================================
--- linux-test.git.orig/kernel/sched_rt.c       2007-10-19 12:34:46.000000000 
-0400
+++ linux-test.git/kernel/sched_rt.c    2007-10-19 12:35:58.000000000 -0400
@@ -25,10 +25,23 @@ static void update_curr_rt(struct rq *rq
        curr->se.exec_start = rq->clock;
 }
 
+#ifdef CONFIG_SMP
+static __cacheline_aligned_in_smp atomic_t rt_overload;
+static cpumask_t rto_cpumask;
+#endif /* CONFIG_SMP*/
+
 static inline void inc_rt_tasks(struct task_struct *p, struct rq *rq)
 {
        if (rt_task(p))
                rq->rt_nr_running++;
+#ifdef CONFIG_SMP
+       if (rq->rt_nr_running == 2) {
+               cpu_set(rq->cpu, rto_cpumask);
+               /* Make sure this cpu is visible on rt_overloads */
+               smp_wmb();
+               atomic_inc(&rt_overload);
+       }
+#endif
 }
 
 static inline void dec_rt_tasks(struct task_struct *p, struct rq *rq)
@@ -37,6 +50,12 @@ static inline void dec_rt_tasks(struct t
                WARN_ON(!rq->rt_nr_running);
                rq->rt_nr_running--;
        }
+#ifdef CONFIG_SMP
+       if (rq->rt_nr_running == 1) {
+               atomic_dec(&rt_overload);
+               cpu_clear(rq->cpu, rto_cpumask);
+       }
+#endif
 }
 
 static void enqueue_task_rt(struct rq *rq, struct task_struct *p, int wakeup)

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to