Re: [RFC 0/12][PATCH] SCHED_DEADLINE: added sched-debug support.
From: Raistlin
Date: Fri Oct 16 2009 - 11:43:44 EST
This commit adds the debugging output support for the SCHED_DEADLINE runqueue.
Signed-off-by: Raistlin <raistlin@xxxxxxxx>
---
include/linux/sched.h | 6 ++++++
kernel/sched_deadline.c | 21 +++++++++++++++++++++
kernel/sched_debug.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 20e1a6a..fac928a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -167,6 +167,8 @@ extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m);
extern void proc_sched_set_task(struct task_struct *p);
extern void
print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
+extern void
+print_deadline_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq);
#else
static inline void
proc_sched_show_task(struct task_struct *p, struct seq_file *m)
@@ -179,6 +181,10 @@ static inline void
print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
}
+static inline void
+print_deadline_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq)
+{
+}
#endif
extern unsigned long long time_sync_thresh;
diff --git a/kernel/sched_deadline.c b/kernel/sched_deadline.c
index b4be178..f2c1b6e 100644
--- a/kernel/sched_deadline.c
+++ b/kernel/sched_deadline.c
@@ -400,6 +400,16 @@ static void start_hrtick_deadline(struct rq *rq, struct task_struct *p)
}
#endif
+static struct sched_dl_entity *__pick_deadline_last_entity(struct dl_rq *dl_rq)
+{
+ struct rb_node *last = rb_last(&dl_rq->rb_root);
+
+ if (!last)
+ return NULL;
+
+ return rb_entry(last, struct sched_dl_entity, rb_node);
+}
+
static struct sched_dl_entity *pick_next_deadline_entity(struct rq *rq,
struct dl_rq *dl_rq)
{
@@ -531,3 +541,14 @@ static const struct sched_class deadline_sched_class = {
.switched_to = switched_to_deadline,
};
+#ifdef CONFIG_SCHED_DEBUG
+static void print_deadline_stats(struct seq_file *m, int cpu)
+{
+ struct dl_rq *dl_rq = &cpu_rq(cpu)->dl;
+
+ rcu_read_lock();
+ for_each_leaf_deadline_rq(dl_rq, cpu_rq(cpu))
+ print_deadline_rq(m, cpu, dl_rq);
+ rcu_read_unlock();
+}
+#endif /* CONFIG_SCHED_DEBUG */
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index efb8440..809ba55 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -246,6 +246,38 @@ void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
#undef P
}
+void print_deadline_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq)
+{
+ s64 min_deadline = -1, max_deadline = -1;
+ struct rq *rq = &per_cpu(runqueues, cpu);
+ struct sched_dl_entity *last;
+ unsigned long flags;
+
+ SEQ_printf(m, "\ndl_rq[%d]:\n", cpu);
+
+ spin_lock_irqsave(&rq->lock, flags);
+ if (dl_rq->rb_leftmost)
+ min_deadline = (rb_entry(dl_rq->rb_leftmost,
+ struct sched_dl_entity,
+ rb_node))->deadline;
+ last = __pick_deadline_last_entity(dl_rq);
+ if (last)
+ max_deadline = last->deadline;
+ spin_unlock_irqrestore(&rq->lock, flags);
+
+#define P(x) \
+ SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(x))
+#define PN(x) \
+ SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(x))
+
+ P(dl_rq->dl_nr_running);
+ PN(min_deadline);
+ PN(max_deadline);
+
+#undef PN
+#undef P
+}
+
static void print_cpu(struct seq_file *m, int cpu)
{
struct rq *rq = cpu_rq(cpu);
@@ -301,6 +333,7 @@ static void print_cpu(struct seq_file *m, int cpu)
#endif
print_cfs_stats(m, cpu);
print_rt_stats(m, cpu);
+ print_deadline_stats(m, cpu);
print_rq(m, rq, cpu);
}
--
1.6.0.4
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
----------------------------------------------------------------------
Dario Faggioli, ReTiS Lab, Scuola Superiore Sant'Anna, Pisa (Italy)
http://blog.linux.it/raistlin / raistlin@xxxxxxxxx /
dario.faggioli@xxxxxxxxxx
Attachment:
signature.asc
Description: This is a digitally signed message part