From: Jiri Olsa <jolsa@redhat.com>
To: Milian Wolff <milian.wolff@kdab.com>
Cc: linux-perf-users@vger.kernel.org, acme@kernel.org, namhyung@kernel.org
Subject: Re: measuring system wide CPU usage ignoring idle process
Date: Mon, 20 Nov 2017 15:29:08 +0100 [thread overview]
Message-ID: <20171120142908.GA22876@krava> (raw)
In-Reply-To: <3344812.IFj9h2T05j@agathebauer>
On Mon, Nov 20, 2017 at 03:00:46PM +0100, Milian Wolff wrote:
> Hey all,
>
> colleagues of mine just brought this inconvenient perf stat behavior to my
> attention:
>
> $ perf stat -a -e cpu-clock,task-clock,cycles,instructions sleep 1
>
> Performance counter stats for 'system wide':
>
> 4004.501439 cpu-clock (msec) # 4.000 CPUs utilized
> 4004.526474 task-clock (msec) # 4.000 CPUs utilized
> 945,906,029 cycles # 0.236 GHz
> 461,861,241 instructions # 0.49 insn per cycle
>
> 1.001247082 seconds time elapsed
>
> This shows that cpu-clock and task-clock are incremented also for the idle
> processes. Is there some trick to exclude that time, such that the CPU
> utilization drops below 100% when doing `perf stat -a`?
I dont think it's the idle process you see, I think it's the managing
overhead before the 'sleep 1' task goes actualy to sleep
there's some user space code before it gets into the sleep syscall,
and there's some possible kernel scheduling/syscall/irq code with
events already enabled and counting
in following 3 sessions you can see the counts are pretty much
the same regardless the sleeping time:
[jolsa@krava perf]$ sudo ./perf stat -e cycles:u,cycles:k sleep 1
Performance counter stats for 'sleep 1':
316,478 cycles:u
594,468 cycles:k
1.000813330 seconds time elapsed
[jolsa@krava perf]$ sudo ./perf stat -e cycles:u,cycles:k sleep 5
Performance counter stats for 'sleep 5':
339,287 cycles:u
665,888 cycles:k
5.001004575 seconds time elapsed
[jolsa@krava perf]$ sudo ./perf stat -e cycles:u,cycles:k sleep 10
Performance counter stats for 'sleep 10':
314,507 cycles:u
658,764 cycles:k
10.001117596 seconds time elapsed
jirka
next prev parent reply other threads:[~2017-11-20 14:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 14:00 measuring system wide CPU usage ignoring idle process Milian Wolff
2017-11-20 14:29 ` Jiri Olsa [this message]
2017-11-20 20:24 ` Milian Wolff
2017-11-20 23:44 ` Jiri Olsa
2017-11-23 13:40 ` Milian Wolff
2017-11-23 14:09 ` Jiri Olsa
2017-11-23 14:21 ` Jiri Olsa
2017-11-23 14:42 ` Arnaldo Carvalho de Melo
2017-11-23 15:12 ` Jiri Olsa
2017-11-23 18:59 ` Arnaldo Carvalho de Melo
2017-11-24 8:14 ` Jiri Olsa
2017-11-23 15:15 ` Peter Zijlstra
2018-04-17 13:41 ` Arnaldo Carvalho de Melo
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=20171120142908.GA22876@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=milian.wolff@kdab.com \
--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;
as well as URLs for NNTP newsgroup(s).