[patch 1/8] Add rt_nr_running accounting

Previous thread: [patch 5/8] Move prototypes together. by Steven Rostedt on Friday, October 19, 2007 - 2:42 pm. (1 message)

Next thread: [patch 8/8] disable CFS RT load balancing. by Steven Rostedt on Friday, October 19, 2007 - 2:43 pm. (1 message)
To: LKML <linux-kernel@...>, RT <linux-rt-users@...>
Cc: Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Gregory Haskins <ghaskins@...>, Peter Zijlstra <a.p.zijlstra@...>
Date: Friday, October 19, 2007 - 2:42 pm

This patch adds accounting to keep track of the number of RT tasks running
on a runqueue. This information will be used in later patches.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

---
kernel/sched.c | 2 ++
kernel/sched_rt.c | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)

Index: linux-test.git/kernel/sched.c
===================================================================
--- linux-test.git.orig/kernel/sched.c 2007-10-19 12:32:39.000000000 -0400
+++ linux-test.git/kernel/sched.c 2007-10-19 12:33:09.000000000 -0400
@@ -300,6 +300,8 @@ struct rq {
*/
unsigned long nr_uninterruptible;

+ unsigned long rt_nr_running;
+
struct task_struct *curr, *idle;
unsigned long next_balance;
struct mm_struct *prev_mm;
Index: linux-test.git/kernel/sched_rt.c
===================================================================
--- linux-test.git.orig/kernel/sched_rt.c 2007-10-19 12:31:08.000000000 -0400
+++ linux-test.git/kernel/sched_rt.c 2007-10-19 12:33:09.000000000 -0400
@@ -25,12 +25,28 @@ static void update_curr_rt(struct rq *rq
curr->se.exec_start = rq->clock;
}

+static inline void inc_rt_tasks(struct task_struct *p, struct rq *rq)
+{
+ if (rt_task(p))
+ rq->rt_nr_running++;
+}
+
+static inline void dec_rt_tasks(struct task_struct *p, struct rq *rq)
+{
+ if (rt_task(p)) {
+ WARN_ON(!rq->rt_nr_running);
+ rq->rt_nr_running--;
+ }
+}
+
static void enqueue_task_rt(struct rq *rq, struct task_struct *p, int wakeup)
{
struct rt_prio_array *array = &rq->rt.active;

list_add_tail(&p->run_list, array->queue + p->prio);
__set_bit(p->prio, array->bitmap);
+
+ inc_rt_tasks(p, rq);
}

/*
@@ -42,6 +58,8 @@ static void dequeue_task_rt(struct rq *r

update_curr_rt(rq);

+ dec_rt_tasks(p, rq);
+
list_del(&p->run_list);
if (list_empty(array->queue + p->prio))
__clear_bit(p->prio, array->bitmap);

--
-

To: Steven Rostedt <rostedt@...>
Cc: LKML <linux-kernel@...>, RT <linux-rt-users@...>, Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Gregory Haskins <ghaskins@...>, Peter Zijlstra <a.p.zijlstra@...>
Date: Saturday, October 20, 2007 - 12:45 pm

why do you need the rt_task(p) check in {inc,dec}_rt_tasks() ?

{enqueue,dequeue}_task_rt() seem to be the only callers and they will
crash (or corrupt memory) anyway in the case of ! rt_task(p) (sure,
this case would mean something is broken somewhere wrt sched_class
handling).

--
Best regards,
Dmitry Adamushko
-

To: Dmitry Adamushko <dmitry.adamushko@...>
Cc: LKML <linux-kernel@...>, RT <linux-rt-users@...>, Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, Gregory Haskins <ghaskins@...>, Peter Zijlstra <a.p.zijlstra@...>
Date: Saturday, October 20, 2007 - 10:13 pm

Hi Dmitry,

--

Maybe. I didn't really look too hard to where to put it. Currently, in the
-rt patch, it is located in struct rq, so I just did the same. I may be

Exactly, I was just being safe. We could add a WARN_ON(!rt_task) there.

-- Steve

-

Previous thread: [patch 5/8] Move prototypes together. by Steven Rostedt on Friday, October 19, 2007 - 2:42 pm. (1 message)

Next thread: [patch 8/8] disable CFS RT load balancing. by Steven Rostedt on Friday, October 19, 2007 - 2:43 pm. (1 message)