From: Frederic Weisbecker on
We have various tracepoints that tell us when a task is going to
be enqueued in a runqueue: fork, wakeup, migrate.

But they don't always provide us the level of information necessary
to know what is actually in which runqueue, precisely because the
migrate event is only fired if the task is queued on another
cpu than its previous one. So we don't always know where a waking up
task goes.

And moreover we don't have events that tells a task goes to sleep,
and even that wouldn't cover every cases when a task is dequeued.

So bring these two new tracepoints to get informations about the
load of each runqueues.

Signed-off-by: Frederic Weisbecker <fweisbec(a)gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra(a)chello.nl>
Cc: Ingo Molnar <mingo(a)elte.hu>
Cc: Steven Rostedt <rostedt(a)goodmis.org>
---
include/trace/events/sched.h | 36 ++++++++++++++++++++++++++++++++++++
kernel/sched.c | 2 ++
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 4f733ec..f7f94af 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -185,6 +185,42 @@ TRACE_EVENT(sched_migrate_task,
__entry->orig_cpu, __entry->dest_cpu)
);

+DECLARE_EVENT_CLASS(sched_activation_template,
+
+ TP_PROTO(struct task_struct *p, int cpu),
+
+ TP_ARGS(p, cpu),
+
+ TP_STRUCT__entry(
+ __field( pid_t, pid )
+ __field( int, cpu )
+ ),
+
+ TP_fast_assign(
+ __entry->pid = p->pid;
+ __entry->cpu = cpu;
+ ),
+
+ TP_printk("pid=%d cpu=%d", __entry->pid, __entry->cpu)
+);
+
+
+/*
+ * Tracepoint for activating a task, pulling it in a runqueue
+ */
+DEFINE_EVENT(sched_activation_template, sched_activate_task,
+ TP_PROTO(struct task_struct *p, int cpu),
+ TP_ARGS(p, cpu));
+
+
+/*
+ * Tracepoint for deactivating a task, pushing it out a runqueue
+ */
+DEFINE_EVENT(sched_activation_template, sched_deactivate_task,
+ TP_PROTO(struct task_struct *p, int cpu),
+ TP_ARGS(p, cpu));
+
+
DECLARE_EVENT_CLASS(sched_process_template,

TP_PROTO(struct task_struct *p),
diff --git a/kernel/sched.c b/kernel/sched.c
index 1d93cd0..8c0b90d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1904,6 +1904,7 @@ static void activate_task(struct rq *rq, struct task_struct *p, int flags)
if (task_contributes_to_load(p))
rq->nr_uninterruptible--;

+ trace_sched_activate_task(p, cpu_of(rq));
enqueue_task(rq, p, flags);
inc_nr_running(rq);
}
@@ -1916,6 +1917,7 @@ static void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
if (task_contributes_to_load(p))
rq->nr_uninterruptible++;

+ trace_sched_deactivate_task(p, cpu_of(rq));
dequeue_task(rq, p, flags);
dec_nr_running(rq);
}
--
1.6.2.3

--
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/