From: tip-bot for Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
rostedt@goodmis.org, a.p.zijlstra@chello.nl, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:sched/urgent] sched, trace: Fix sched_switch() prev_state argument
Date: Tue, 1 Jun 2010 09:13:00 GMT [thread overview]
Message-ID: <tip-02f726949f2be0967aa4871dd4e47d3967779b26@git.kernel.org> (raw)
In-Reply-To: <1275322715.27810.23323.camel@twins>
Commit-ID: 02f726949f2be0967aa4871dd4e47d3967779b26
Gitweb: http://git.kernel.org/tip/02f726949f2be0967aa4871dd4e47d3967779b26
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 31 May 2010 18:13:25 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 1 Jun 2010 09:27:17 +0200
sched, trace: Fix sched_switch() prev_state argument
For CONFIG_PREEMPT=y kernels the sched_switch(.prev_state) argument isn't
useful because we can get preempted with current->state != TASK_RUNNING
without actually getting removed from the runqueue.
Cure this by treating all preempted tasks as runnable from the tracer's
point of view.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cautiously-acked-by: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1275322715.27810.23323.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/trace/events/sched.h | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 4f733ec..b9e1dd6 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -115,6 +115,23 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
TP_PROTO(struct task_struct *p, int success),
TP_ARGS(p, success));
+#ifdef CREATE_TRACE_POINTS
+static inline long __trace_sched_switch_state(struct task_struct *p)
+{
+ long state = p->state;
+
+#ifdef CONFIG_PREEMPT
+ /*
+ * For all intents and purposes a preempted task is a running task.
+ */
+ if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE)
+ state = TASK_RUNNING;
+#endif
+
+ return state;
+}
+#endif
+
/*
* Tracepoint for task switches, performed by the scheduler:
*/
@@ -139,7 +156,7 @@ TRACE_EVENT(sched_switch,
memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
__entry->prev_pid = prev->pid;
__entry->prev_prio = prev->prio;
- __entry->prev_state = prev->state;
+ __entry->prev_state = __trace_sched_switch_state(prev);
memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
__entry->next_pid = next->pid;
__entry->next_prio = next->prio;
prev parent reply other threads:[~2010-06-01 9:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-28 14:26 [PATCH] tracing: Add task activate/deactivate tracepoints Frederic Weisbecker
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-bot for Peter Zijlstra [this message]
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=tip-02f726949f2be0967aa4871dd4e47d3967779b26@git.kernel.org \
--to=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.