linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>,
	Ian Rogers <irogers@google.com>
Subject: Re: perf record question regarding grouped events
Date: Mon, 24 Feb 2025 15:57:07 -0800	[thread overview]
Message-ID: <Z70HU3obg1ZHeutj@google.com> (raw)
In-Reply-To: <e2c7e654-5608-4206-ab3a-2a63b54cbc35@linux.ibm.com>

Hello,

On Wed, Feb 19, 2025 at 11:57:46AM +0100, Thomas Richter wrote:
> Hi all,
> 
> I have a question on the intended usage of the grouped events as
> in test case 114 perf record tests subtest 'Basic leader sampling' test
> where this command is executed:
> 
>  # perf record -vv -e '{cycles,cycles}:uS' -- ...
> 
> In the debug output the following 2 event are installed:
> 
>  ------------------------------------------------------------
>  perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   size                             136
>   config                           0 (PERF_COUNT_HW_CPU_CYCLES)
>   { sample_period, sample_freq }   4000
>   sample_type                      IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER
>   read_format                      ID|GROUP|LOST
>   disabled                         1
>   exclude_kernel                   1
>   exclude_hv                       1
>   freq                             1
>   sample_id_all                    1
>  ------------------------------------------------------------
>  sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
>  ------------------------------------------------------------
>  perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   size                             136
>   config                           0 (PERF_COUNT_HW_CPU_CYCLES)
>   sample_type                      IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER
>   read_format                      ID|GROUP|LOST
>   exclude_kernel                   1
>   exclude_hv                       1
>   sample_id_all                    1
>  ------------------------------------------------------------
>  sys_perf_event_open: pid -1  cpu 0  group_fd 5  flags 0x8 = 6
> 
> What puzzles me is that the first event with file descriptor 5
> is installed for sampling. The second event with file descriptor 6
> is installed for counting because event attribute members
> attr::freq and attr::sample_freq are zero.
> 
> So of the 2 cycles events installed, the group leader is sampling
> and the other event is counting.
> 
> Is this understanding correct?
> The test then checks if the number of samples matches the count
> from the counting event?

Yep, the syntax '{event1,event2}:S' is for group leader sampling which
reduces the overhead of PMU interrupts.  The idea is that those events
are scheduled together so sampling is enabled only for the leader
(usually the first) event and it reads counts from the member events
using PERF_SAMPLE_READ.

So they should have the same counts if it uses the same events in a
group.

Thanks,
Namhyung

 
> Thanks a lot for your help.
> 
> -- 
> Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> --
> IBM Deutschland Research & Development GmbH
> 
> Vorsitzender des Aufsichtsrats: Wolfgang Wendt
> 
> Geschäftsführung: David Faller
> 
> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
> 

      reply	other threads:[~2025-02-24 23:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 10:57 perf record question regarding grouped events Thomas Richter
2025-02-24 23:57 ` Namhyung Kim [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=Z70HU3obg1ZHeutj@google.com \
    --to=namhyung@kernel.org \
    --cc=irogers@google.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).