mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH] tracing: Add task activate/deactivate tracepoints
Date: Fri, 28 May 2010 16:26:02 +0200	[thread overview]
Message-ID: <1275056762-13130-1-git-send-regression-fweisbec@gmail.com> (raw)

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@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@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


             reply	other threads:[~2010-05-28 14:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-28 14:26 Frederic Weisbecker [this message]
2010-05-28 15:15 ` Peter Zijlstra
2010-05-31  8:00   ` Ingo Molnar
2010-05-31  8:12     ` Peter Zijlstra
2010-05-31  8:54       ` Peter Zijlstra
2010-05-31 14:36         ` Frederic Weisbecker
2010-05-31 14:43           ` Peter Zijlstra
2010-05-31 14:48             ` Frederic Weisbecker
2010-05-31 16:18               ` Peter Zijlstra
2010-05-31 16:37                 ` Steven Rostedt
2010-05-31 18:28                   ` Peter Zijlstra
2010-05-31 19:14                     ` Steven Rostedt
2010-05-31 19:16                     ` Steven Rostedt
2010-05-31 16:51                 ` Frederic Weisbecker
2010-06-01  9:13                 ` [tip:sched/urgent] sched, trace: Fix sched_switch() prev_state argument tip-bot for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275056762-13130-1-git-send-regression-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®