From: Nikhil Rao on
Account SCHED_IDLE tasks on rq->idle_nr_running in addition to rq->nr_running.
This is a preparatory patch for the SCHED_IDLE load balancer.

Signed-off-by: Nikhil Rao <ncrao(a)google.com>
---
kernel/sched.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index f52a880..26e74e9 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -456,6 +456,7 @@ struct rq {
unsigned long nr_running;
#define CPU_LOAD_IDX_MAX 5
unsigned long cpu_load[CPU_LOAD_IDX_MAX];
+ unsigned long idle_nr_running;
#ifdef CONFIG_NO_HZ
u64 nohz_stamp;
unsigned char in_nohz_recently;
@@ -1838,6 +1839,16 @@ static void dec_nr_running(struct rq *rq)
rq->nr_running--;
}

+static void inc_idle_nr_running(struct rq *rq)
+{
+ rq->idle_nr_running++;
+}
+
+static void dec_idle_nr_running(struct rq *rq)
+{
+ rq->idle_nr_running--;
+}
+
static void set_load_weight(struct task_struct *p)
{
if (task_has_rt_policy(p)) {
@@ -1885,6 +1896,8 @@ static void activate_task(struct rq *rq, struct task_struct *p, int flags)

enqueue_task(rq, p, flags);
inc_nr_running(rq);
+ if (p->policy == SCHED_IDLE)
+ inc_idle_nr_running(rq);
}

/*
@@ -1897,6 +1910,8 @@ static void deactivate_task(struct rq *rq, struct task_struct *p, int flags)

dequeue_task(rq, p, flags);
dec_nr_running(rq);
+ if (p->policy == SCHED_IDLE)
+ dec_idle_nr_running(rq);
}

#include "sched_idletask.c"
--
1.7.1

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