Skip to content

perf stat: Introduce --per-thread option

Jiri Olsa lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest22 patches 2 repliesIn review
  2. v427 patches 14 repliesApplied
  3. v326 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v230 patches10 repliesApplied
v125 patches28 repliesSuperseded

Changes in v5 from the cover letter

- reading comms explicitly by thread_map__read_comms, so it gets read only within 'perf stat --per-thread'
- introducing thread_map__reset function
- several patches got accepted, rebased on latest perf/core

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22perf thread_map: Introduce thread_map__reset functiontools/perf/util/thread_map.c+16 -11 reply
2/22perf tools: Add comm string into struct thread_maptools/perf/util/python-ext-sources tools/perf/util/thread_map.c tools/perf/util/thread_map.h+68 -00 replies
3/22perf tests: Add thread_map object teststools/perf/tests/Build tools/perf/tests/builtin-test.c tools/perf/tests/tests.h +1 more+44 -00 replies
4/22perf stat: Introduce perf_counts functiontools/perf/builtin-stat.c tools/perf/tests/openat-syscall-all-cpus.c tools/perf/tests/openat-syscall.c +3 more+37 -300 replies
5/22perf stat: Use xyarray for cpu evsel countstools/perf/builtin-stat.c tools/perf/tests/openat-syscall.c tools/perf/util/stat.c +1 more+28 -140 replies
6/22perf stat: Make stats work over the thread dimensiontools/perf/builtin-stat.c tools/perf/tests/openat-syscall-all-cpus.c tools/perf/tests/openat-syscall.c +4 more+38 -340 replies
7/22perf stat: Rename struct perf_counts::cpu member to valuestools/perf/util/stat.c tools/perf/util/stat.h+8 -80 replies
8/22perf stat: Introduce perf_evlist__reset_statstools/perf/builtin-stat.c+6 -20 replies
9/22perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into stat objecttools/perf/builtin-stat.c tools/perf/util/stat.c tools/perf/util/stat.h+29 -250 replies
10/22perf stat: Move perf_evsel__(alloc|free)_prev_raw_counts into stat objecttools/perf/builtin-stat.c tools/perf/util/stat.c tools/perf/util/stat.h+22 -180 replies
11/22perf stat: Move perf_evlist__(alloc|free|reset)_stats into stat objecttools/perf/builtin-stat.c tools/perf/util/evlist.h tools/perf/util/stat.c +1 more+50 -430 replies
12/22perf stat: Introduce perf_evsel__alloc_stats functiontools/perf/util/stat.c tools/perf/util/stat.h+16 -60 replies
13/22perf stat: Introduce perf_evsel__read functiontools/perf/util/evsel.c tools/perf/util/evsel.h+17 -00 replies
14/22perf stat: Introduce read_counters functiontools/perf/builtin-stat.c+22 -250 replies
15/22perf stat: Separate counters reading and processingtools/perf/builtin-stat.c+39 -170 replies
16/22perf stat: Move zero_per_pkg into counter process codetools/perf/builtin-stat.c+3 -30 replies
17/22perf stat: Move perf_stat initialization counter process codetools/perf/builtin-stat.c+1 -40 replies
18/22perf stat: Remove perf_evsel__read_cb functiontools/perf/util/evsel.c tools/perf/util/evsel.h+0 -230 replies
19/22perf stat: Rename print_interval to process_intervaltools/perf/builtin-stat.c+3 -30 replies
20/22perf stat: Using init_stats instead of memsettools/perf/builtin-stat.c+1 -10 replies
21/22perf stat: Introduce print_counters functiontools/perf/builtin-stat.c+64 -630 replies
22/22perf stat: Introduce --per-thread optiontools/perf/Documentation/perf-stat.txt tools/perf/builtin-stat.c tools/perf/util/stat.h+79 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCHv5 00/22] perf stat: Introduce --per-thread option

hi,
adding the possibility to display stat data per thread.

Allowing following commands and output:

  $ perf stat  -e cycles,instructions --per-thread -p 30190,30242
  ^C
   Performance counter stats for process id '30190,30242':
               cat-30190                     0      cycles
               yes-30242         3,842,525,421      cycles
               cat-30190                     0      instructions
               yes-30242        10,370,817,010      instructions
         1.143155657 seconds time elapsed

Also works under interval mode:

  $ perf stat  -e cycles,instructions --per-thread -p 30190,30242 -I 1000
  #           time             comm-pid                  counts unit events
       1.000073435              cat-30190                89,058      cycles
       1.000073435              yes-30242         3,360,786,902      cycles                     (100.00%)
       1.000073435              cat-30190                14,066      instructions
       1.000073435              yes-30242         9,069,937,462      instructions
       2.000204830              cat-30190                     0      cycles
       2.000204830              yes-30242         3,351,667,626      cycles
       2.000204830              cat-30190                     0      instructions
       2.000204830              yes-30242         9,045,796,885      instructions
  ^C     2.771286639              cat-30190                     0      cycles
       2.771286639              yes-30242         2,593,884,166      cycles
       2.771286639              cat-30190                     0      instructions
       2.771286639              yes-30242         7,001,171,191      instructions

Available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/per_thread

v5 changes:
- reading comms explicitly by thread_map__read_comms, so it gets read only within 'perf stat --per-thread'
- introducing thread_map__reset function
- several patches got accepted, rebased on latest perf/core

v4 changes:
- add thread_map__set_(pid|comm) interface
- several fixes for task comm string reading
- added perf_evlist__reset_stats function

v3 changes:
- some patches already pulled in, rebased on latest acme's perf/core
- fixed cpu_map__get/thread_map__get to accept NULL map
- renamed propagate_maps to perf_evlist__propagate_maps
- renamed --per-task option to --per-thread
- changed 'task-pid' header output to 'comm-pid'

v2 changes:
- renamed xyarray__zero to xyarray__reset
- using atomic_t for cpu_map/thread_map refcnt
- moving all stat functions into stat object
- using init_stats to initialize 'struct stats*'
- change TASK-$pid output into $comm-$pid
- updated doc with --per-task option

thanks,
jirka
---
Jiri Olsa (22):
perf thread_map: Introduce thread_map__reset function
perf tools: Add comm string into struct thread_map
perf tests: Add thread_map object tests
perf stat: Introduce perf_counts function
perf stat: Use xyarray for cpu evsel counts
perf stat: Make stats work over the thread dimension
perf stat: Rename struct perf_counts::cpu member to values perf stat: Introduce perf_evlist__reset_stats
perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into stat object perf stat: Move perf_evsel__(alloc|free)_prev_raw_counts into stat object perf stat: Move perf_evlist__(alloc|free|reset)_stats into stat object perf stat: Introduce perf_evsel__alloc_stats function
perf stat: Introduce perf_evsel__read function
perf stat: Introduce read_counters function
perf stat: Separate counters reading and processing
perf stat: Move zero_per_pkg into counter process code
perf stat: Move perf_stat initialization counter process code perf stat: Remove perf_evsel__read_cb function
perf stat: Rename print_interval to process_interval
perf stat: Using init_stats instead of memset
perf stat: Introduce print_counters function
perf stat: Introduce --per-thread option

 tools/perf/Documentation/perf-stat.txt     |   4 +
 tools/perf/builtin-stat.c                  | 402 +++++++++++++++++++++++++++++++------------------------------
 tools/perf/tests/Build                     |   1 +
 tools/perf/tests/builtin-test.c            |   4 +
 tools/perf/tests/openat-syscall-all-cpus.c |   6 +-
 tools/perf/tests/openat-syscall.c          |   4 +-
 tools/perf/tests/tests.h                   |   1 +
 tools/perf/tests/thread-map.c              |  38 ++++++
 tools/perf/util/evlist.h                   |   1 -
 tools/perf/util/evsel.c                    |  24 ++--
 tools/perf/util/evsel.h                    |  28 +----
 tools/perf/util/python-ext-sources         |   1 +
 tools/perf/util/stat.c                     | 132 ++++++++++++++++++--
 tools/perf/util/stat.h                     |  47 +++++++-
 tools/perf/util/thread_map.c               |  76 +++++++++++-
 tools/perf/util/thread_map.h               |   8 ++
 16 files changed, 523 insertions(+), 254 deletions(-)
 create mode 100644 tools/perf/tests/thread-map.c