xref: /aosp_15_r20/external/bcc/tools/llcstat_example.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1Demonstrations of llcstat.
2
3
4llcstat traces cache reference and cache miss events system-wide, and summarizes
5them by PID and CPU.
6
7These events, defined in uapi/linux/perf_event.h, have different meanings on
8different architecture. For x86-64, they mean misses and references to LLC.
9
10Example output:
11
12# ./llcstat.py 20 -c 5000
13Running for 20 seconds or hit Ctrl-C to end.
14PID      NAME             CPU     REFERENCE         MISS   HIT%
150        swapper/15       15        3515000       640000  81.79%
16238      migration/38     38           5000            0 100.00%
174512     ntpd             11           5000            0 100.00%
18150867   ipmitool         3           25000         5000  80.00%
19150895   lscpu            17         280000        25000  91.07%
20151807   ipmitool         15          15000         5000  66.67%
21150757   awk              2           15000         5000  66.67%
22151213   chef-client      5         1770000       240000  86.44%
23151822   scribe-dispatch  12          15000            0 100.00%
24123386   mysqld           5            5000            0 100.00%
25[...]
26Total References: 518920000 Total Misses: 90265000 Hit Rate: 82.61%
27
28This shows each PID's cache hit rate during the 20 seconds run period.
29
30A count of 5000 was used in this example, which means that one in every 5,000
31events will trigger an in-kernel counter to be incremented. This is refactored
32on the output, which is why it is always in multiples of 5,000.
33
34We don't instrument every single event since the overhead would be prohibitive,
35nor do we need to: this is a type of sampling profiler. Because of this, the
36processes that trigger the 5,000'th cache reference or misses can happen to
37some degree by chance. Overall it should make sense. But for low counts,
38you might find a case where -- by chance -- a process has been tallied with
39more misses than references, which would seem impossible.
40
41# ./llcstat.py 10 -t
42Running for 10 seconds or hit Ctrl-C to end.
43PID      TID      NAME             CPU     REFERENCE         MISS    HIT%
44170843   170845   docker           12           2700         1200  55.56%
45298670   298670   kworker/15:0     15            500            0 100.00%
46170254   170254   kworker/11:1     11           2500          400  84.00%
471046952  1046953  git              0            2600         1100  57.69%
48170843   170849   docker           15           1000          400  60.00%
491027373  1027382  node             8            3500         2500  28.57%
500        0        swapper/7        7          173000         4200  97.57%
511028217  1028217  node             14          15600        22400   0.00%
52[...]
53Total References: 7139900 Total Misses: 1413900 Hit Rate: 80.20%
54
55This shows each TID`s cache hit rate during the 10 seconds run period.
56
57USAGE message:
58
59# ./llcstat.py --help
60usage: llcstat.py [-h] [-c SAMPLE_PERIOD] [duration]
61
62Summarize cache references and misses by PID
63
64positional arguments:
65  duration                Duration, in seconds, to run
66
67  optional arguments:
68    -h, --help            show this help message and exit
69    -c SAMPLE_PERIOD, --sample_period SAMPLE_PERIOD
70                          Sample one in this many number of cache reference
71                          and miss events
72    -t, --tid             Summarize cache references and misses by PID/TID
73