All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, markus@trippelsdorf.de, rostedt@goodmis.org
Cc: tj@kernel.org, mcgrof@kernel.org, ebiederm@xmission.com,
	paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org,
	tglx@linutronix.de, peterz@infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/8] sched/trace: Fix trace_sched_switch task-state printing
Date: Mon, 25 Sep 2017 14:07:51 +0200	[thread overview]
Message-ID: <20170925121117.116594419@infradead.org> (raw)
In-Reply-To: 20170925120747.125098571@infradead.org

[-- Attachment #1: peterz-sched-state-4.patch --]
[-- Type: text/plain, Size: 2087 bytes --]

Convert trace_sched_switch to use the common task-state helpers and
fix the "X" and "Z" order, possibly they ended up in the wrong order
because TASK_REPORT has them in the wrong order too.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/sched.h        |    2 +-
 include/trace/events/sched.h |   18 +++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -99,7 +99,7 @@ struct task_group;
 /* get_task_state(): */
 #define TASK_REPORT			(TASK_RUNNING | TASK_INTERRUPTIBLE | \
 					 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
-					 __TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD)
+					 __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE)
 
 #define task_is_traced(task)		((task->state & __TASK_TRACED) != 0)
 
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -114,7 +114,10 @@ static inline long __trace_sched_switch_
 	 * Preemption ignores task state, therefore preempted tasks are always
 	 * RUNNING (we will not have dequeued if state != RUNNING).
 	 */
-	return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
+	if (preempt)
+		return TASK_STATE_MAX;
+
+	return __get_task_state(p);
 }
 #endif /* CREATE_TRACE_POINTS */
 
@@ -152,12 +155,13 @@ TRACE_EVENT(sched_switch,
 
 	TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
 		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
-		__entry->prev_state & (TASK_STATE_MAX-1) ?
-		  __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
-				{ 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
-				{ 16, "Z" }, { 32, "X" }, { 64, "x" },
-				{ 128, "K" }, { 256, "W" }, { 512, "P" },
-				{ 1024, "N" }) : "R",
+
+		(__entry->prev_state & TASK_REPORT) ?
+		  __print_flags(__entry->prev_state & TASK_REPORT, "|",
+				{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
+				{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" }) :
+		  "R",
+
 		__entry->prev_state & TASK_STATE_MAX ? "+" : "",
 		__entry->next_comm, __entry->next_pid, __entry->next_prio)
 );

  parent reply	other threads:[~2017-09-25 12:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25 12:07 [PATCH 0/8] sched: Rework task state printing Peter Zijlstra
2017-09-25 12:07 ` [PATCH 1/8] sched: Consistent task-state printing Peter Zijlstra
2017-09-25 20:01   ` Steven Rostedt
2017-09-29 11:50     ` Peter Zijlstra
2017-09-29 13:00       ` Steven Rostedt
2017-10-10 10:55       ` [tip:sched/core] sched/debug: Rename task-state printing helpers tip-bot for Peter Zijlstra
2017-09-25 12:07 ` [PATCH 2/8] sched: Convert TASK_state to hex Peter Zijlstra
2017-09-25 12:07 ` [PATCH 3/8] sched/debug: Remove unused variable Peter Zijlstra
2017-09-25 12:07 ` Peter Zijlstra [this message]
2017-09-25 12:07 ` [PATCH 5/8] sched/trace: Use common task-state helpers Peter Zijlstra
2017-09-25 12:07 ` [PATCH 6/8] sched: Add explicit TASK_IDLE printing Peter Zijlstra
2017-09-25 12:07 ` [PATCH 7/8] sched: Ignore TASK_IDLE for SysRq-W Peter Zijlstra
2017-09-25 12:07 ` [PATCH 8/8] sched: Add explicit TASK_PARKED printing Peter Zijlstra
2017-09-25 13:41 ` [PATCH 0/8] sched: Rework task state printing Thomas Gleixner

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=20170925121117.116594419@infradead.org \
    --to=peterz@infradead.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus@trippelsdorf.de \
    --cc=mcgrof@kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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 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.