All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Ian Rogers <irogers@google.com>, Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: linux-perf-users <linux-perf-users@vger.kernel.org>,
	Weilin Wang <weilin.wang@intel.com>
Subject: Re: Leader sampling and topdown events
Date: Mon, 7 Apr 2025 14:51:15 -0400	[thread overview]
Message-ID: <1b35658f-da59-4939-8b6a-110f445abcf3@linux.intel.com> (raw)
In-Reply-To: <CAP-5=fX=hnn7egfAj+gyBeQAo24CQ1_mb7Dx-NfWaue8NMugnA@mail.gmail.com>



On 2025-04-07 2:23 p.m., Ian Rogers wrote:
> Hi,
> 
> I'm trying to understand why the following succeeds:
> ```
> $ perf record -e '{slots,instructions,topdown-retiring}:S' -a sleep 0.1
> WARNING: events were regrouped to match PMUs
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 3.077 MB perf.data (496 samples) ]
> ```
> As per the test case in:
> https://lore.kernel.org/all/20240913084712.13861-6-dapeng1.mi@linux.intel.com/
> But without the instructions event it fails:
> ```
> $ perf record -e '{slots,topdown-retiring}:S' -a sleep 0.1
> WARNING: events were regrouped to match PMUs
> Error:
> The sys_perf_event_open() syscall returned with 22 (Invalid argument)
> for event (cpu_core/topdown-retiring/).
> "dmesg | grep -i perf" may provide additional information.
> ```
> With the (not merged) patch:
> https://lore.kernel.org/lkml/20250402201549.4090305-6-irogers@google.com/
> The groups being programmed are:
> ```
> $ perf record -v -e '{slots,topdown-retiring}:S' -a sleep 0.1
> Using CPUID GenuineIntel-6-B7-1
> slots -> cpu_core/slots/
> topdown-retiring -> cpu_atom/topdown-retiring/
> topdown-retiring -> cpu_core/topdown-retiring/
> WARNING: events were regrouped to match PMUs
> evlist after sorting/fixing:
> 'cpu_atom/topdown-retiring/,{cpu_core/slots/,cpu_core/topdown-retiring/}'
> DEBUGINFOD_URLS=
> nr_cblocks: 0
> affinity: SYS
> mmap flush: 1
> comp level: 0
> Error:
> The sys_perf_event_open() syscall returned with 22 (Invalid argument)
> for event (cpu_core/topdown-retiring/).
> "dmesg | grep -i perf" may provide additional information.
> ```
> Given we only want to read the topdown-retiring event with leader
> sampling, what's the significance of the instructions event? `perf
> stat` doesn't require it.
> 

For p-core, the PERF_METRICS counter is not a regular counter. It's a
combination of fractions for topdown events. The slots event is required
to calculate the topdown events. The PERF_METRICS and slots must be
synchronized (start from 0 at the same time). So we cannot use the slots
for sampling. There must be an auxiliary event for sampling, e.g.,
instructions in this case.

The slots must be the first event of a topdown group. So the auxiliary
event needs to be the second event.

Thanks,
Kan


      reply	other threads:[~2025-04-07 18:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 18:23 Leader sampling and topdown events Ian Rogers
2025-04-07 18:51 ` Liang, Kan [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=1b35658f-da59-4939-8b6a-110f445abcf3@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=weilin.wang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.