[PATCH v2 0/4] perf trace: Add --summary-mode option

Namhyung Kim posted 4 patches 1 year, 3 months ago
There is a newer version of this series
tools/perf/Documentation/perf-trace.txt |   4 +
tools/perf/builtin-trace.c              | 252 +++++++++++++++++++-----
tools/perf/util/rb_resort.h             | 146 --------------
3 files changed, 208 insertions(+), 194 deletions(-)
delete mode 100644 tools/perf/util/rb_resort.h
[PATCH v2 0/4] perf trace: Add --summary-mode option
Posted by Namhyung Kim 1 year, 3 months ago
Hello,

I've realized that perf trace shows system call summary at the end for
each thread.  But sometimes users want to see the global whole system
summary or statistics instead.

So I've added --summary-mode option like below:

    $ sudo ./perf trace -as --summary-mode=total sleep 1

     Summary of events:

     total, 21580 events

       syscall            calls  errors  total       min       avg       max       stddev
                                         (msec)    (msec)    (msec)    (msec)        (%)
       --------------- --------  ------ -------- --------- --------- ---------     ------
       epoll_wait          1305      0 14716.712     0.000    11.277   551.529      8.87%
       futex               1256     89 13331.197     0.000    10.614   733.722     15.49%
       poll                 669      0  6806.618     0.000    10.174   459.316     11.77%
       ppoll                220      0  3968.797     0.000    18.040   516.775     25.35%
       clock_nanosleep        1      0  1000.027  1000.027  1000.027  1000.027      0.00%
       epoll_pwait           21      0   592.783     0.000    28.228   522.293     88.29%
       nanosleep             16      0    60.515     0.000     3.782    10.123     33.33%
       ioctl                510      0     4.284     0.001     0.008     0.182      8.84%
       recvmsg             1434    775     3.497     0.001     0.002     0.174      6.37%
       write               1393      0     2.854     0.001     0.002     0.017      1.79%
       read                1063    100     2.236     0.000     0.002     0.083      5.11%
       ...

Also it changes internal data structure to hash table to track
statistics of syscalls.  And removes the rb_resort code.

v2 changes)
* Rebase to current perf-tools-next
* Fix some style issues  (Howard)
* Rename to --summary-mode  (Howard)

Thanks,
Namhyung


Namhyung Kim (4):
  perf trace: Allocate syscall stats only if summary is on
  perf trace: Convert syscall_stats to hashmap
  perf tools: Get rid of now-unused rb_resort.h
  perf trace: Add --summary-mode option

 tools/perf/Documentation/perf-trace.txt |   4 +
 tools/perf/builtin-trace.c              | 252 +++++++++++++++++++-----
 tools/perf/util/rb_resort.h             | 146 --------------
 3 files changed, 208 insertions(+), 194 deletions(-)
 delete mode 100644 tools/perf/util/rb_resort.h

-- 
2.48.1.262.g85cc9f2d1e-goog
Re: [PATCH v2 0/4] perf trace: Add --summary-mode option
Posted by Howard Chu 1 year, 3 months ago
Hello Namhyung,

On Wed, Jan 29, 2025 at 7:05 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> I've realized that perf trace shows system call summary at the end for
> each thread.  But sometimes users want to see the global whole system
> summary or statistics instead.
>
> So I've added --summary-mode option like below:
>
>     $ sudo ./perf trace -as --summary-mode=total sleep 1
>
>      Summary of events:
>
>      total, 21580 events
>
>        syscall            calls  errors  total       min       avg       max       stddev
>                                          (msec)    (msec)    (msec)    (msec)        (%)
>        --------------- --------  ------ -------- --------- --------- ---------     ------
>        epoll_wait          1305      0 14716.712     0.000    11.277   551.529      8.87%
>        futex               1256     89 13331.197     0.000    10.614   733.722     15.49%
>        poll                 669      0  6806.618     0.000    10.174   459.316     11.77%
>        ppoll                220      0  3968.797     0.000    18.040   516.775     25.35%
>        clock_nanosleep        1      0  1000.027  1000.027  1000.027  1000.027      0.00%
>        epoll_pwait           21      0   592.783     0.000    28.228   522.293     88.29%
>        nanosleep             16      0    60.515     0.000     3.782    10.123     33.33%
>        ioctl                510      0     4.284     0.001     0.008     0.182      8.84%
>        recvmsg             1434    775     3.497     0.001     0.002     0.174      6.37%
>        write               1393      0     2.854     0.001     0.002     0.017      1.79%
>        read                1063    100     2.236     0.000     0.002     0.083      5.11%
>        ...
>
> Also it changes internal data structure to hash table to track
> statistics of syscalls.  And removes the rb_resort code.
>
> v2 changes)
> * Rebase to current perf-tools-next
> * Fix some style issues  (Howard)
> * Rename to --summary-mode  (Howard)

perf $ sudo ./perf trace -s -C 0 --summary-mode=total
^C
 Summary of events:

 total, 185 events

   syscall            calls  errors  total       min       avg
max       stddev
                                     (msec)    (msec)    (msec)
(msec)        (%)
   --------------- --------  ------ -------- --------- ---------
---------     ------
   ppoll                 29      0   188.684     0.000     6.506
62.504     54.91%
   read                  20      0     0.415     0.002     0.021
0.345     82.16%
   write                 24      0     0.085     0.001     0.004
0.012     12.09%
   sendmsg                4      0     0.039     0.005     0.010
0.014     24.12%
   recvmsg                8      0     0.034     0.003     0.004
0.005      4.81%
   poll                   8      0     0.020     0.002     0.003
0.003      8.96%

The new option is working as expected, thank you.

Acked-by: Howard Chu <howardchu95@gmail.com>

Thanks,
Howard
>
> Thanks,
> Namhyung
>
>
> Namhyung Kim (4):
>   perf trace: Allocate syscall stats only if summary is on
>   perf trace: Convert syscall_stats to hashmap
>   perf tools: Get rid of now-unused rb_resort.h
>   perf trace: Add --summary-mode option
>
>  tools/perf/Documentation/perf-trace.txt |   4 +
>  tools/perf/builtin-trace.c              | 252 +++++++++++++++++++-----
>  tools/perf/util/rb_resort.h             | 146 --------------
>  3 files changed, 208 insertions(+), 194 deletions(-)
>  delete mode 100644 tools/perf/util/rb_resort.h
>
> --
> 2.48.1.262.g85cc9f2d1e-goog
>