Counting page fault per PID
Hi,
I have a question regarding perf tool usage. I would like to know which process caused how many page faults?
I ran these commands:
# perf stat -e faults -a -- sleep 4 & # find / -ls > /dev/null 2>&1 & # dd if=/dev/zero of=/dev/null bs=1M count=10K & Performance counter stats for 'system wide':
606 faults
3.994941053 seconds time elapsedThis tells me 606 page faults in total, but how to find out how many page faults did hit my two processes dd and find?
When I do this
# perf report -e faults -a -- sleep 4 & # find / -ls > /dev/null 2>&1 & 36033 # dd if=/dev/zero of=/dev/null bs=1M count=10K & 36034 sleep 4
Now I have a perf.data file and can check for PERF_RECORD_SAMPLE from pid 36033 and 36034? Is the number of sample entries for pid 36034 identical with the page faults?
PERF_RECORD_FORK(36034:36034):(36031:36031)PERF_RECORD_COMM: dd:36034/36034
...PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffbaa12d00 period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978cc4 period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978d02 period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba9768d2 period: 2 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba961550 period: 9 addr: 0
... thread: dd:36034
PERF_RECORD_EXIT(36034:36034):(36031:36031)
Since I detect 5 sample entries from dd command, I can attribute 5 page faults to the running dd command?
Thanks a lot.
Signature · 5 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzender des Aufsichtsrats: Gregor Pillen Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 46 lines · Thomas Richter
Hi,
I have a question regarding perf tool usage. I would like to know which process caused how many page faults?
I ran these commands:
# perf stat -e faults -a -- sleep 4 & # find / -ls > /dev/null 2>&1 & # dd if=/dev/zero of=/dev/null bs=1M count=10K & Performance counter stats for 'system wide':606 faults 3.994941053 seconds time elapsedThis tells me 606 page faults in total, but how to find out how many page faults did hit my two processes dd and find?
When I do this
# perf report -e faults -a -- sleep 4 & # find / -ls > /dev/null 2>&1 & 36033 # dd if=/dev/zero of=/dev/null bs=1M count=10K & 36034 sleep 4Now I have a perf.data file and can check for
PERF_RECORD_SAMPLEfrom pid 36033 and 36034? Is the number of sample entries for pid 36034 identical with the page faults?PERF_RECORD_FORK(36034:36034):(36031:36031)
PERF_RECORD_COMM: dd:36034/36034
...PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034:0x3ffbaa12d00period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034:0x3ffba978cc4period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034:0x3ffba978d02period: 1 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034:0x3ffba9768d2period: 2 addr: 0
... thread: dd:36034PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034:0x3ffba961550period: 9 addr: 0
... thread: dd:36034
PERF_RECORD_EXIT(36034:36034):(36031:36031)
Quoted 2 lines
Since I detect 5 sample entries from dd command, I can attribute 5 page faults to the running dd command?
yes, I think so.. with your test above, you can do following report:
[root@krava perf]# ./perf report -f -s overhead,period,pid -n --stdio # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 347 of event 'faults' # Event count (approx.): 21379 # # Overhead Samples Period Pid:Command # ........ ............ ............ ....................... # 65.55% 236 14015 711526:find 14.29% 31 3055 12445:Web Content 4.91% 5 1049 702453:MediaSu~isor #3 2.25% 8 480 702436:MediaSu~isor #1 2.18% 1 465 12608:TaskCon~ller #2 1.90% 9 407 702441:MediaSu~isor #2 1.65% 10 352 683724:Backgro~l #3843 1.28% 9 273 12231:GeckoMain 1.27% 1 272 12606:TaskCon~ller #0 1.21% 2 258 12463:Web Content 1.05% 3 224 711531:DOM Worker 0.69% 10 147 711528:sleep 0.29% 1 63 12611:TaskCon~ller #5 0.25% 1 53 12454:IPC I/O Child 0.22% 1 47 1:systemd 0.18% 5 38 711525:perf 0.16% 1 35 12609:TaskCon~ller #3 0.15% 2 31 12627:TaskCon~ller #2 0.12% 1 25 11684:Xorg 0.11% 1 23 12363:IPDL Background 0.10% 2 21 706434:MediaSu~isor #4 0.09% 1 19 13129:TaskCon~ller #7 0.07% 1 14 12466:ImageIO 0.06% 5 13 711527:dd
now I'm not sure how we map period for fault event, I thought it's 1:1 to number of samples, but apparently not ;-)
jirka