From: "Tomoki Sekiyama" <tomoki.sekiyama.qu@hitachi.com>
To: "'David Ahern'" <dsahern@gmail.com>, <linux-kernel@vger.kernel.org>
Cc: ltc-kernel@rdgml.intra.hitachi.co.jp,
"森谷真寿美 / MORITANI,MASUMI" <masumi.moritani.ju@hitachi.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
"Masami Hiramatsu" <mhiramat@kernel.org>
Subject: RE: [PATCH] perf sched: fix wrong conversion of task state
Date: Thu, 28 Jul 2016 12:10:33 +0900 [thread overview]
Message-ID: <000001d1e87d$9b28e680$d17ab380$@hitachi.com> (raw)
In-Reply-To: <329ca7da-d6ca-2067-0789-63d75f345a90@gmail.com>
On 2016/7/28 1:50, David Ahern wrote:
>>>> 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.
>>
>> I couldn't find the state for 'n'. Where can I find it?
>
> Check Linus' tree -- top of tree; commit 7dc603c9028ea.
Thanks, I was failing to git pull by some network reason..
Will add 'n' too.
>> I have rechecked the code and found that __trace_sched_switch_state()
uses
>> TASK_STATE_MAX for preempted tasks.
>
>since TASK_STATE_MAX is kernel version dependent perf should not rely on
it.
Hmm, that is true (actually 'n' is added recently).
But that means we cannot handle preemption correctly as far as
sched:sched_switch
event uses TASK_STATE_MAX to mark preempted tasks.
Should we stop using TASK_STATE_MAX for preempted tasks in ftrace and
use (1 << 63) or something that doesn't change on kernel version instead?
This causes missing some context switches information by 'perf sched
latency'.
For example, running 2 'yes' commands (inifinitely call write(2)) on the
same
cpu by following steps results in the incomplete result:
$ taskset -c 0 yes > /dev/null &
$ taskset -c 0 yes > /dev/null &
# perf sched record sleep 1
# perf sched latency -p -C 0
like:
----------------------------------------------------------------------
Task | Runtime ms | Switches | Average delay ms |
----------------------------------------------------------------------
yes:14187 | 499.705 ms | 17 | avg: 12.981 ms |
yes:14188 | 500.350 ms | 14 | avg: 12.023 ms |
gnome-terminal-:12722 | 0.285 ms | 3 | avg: 0.025 ms |
...
where avg delay * switches for yes commands don't cover expected total delay
500 ms although one make another delayed to be executed.
(12.981 ms * 17 = 220.677 ms << 500 ms)
With the patch, perf sched latency shows:
Now 12.838 ms * 39 = 500.682 ms as expected.
----------------------------------------------------------------------
Task | Runtime ms | Switches | Average delay ms |
----------------------------------------------------------------------
yes:14187 | 499.705 ms | 39 | avg: 12.838 ms |
yes:14188 | 500.350 ms | 40 | avg: 12.506 ms |
gnome-terminal-:12722 | 0.285 ms | 3 | avg: 0.025 ms |
...
Thanks,
Tomoki Sekiyama
next prev parent reply other threads:[~2016-07-28 3:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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='000001d1e87d$9b28e680$d17ab380$@hitachi.com' \
--to=tomoki.sekiyama.qu@hitachi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ltc-kernel@rdgml.intra.hitachi.co.jp \
--cc=masumi.moritani.ju@hitachi.com \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox