[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1469635660-29303-1-git-send-email-tomoki.sekiyama.qu@hitachi.com>
Date: Thu, 28 Jul 2016 01:07:40 +0900
From: Tomoki Sekiyama <tomoki.sekiyama.qu@...achi.com>
To: linux-kernel@...r.kernel.org
Cc: ltc-kernel@...ml.intra.hitachi.co.jp,
masumi.moritani.ju@...achi.com,
Tomoki Sekiyama <tomoki.sekiyama.qu@...achi.com>,
Jiri Olsa <jolsa@...nel.org>, David Ahern <dsahern@...il.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Masami Hiramatsu <mhiramat@...nel.org>
Subject: [PATCH v2] perf sched: fix wrong conversion of task state
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.
Also, preempted tasks must be considered that they are in the
THREAD_WAIT_CPU state.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@...achi.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
---
tools/perf/builtin-sched.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0dfe8df..8651c36 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -70,7 +70,8 @@ struct sched_atom {
struct task_desc *wakee;
};
-#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"
+/* TASK_STATE_MAX means the task is preempted(R+). Use '+' for it here. */
+#define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWPN+"
enum thread_state {
THREAD_SLEEPING = 0,
@@ -897,9 +898,10 @@ static int thread_atoms_insert(struct perf_sched *sched, struct thread *thread)
static char sched_out_state(u64 prev_state)
{
- const char *str = TASK_STATE_TO_CHAR_STR;
+ const char str[] = TASK_STATE_TO_CHAR_STR;
+ unsigned int bit = prev_state ? __ffs(prev_state) + 1 : 0;
- return str[prev_state];
+ return bit < sizeof(str) - 1 ? str[bit] : '?';
}
static int
@@ -915,7 +917,7 @@ add_sched_out_event(struct work_atoms *atoms,
atom->sched_out_time = timestamp;
- if (run_state == 'R') {
+ if (run_state == 'R' || run_state == '+') {
atom->state = THREAD_WAIT_CPU;
atom->wake_up_time = atom->sched_out_time;
}
--
2.7.4
Powered by blists - more mailing lists