xref: /aosp_15_r20/external/bcc/tools/ppchcalls_example.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1Demonstrations of ppchcalls, the Linux/eBPF version.
2
3
4ppchcalls summarizes hcall counts across the system or a specific process,
5with optional latency information. It is very useful for general workload
6characterization, for example:
7
8# ./ppchcalls.py
9Tracing ppc hcalls, printing top 10... Ctrl+C to quit.
10^C[04:59:47]
11PPC HCALL                                        COUNT
12H_IPI                                               26
13H_EOI                                               22
14H_XIRR                                              22
15H_VIO_SIGNAL                                         4
16H_REMOVE                                             3
17H_PUT_TCE                                            2
18H_SEND_CRQ                                           2
19H_STUFF_TCE                                          2
20H_ENTER                                              1
21H_PROTECT                                            1
22
23Detaching...
24#
25
26These are the top 10 entries; you can get more by using the -T switch. Here,
27the output indicates that the H_IPI, H_EOI and H_XIRR hcalls were very common,
28followed immediately by H_VIO_SIGNAL, H_REMOVE and so on. By default, ppchcalls
29counts across the entire system, but we can point it to a specific process of
30interest:
31
32# ./ppchcalls.py -p $(pidof vim)
33Tracing ppc hcalls, printing top 10... Ctrl+C to quit.
34^C[06:23:12]
35PPC HCALL                                        COUNT
36H_PUT_TERM_CHAR                                     62
37H_ENTER                                              2
38
39Detaching...
40#
41
42
43Occasionally, the count of hcalls is not enough, and you'd also want to know
44the minimum, maximum and aggregate latency for each of the hcalls:
45
46# ./ppchcalls.py -L
47Tracing ppc hcalls, printing top 10... Ctrl+C to quit.
48[00:53:59]
49PPC HCALL                                        COUNT          MIN (us)          MAX (us)          AVG (us)
50H_IPI                                               32             0.808             7.730             2.329
51H_EOI                                               25             0.697             1.984             1.081
52H_PUT_TERM_CHAR                                     25            10.315            47.184            14.667
53H_XIRR                                              25             0.868             6.223             2.397
54H_VIO_SIGNAL                                         6             1.418            22.053             7.507
55H_STUFF_TCE                                          3             0.865             2.349             1.384
56H_SEND_CRQ                                           3            18.015            21.137            19.673
57H_REMOVE                                             3             1.838             7.407             3.735
58H_PUT_TCE                                            3             1.473             4.808             2.698
59H_GET_TERM_CHAR                                      2             8.379            26.729            17.554
60
61Detaching...
62#
63
64Another direction would be to understand which processes are making a lot of
65hcalls, thus responsible for a lot of activity. This is what the -P switch
66does:
67
68# ./ppchcalls.py -P
69Tracing ppc hcalls, printing top 10... Ctrl+C to quit.
70^C[04:07:39]
71PID    COMM                                      COUNT
7214118  top                                        1073
730      [unknown]                                   286
741679   bash                                         67
7514111  kworker/12:0-events_freezable_power_         12
762      kthreadd                                      4
7711753  kworker/0:0-events                            4
78141    kworker/21:0H-xfs-log/dm-0                    3
79847    systemd-udevd                                 3
8014116  ppchcalls.py                                  3
8113368  kworker/u64:1-events_unbound                  3
82
83Detaching...
84#
85
86Sometimes, you'd want both, the process making the most hcalls and respective
87process-wide latencies. All you need to do is combine both options:
88
89# ./ppchcalls.py -P -L
90Tracing ppc hcalls, printing top 10... Ctrl+C to quit.
91^C[04:35:27]
92PID    COMM                                      COUNT          MIN (us)          MAX (us)          AVG (us)
930      [unknown]                                    69             0.666            13.059             2.834
9414151  kworker/12:1-events_freezable_power_          8             6.489            84.470            34.354
9511753  kworker/0:0-events                            4             1.415             2.059             1.784
9614152  kworker/u64:0-events_unbound                  2             2.402             2.935             2.668
9714154  ppchcalls.py                                  2             3.139            11.934             7.537
981751   sshd                                          1             7.227             7.227             7.227
993413   kworker/6:2-mm_percpu_wq                      1             6.775             6.775             6.775
100
101Detaching...
102#
103
104Sometimes, you'd only care about a single hcall rather than all hcalls.
105Use the --hcall option for this; the following example also demonstrates
106the --hcall option, for printing at predefined intervals:
107
108# ./ppchcalls.py --hcall H_VIO_SIGNAL -i 5
109hcall H_VIO_SIGNAL , hcall_nr =260
110Tracing ppc hcall 'H_VIO_SIGNAL'... Ctrl+C to quit.
111[04:29:56]
112PPC HCALL                                        COUNT
113H_VIO_SIGNAL                                         6
114
115[04:30:01]
116PPC HCALL                                        COUNT
117H_VIO_SIGNAL                                         4
118
119[04:30:06]
120PPC HCALL                                        COUNT
121H_VIO_SIGNAL                                         6
122
123[04:30:07]
124PPC HCALL                                        COUNT
125
126Detaching...
127#
128
129USAGE:
130# ./ppchcalls.py -h
131usage: ppchcalls.py [-h] [-p PID] [-t TID] [-i INTERVAL] [-d DURATION]
132                    [-T TOP] [-x] [-e ERRNO] [-L] [-m] [-P] [-l]
133                    [--hcall HCALL]
134
135Summarize ppc hcall counts and latencies.
136
137optional arguments:
138  -h, --help            show this help message and exit
139  -p PID, --pid PID     trace only this pid
140  -t TID, --tid TID     trace only this tid
141  -i INTERVAL, --interval INTERVAL
142                        print summary at this interval (seconds)
143  -d DURATION, --duration DURATION
144                        total duration of trace, in seconds
145  -T TOP, --top TOP     print only the top hcalls by count or latency
146  -x, --failures        trace only failed hcalls (return < 0)
147  -e ERRNO, --errno ERRNO
148                        trace only hcalls that return this error (numeric or
149                        EPERM, etc.)
150  -L, --latency         collect hcall latency
151  -m, --milliseconds    display latency in milliseconds (default:
152                        microseconds)
153  -P, --process         count by process and not by hcall
154  -l, --list            print list of recognized hcalls and exit
155  --hcall HCALL         trace this hcall only (use option -l to get all
156                        recognized hcalls)
157#
158
159Ref: https://docs.kernel.org/powerpc/papr_hcalls.html
160