mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf sched: fix wrong conversion of task state
@ 2016-07-27 12:54 Tomoki Sekiyama
  2016-07-27 14:18 ` David Ahern
  0 siblings, 1 reply; 9+ messages in thread
From: Tomoki Sekiyama @ 2016-07-27 12:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: ltc-kernel, masumi.moritani.ju, Tomoki Sekiyama, Jiri Olsa,
	David Ahern, Namhyung Kim, Peter Zijlstra, Masami Hiramatsu

sched_out_state() converts the prev_state u64 bitmask to a char in
a wrong way, which may cause wrong results of 'perf sched latency'.
This patch fixes the conversion.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/builtin-sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0dfe8df..eb2f7f4 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -71,6 +71,7 @@ struct sched_atom {
 };
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"
+#define TASK_STATE_MASK 0x7ff
 
 enum thread_state {
 	THREAD_SLEEPING = 0,
@@ -899,7 +900,7 @@ static char sched_out_state(u64 prev_state)
 {
 	const char *str = TASK_STATE_TO_CHAR_STR;
 
-	return str[prev_state];
+	return str[ffs(prev_state & TASK_STATE_MASK)];
 }
 
 static int
-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH] perf sched: fix wrong conversion of task state
@ 2016-07-27 12:52 Tomoki Sekiyama
  0 siblings, 0 replies; 9+ messages in thread
From: Tomoki Sekiyama @ 2016-07-27 12:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: ltc-kernel, Tomoki Sekiyama, Jiri Olsa, David Ahern,
	Namhyung Kim, Peter Zijlstra, Masami Hiramatsu

sched_out_state() converts the prev_state u64 bitmask to a char in
a wrong way, which may cause wrong results of 'perf sched latency'.
This patch fixes the conversion.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/builtin-sched.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0dfe8df..eb2f7f4 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -71,6 +71,7 @@ struct sched_atom {
 };
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"
+#define TASK_STATE_MASK 0x7ff
 
 enum thread_state {
 	THREAD_SLEEPING = 0,
@@ -899,7 +900,7 @@ static char sched_out_state(u64 prev_state)
 {
 	const char *str = TASK_STATE_TO_CHAR_STR;
 
-	return str[prev_state];
+	return str[ffs(prev_state & TASK_STATE_MASK)];
 }
 
 static int
-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-07-29  2:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27 12:54 [PATCH] perf sched: fix wrong conversion of task state Tomoki Sekiyama
2016-07-27 14:18 ` David Ahern
2016-07-27 15:58   ` 関山友輝 / SEKIYAMA,TOMOKI
2016-07-27 16:03     ` 関山友輝 / SEKIYAMA,TOMOKI
2016-07-27 16:50     ` David Ahern
2016-07-28  3:10       ` Tomoki Sekiyama
2016-07-28 14:26         ` David Ahern
2016-07-29  2:30           ` 関山友輝 / SEKIYAMA,TOMOKI
  -- strict thread matches above, loose matches on Subject: below --
2016-07-27 12:52 Tomoki Sekiyama

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome