From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756334AbcG0OSi (ORCPT ); Wed, 27 Jul 2016 10:18:38 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35928 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754048AbcG0OSh (ORCPT ); Wed, 27 Jul 2016 10:18:37 -0400 Subject: Re: [PATCH] perf sched: fix wrong conversion of task state To: Tomoki Sekiyama , linux-kernel@vger.kernel.org References: <1469624093-16601-1-git-send-email-tomoki.sekiyama.qu@hitachi.com> Cc: ltc-kernel@rdgml.intra.hitachi.co.jp, masumi.moritani.ju@hitachi.com, Jiri Olsa , Namhyung Kim , Peter Zijlstra , Masami Hiramatsu From: David Ahern Message-ID: <63263328-bde5-8cc1-e98b-08448fc163ea@gmail.com> Date: Wed, 27 Jul 2016 08:18:14 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1469624093-16601-1-git-send-email-tomoki.sekiyama.qu@hitachi.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Jiri Olsa > Cc: David Ahern > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: Masami Hiramatsu > --- > 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).