Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1451297

Re: [PATCH] perf sched: fix wrong conversion of task state

From David Ahern <dsahern@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] perf sched: fix wrong conversion of task state
Date 2016-07-27 16:20 +0200
Message-ID <rZxQJ-ug-11@gated-at.bofh.it> (permalink)
References <rZwUF-8kd-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 7/27/16 6:54 AM, Tomoki Sekiyama wrote:
> 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

The mask should not be needed and looking at top of tree there are 2 new 
states (N and n) that need to be added.

>
>  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
>

Handle unknown bits with '?' like the kernel does (see task_state_char 
and sched_show_task).

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] perf sched: fix wrong conversion of task state Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com> - 2016-07-27 15:20 +0200
  Re: [PATCH] perf sched: fix wrong conversion of task state David Ahern <dsahern@gmail.com> - 2016-07-27 16:20 +0200
    RE: [PATCH] perf sched: fix wrong conversion of task state 関山友輝 / SEKIYAMA,TOMOKI   <tomoki.sekiyama.qu@hitachi.com> - 2016-07-27 18:10 +0200
    RE: [PATCH] perf sched: fix wrong conversion of task state 関山友輝 / SEKIYAMA,TOMOKI   <tomoki.sekiyama.qu@hitachi.com> - 2016-07-27 18:10 +0200
      Re: [PATCH] perf sched: fix wrong conversion of task state David Ahern <dsahern@gmail.com> - 2016-07-27 19:00 +0200
        RE: [PATCH] perf sched: fix wrong conversion of task state "Tomoki Sekiyama" <tomoki.sekiyama.qu@hitachi.com> - 2016-07-28 05:20 +0200
          Re: [PATCH] perf sched: fix wrong conversion of task state David Ahern <dsahern@gmail.com> - 2016-07-28 16:30 +0200
            Re: [PATCH] perf sched: fix wrong conversion of task state 関山友輝 / SEKIYAMA,TOMOKI   <tomoki.sekiyama.qu@hitachi.com> - 2016-07-29 04:40 +0200

csiph-web