Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1401052 > unrolled thread
| Started by | Andi Kleen <andi@firstfloor.org> |
|---|---|
| First post | 2016-05-14 03:50 +0200 |
| Last post | 2016-05-20 12:30 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
Add top down metrics to perf stat Andi Kleen <andi@firstfloor.org> - 2016-05-14 03:50 +0200
Re: Add top down metrics to perf stat Jiri Olsa <jolsa@redhat.com> - 2016-05-16 15:00 +0200
Re: Add top down metrics to perf stat Andi Kleen <andi@firstfloor.org> - 2016-05-20 02:00 +0200
Re: Add top down metrics to perf stat Jiri Olsa <jolsa@redhat.com> - 2016-05-20 12:10 +0200
Re: Add top down metrics to perf stat Andi Kleen <andi@firstfloor.org> - 2016-05-20 16:20 +0200
Re: Add top down metrics to perf stat Jiri Olsa <jolsa@redhat.com> - 2016-05-20 12:30 +0200
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2016-05-14 03:50 +0200 |
| Subject | Add top down metrics to perf stat |
| Message-ID | <rywSm-7dg-3@gated-at.bofh.it> |
Note to reviewers: includes both tools and kernel patches.
The kernel patches are at the beginning.
[v2: Address review feedback.
Metrics are now always printed, but colored when crossing threshold.
--topdown implies --metric-only.
Various smaller fixes, see individual patches]
[v3: Add --single-thread option and support it with HT off.
Clean up old HT workaround.
Improve documentation.
Various smaller fixes, see individual patches.]
[v4: Rebased on latest tree]
[v5: Rebased on latest tree. Move debug messages to -vv]
[v6: Rebased. Remove .aggr-per-core and --single-thread to not
break old perf binaries. Put SMT enumeration into
generic topology API.]
[v7: Address review comments. Change patch title headers.]
This patchkit adds support for TopDown measurements to perf stat
It applies on top of my earlier metrics patchkit, posted
separately.
TopDown is intended to replace the frontend cycles idle/
backend cycles idle metrics in standard perf stat output.
These metrics are not reliable in many workloads,
due to out of order effects.
This implements a new --topdown mode in perf stat
(similar to --transaction) that measures the pipe line
bottlenecks using standardized formulas. The measurement
can be all done with 5 counters (one fixed counter)
The result are four metrics:
FrontendBound, BackendBound, BadSpeculation, Retiring
that describe the CPU pipeline behavior on a high level.
FrontendBound and BackendBound
BadSpeculation is a higher
The full top down methology has many hierarchical metrics.
This implementation only supports level 1 which can be
collected without multiplexing. A full implementation
of top down on top of perf is available in pmu-tools toplev.
(http://github.com/andikleen/pmu-tools)
The current version works on Intel Core CPUs starting
with Sandy Bridge, and Atom CPUs starting with Silvermont.
In principle the generic metrics should be also implementable
on other out of order CPUs.
TopDown level 1 uses a set of abstracted metrics which
are generic to out of order CPU cores (although some
CPUs may not implement all of them):
topdown-total-slots Available slots in the pipeline
topdown-slots-issued Slots issued into the pipeline
topdown-slots-retired Slots successfully retired
topdown-fetch-bubbles Pipeline gaps in the frontend
topdown-recovery-bubbles Pipeline gaps during recovery
from misspeculation
These metrics then allow to compute four useful metrics:
FrontendBound, BackendBound, Retiring, BadSpeculation.
The formulas to compute the metrics are generic, they
only change based on the availability on the abstracted
input values.
The kernel declares the events supported by the current
CPU and perf stat then computes the formulas based on the
available metrics.
Example output:
$ perf stat --topdown -I 1000 cmd
1.000735655 frontend bound retiring bad speculation backend bound
1.000735655 S0-C0 2 47.84% 11.69% 8.37% 32.10%
1.000735655 S0-C1 2 45.53% 11.39% 8.52% 34.56%
2.003978563 S0-C0 2 49.47% 12.22% 8.65% 29.66%
2.003978563 S0-C1 2 47.21% 12.98% 8.77% 31.04%
3.004901432 S0-C0 2 49.35% 12.26% 8.68% 29.70%
3.004901432 S0-C1 2 47.23% 12.67% 8.76% 31.35%
4.005766611 S0-C0 2 48.44% 12.14% 8.59% 30.82%
4.005766611 S0-C1 2 46.07% 12.41% 8.67% 32.85%
5.006580592 S0-C0 2 47.91% 12.08% 8.57% 31.44%
5.006580592 S0-C1 2 45.57% 12.27% 8.63% 33.53%
6.007545125 S0-C0 2 47.45% 12.02% 8.57% 31.96%
6.007545125 S0-C1 2 45.13% 12.17% 8.57% 34.14%
7.008539347 S0-C0 2 47.07% 12.03% 8.61% 32.29%
...
For Level 1 Top Down computes metrics per core instead of per logical CPU
on Core CPUs (On Atom CPUs there is no Hyper Threading and TopDown
is per thread)
In this case perf stat automatically enables --per-core mode and also requires
global mode (-a) and avoiding other filters (no cgroup mode)
One side effect is that this may require root rights or a
kernel.perf_event_paranoid=-1 setting.
Full tree available in
git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc perf/top-down-21
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-16 15:00 +0200 |
| Message-ID | <rzqhQ-7bz-7@gated-at.bofh.it> |
| In reply to | #1401052 |
On Fri, May 13, 2016 at 06:44:49PM -0700, Andi Kleen wrote:
SNIP
>
> The formulas to compute the metrics are generic, they
> only change based on the availability on the abstracted
> input values.
>
> The kernel declares the events supported by the current
> CPU and perf stat then computes the formulas based on the
> available metrics.
>
>
> Example output:
>
> $ perf stat --topdown -I 1000 cmd
> 1.000735655 frontend bound retiring bad speculation backend bound
> 1.000735655 S0-C0 2 47.84% 11.69% 8.37% 32.10%
> 1.000735655 S0-C1 2 45.53% 11.39% 8.52% 34.56%
you've lost first 3 header lines (time/core/cpus):
[jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --per-core -e cycles -I 1000 -a
# time core cpus counts unit events
1.000310344 S0-C0 2 3,764,470,414 cycles
1.000310344 S0-C1 2 3,764,445,293 cycles
1.000310344 S0-C2 2 3,764,428,422 cycles
also I'm still getting -0% as I mentioned in my previous comment:
[jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --topdown -I 1000 -a
nmi_watchdog enabled with topdown. May give wrong results.
Disable with echo 0 > /proc/sys/kernel/nmi_watchdog
1.001615409 retiring bad speculation frontend bound backend bound
1.001615409 S0-C0 2 38.3% 0.0% 58.4% 3.3%
1.001615409 S0-C1 2 38.1% -0.0% 59.3% 2.6%
1.001615409 S0-C2 2 38.1% 0.0% 58.9% 2.9%
1.001615409 S0-C3 2 38.1% -0.0% 58.9% 3.0%
1.001615409 S0-C4 2 38.0% 0.0% 59.0% 2.9%
1.001615409 S0-C5 2 38.1% -0.0% 58.6% 3.3%
1.001615409 S1-C0 2 49.7% 1.9% 44.7% 3.7%
thanks,
jirka
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2016-05-20 02:00 +0200 |
| Message-ID | <rAG1b-6u9-13@gated-at.bofh.it> |
| In reply to | #1401481 |
On Mon, May 16, 2016 at 02:58:38PM +0200, Jiri Olsa wrote: > On Fri, May 13, 2016 at 06:44:49PM -0700, Andi Kleen wrote: > > SNIP > > > > > The formulas to compute the metrics are generic, they > > only change based on the availability on the abstracted > > input values. > > > > The kernel declares the events supported by the current > > CPU and perf stat then computes the formulas based on the > > available metrics. > > > > > > Example output: > > > > $ perf stat --topdown -I 1000 cmd > > 1.000735655 frontend bound retiring bad speculation backend bound > > 1.000735655 S0-C0 2 47.84% 11.69% 8.37% 32.10% > > 1.000735655 S0-C1 2 45.53% 11.39% 8.52% 34.56% Hi Jiri, > > you've lost first 3 header lines (time/core/cpus): > > [jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --per-core -e cycles -I 1000 -a > # time core cpus counts unit events > 1.000310344 S0-C0 2 3,764,470,414 cycles > 1.000310344 S0-C1 2 3,764,445,293 cycles > 1.000310344 S0-C2 2 3,764,428,422 cycles I can't reproduce that. The headers look the same as before. > > also I'm still getting -0% as I mentioned in my previous comment: Keeping the NMI watchdog enabled can make the formulas inaccurate because the grouping is disabled, and parts of the formulas may be measured at different times where the execution profile is different. But anyways even without that it can be caused by small inaccuracies, and then during rounding the value rounds to 0. I can remove the - for this case. Otherwise the data looks reasonable. -Andi -- ak@linux.intel.com -- Speaking for myself only.
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-20 12:10 +0200 |
| Message-ID | <rAPxw-4bk-31@gated-at.bofh.it> |
| In reply to | #1404026 |
On Thu, May 19, 2016 at 04:51:30PM -0700, Andi Kleen wrote:
> On Mon, May 16, 2016 at 02:58:38PM +0200, Jiri Olsa wrote:
> > On Fri, May 13, 2016 at 06:44:49PM -0700, Andi Kleen wrote:
> >
> > SNIP
> >
> > >
> > > The formulas to compute the metrics are generic, they
> > > only change based on the availability on the abstracted
> > > input values.
> > >
> > > The kernel declares the events supported by the current
> > > CPU and perf stat then computes the formulas based on the
> > > available metrics.
> > >
> > >
> > > Example output:
> > >
> > > $ perf stat --topdown -I 1000 cmd
> > > 1.000735655 frontend bound retiring bad speculation backend bound
> > > 1.000735655 S0-C0 2 47.84% 11.69% 8.37% 32.10%
> > > 1.000735655 S0-C1 2 45.53% 11.39% 8.52% 34.56%
>
> Hi Jiri,
> >
> > you've lost first 3 header lines (time/core/cpus):
> >
> > [jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --per-core -e cycles -I 1000 -a
> > # time core cpus counts unit events
> > 1.000310344 S0-C0 2 3,764,470,414 cycles
> > 1.000310344 S0-C1 2 3,764,445,293 cycles
> > 1.000310344 S0-C2 2 3,764,428,422 cycles
>
> I can't reproduce that.
>
I can.. your latest code does not display headers: 'time' 'core' 'cpus'
also the initial '#'
[jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --topdown -I 1000 -a
nmi_watchdog enabled with topdown. May give wrong results.
Disable with echo 0 > /proc/sys/kernel/nmi_watchdog
1.002097350 retiring bad speculation frontend bound backend bound
1.002097350 S0-C0 2 38.1% 0.0% 59.2% 2.7%
1.002097350 S0-C1 2 38.1% 0.1% 59.7% 2.1%
thanks,
jirka
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2016-05-20 16:20 +0200 |
| Message-ID | <rATrs-6y8-17@gated-at.bofh.it> |
| In reply to | #1404309 |
> [jolsa@ibm-x3650m4-01 perf]$ sudo ./perf stat --topdown -I 1000 -a > nmi_watchdog enabled with topdown. May give wrong results. > Disable with echo 0 > /proc/sys/kernel/nmi_watchdog > 1.002097350 retiring bad speculation frontend bound backend bound > 1.002097350 S0-C0 2 38.1% 0.0% 59.2% 2.7% > 1.002097350 S0-C1 2 38.1% 0.1% 59.7% 2.1% Ah I see now. this is --metric-only not displaying. --topdown enables --metric-only implicitely. I'll send a separate patch for that because metric only was already merged separately. So it's not really a problem in this patchkit, but in a previous one. -Andi -- ak@linux.intel.com -- Speaking for myself only.
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-20 12:30 +0200 |
| Message-ID | <rAPQS-4i2-5@gated-at.bofh.it> |
| In reply to | #1401052 |
On Fri, May 13, 2016 at 06:44:49PM -0700, Andi Kleen wrote: > Note to reviewers: includes both tools and kernel patches. > The kernel patches are at the beginning. > > [v2: Address review feedback. > Metrics are now always printed, but colored when crossing threshold. > --topdown implies --metric-only. > Various smaller fixes, see individual patches] > [v3: Add --single-thread option and support it with HT off. > Clean up old HT workaround. > Improve documentation. > Various smaller fixes, see individual patches.] > [v4: Rebased on latest tree] > [v5: Rebased on latest tree. Move debug messages to -vv] > [v6: Rebased. Remove .aggr-per-core and --single-thread to not > break old perf binaries. Put SMT enumeration into > generic topology API.] > [v7: Address review comments. Change patch title headers.] other than the missing headers and unnneeded initialization of have_frontend_stalled I'm ok with the perf tools part thanks, jirka
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web