linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: Re: Counting page fault per PID
Date: Fri, 12 Nov 2021 10:57:13 +0100	[thread overview]
Message-ID: <YY4544YTnnajizhk@krava> (raw)
In-Reply-To: <13ec9620-dbd6-a8a9-b51d-46aaec764351@linux.ibm.com>

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


      reply	other threads:[~2021-11-12  9:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12  9:30 Counting page fault per PID Thomas Richter
2021-11-12  9:57 ` Jiri Olsa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YY4544YTnnajizhk@krava \
    --to=jolsa@redhat.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).