* Counting page fault per PID
@ 2021-11-12 9:30 Thomas Richter
2021-11-12 9:57 ` Jiri Olsa
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Richter @ 2021-11-12 9:30 UTC (permalink / raw)
To: linux-perf-use.
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 elapsed
This 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:36034
PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978cc4 period: 1 addr: 0
... thread: dd:36034
PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978d02 period: 1 addr: 0
... thread: dd:36034
PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba9768d2 period: 2 addr: 0
... thread: dd:36034
PERF_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.
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Counting page fault per PID
2021-11-12 9:30 Counting page fault per PID Thomas Richter
@ 2021-11-12 9:57 ` Jiri Olsa
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2021-11-12 9:57 UTC (permalink / raw)
To: Thomas Richter; +Cc: linux-perf-use.
On Fri, Nov 12, 2021 at 10:30:33AM +0100, Thomas Richter wrote:
> 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 elapsed
>
> This 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:36034
> PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978cc4 period: 1 addr: 0
> ... thread: dd:36034
> PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba978d02 period: 1 addr: 0
> ... thread: dd:36034
> PERF_RECORD_SAMPLE(IP, 0x2): 36034/36034: 0x3ffba9768d2 period: 2 addr: 0
> ... thread: dd:36034
> PERF_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?
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-12 9:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-12 9:30 Counting page fault per PID Thomas Richter
2021-11-12 9:57 ` Jiri Olsa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).