linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qiao Zhao <qzhao@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	 Athira Rajeev <atrajeev@linux.ibm.com>,
	Chun-Tse Shao <ctshao@google.com>,
	 James Clark <james.clark@linaro.org>,
	Howard Chu <howardchu95@gmail.com>,
	 linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 3/3] perf test: Avoid uncore_imc/clockticks in uniquification test
Date: Sun, 28 Sep 2025 19:39:23 -0700	[thread overview]
Message-ID: <CAATMXfkcWT+SP0eu9By2VdnLoHY8PdCFWa9MwTNzHMZ7t2UB_Q@mail.gmail.com> (raw)
In-Reply-To: <CAP-5=fWb5R3Gu+01Qr0+fu7n=RL8hs2b-timZKzqnATa+DRMyw@mail.gmail.com>

Hi Ian,

Cool! After applied your patch "[PATCH v2 2/3] perf evsel: Fix
uniquification when PMU given without suffix" and  "[PATCH v2 3/3]
perf test: Avoid uncore_imc/clockticks in uniquification test",
the uniquifying testing passed on both Intel hybrid and non-hybrid machine:

hybrid CPU machine:
>>>>>>>>>>>>>>>>>>
# ./perf test -vv 96
 96: perf stat events uniquifying:
--- start ---
test child forked, pid 40541
Uniquification of PMU sysfs events test
Testing event uncore_imc_free_running/data_read/ is uniquified to
uncore_imc_free_running_0/data_read/
Testing event uncore_imc_free_running/data_total/ is uniquified to
uncore_imc_free_running_0/data_total/
Testing event uncore_imc_free_running/data_write/ is uniquified to
uncore_imc_free_running_0/data_write/
Testing event uncore_imc_free_running/data_read/ is uniquified to
uncore_imc_free_running_1/data_read/
Testing event uncore_imc_free_running/data_total/ is uniquified to
uncore_imc_free_running_1/data_total/
Testing event uncore_imc_free_running/data_write/ is uniquified to
uncore_imc_free_running_1/data_write/
---- end(0) ----
 96: perf stat events uniquifying                                    : Ok
>>>>>>>>>>>>>>>>>>

non-hybrid CPU machine:
>>>>>>>>>>>>>>>>>>
# ./perf test -vv 96
 96: perf stat events uniquifying:
--- start ---
test child forked, pid 114458
Uniquification of PMU sysfs events test
Testing event uncore_iio_free_running/bw_in_port0/ is uniquified to
uncore_iio_free_running_0/bw_in_port0/
Testing event uncore_iio_free_running/bw_in_port1/ is uniquified to
uncore_iio_free_running_0/bw_in_port1/
Testing event uncore_iio_free_running/bw_in_port2/ is uniquified to
uncore_iio_free_running_0/bw_in_port2/
Testing event uncore_iio_free_running/bw_in_port3/ is uniquified to
uncore_iio_free_running_0/bw_in_port3/
Testing event uncore_iio_free_running/bw_in_port4/ is uniquified to
uncore_iio_free_running_0/bw_in_port4/
Testing event uncore_iio_free_running/bw_in_port5/ is uniquified to
uncore_iio_free_running_0/bw_in_port5/
Testing event uncore_iio_free_running/bw_in_port6/ is uniquified to
uncore_iio_free_running_0/bw_in_port6/
Testing event uncore_iio_free_running/bw_in_port7/ is uniquified to
uncore_iio_free_running_0/bw_in_port7/
Testing event uncore_iio_free_running/ioclk/ is uniquified to
uncore_iio_free_running_0/ioclk/
... ...
Testing event uncore_imc_free_running/dclk/ is uniquified to
uncore_imc_free_running_0/dclk/
Testing event uncore_imc_free_running/rpq_cycles/ is uniquified to
uncore_imc_free_running_0/rpq_cycles/
Testing event uncore_imc_free_running/wpq_cycles/ is uniquified to
uncore_imc_free_running_0/wpq_cycles/
Testing event uncore_imc_free_running/dclk/ is uniquified to
uncore_imc_free_running_1/dclk/
Testing event uncore_imc_free_running/rpq_cycles/ is uniquified to
uncore_imc_free_running_1/rpq_cycles/
Testing event uncore_imc_free_running/wpq_cycles/ is uniquified to
uncore_imc_free_running_1/wpq_cycles/
Testing event uncore_imc_free_running/dclk/ is uniquified to
uncore_imc_free_running_2/dclk/
Testing event uncore_imc_free_running/rpq_cycles/ is uniquified to
uncore_imc_free_running_2/rpq_cycles/
Testing event uncore_imc_free_running/wpq_cycles/ is uniquified to
uncore_imc_free_running_2/wpq_cycles/
Testing event uncore_imc_free_running/dclk/ is uniquified to
uncore_imc_free_running_3/dclk/
Testing event uncore_imc_free_running/rpq_cycles/ is uniquified to
uncore_imc_free_running_3/rpq_cycles/
Testing event uncore_imc_free_running/wpq_cycles/ is uniquified to
uncore_imc_free_running_3/wpq_cycles/
---- end(0) ----
 96: perf stat events uniquifying                                    : Ok
>>>>>>>>>>>>>>>>>>

Tested-by: Qiao Zhao <qzhao@redhat.com>

On Fri, Sep 26, 2025 at 9:22 AM Ian Rogers <irogers@google.com> wrote:
>
> On Fri, Sep 26, 2025 at 2:00 AM Qiao Zhao <qzhao@redhat.com> wrote:
> >
> > Hi Ian,
> >
> > I tested your patch (latest linux-next code + your patch) on hybrid
> > CPU machine {CPU Model name: 12th Gen Intel(R) Core(TM) i7-12800HE}
> > and failed,
>
> Hi Qiao,
>
> in your output is:
> uncore_imc_free_running_0/uncore_imc_free_running,data_total/
> ie the uncore PMU is reported twice. This is fixed in the immediately
> prior patch in this series:
> https://lore.kernel.org/lkml/20250918222202.1353854-3-irogers@google.com/
>
> Thanks,
> Ian
>
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > # perf test -vv "perf stat events uniquifying"
> >  95: perf stat events uniquifying:
> > --- start ---
> > test child forked, pid 21799
> > Uniquification of PMU sysfs events test
> > Testing event uncore_imc_free_running/data_read/ is uniquified to
> > uncore_imc_free_running_0/data_read/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 1.47 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_read/
> > CPU0                 1.47 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_read/
> >
> >        0.000925108 seconds time elapsed
> >
> > Testing event uncore_imc_free_running/data_total/ is uniquified to
> > uncore_imc_free_running_0/data_total/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 0.59 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_total/
> > CPU0                 0.58 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_total/
> >
> >        0.000969877 seconds time elapsed
> >
> > Testing event uncore_imc_free_running/data_write/ is uniquified to
> > uncore_imc_free_running_0/data_write/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 0.00 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_write/
> > CPU0                 0.00 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_write/
> >
> >        0.001183888 seconds time elapsed
> >
> > Testing event uncore_imc_free_running/data_read/ is uniquified to
> > uncore_imc_free_running_1/data_read/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 0.29 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_read/
> > CPU0                 0.29 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_read/
> >
> >        0.000710088 seconds time elapsed
> >
> > Testing event uncore_imc_free_running/data_total/ is uniquified to
> > uncore_imc_free_running_1/data_total/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 0.62 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_total/
> > CPU0                 0.67 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_total/
> >
> >        0.000959074 seconds time elapsed
> >
> > Testing event uncore_imc_free_running/data_write/ is uniquified to
> > uncore_imc_free_running_1/data_write/
> > Uniquification of PMU sysfs events test [Failed]
> > # started on Fri Sep 26 04:49:54 2025
> >
> >
> >  Performance counter stats for 'system wide':
> >
> > CPU0                 0.23 MiB
> > uncore_imc_free_running_0/uncore_imc_free_running,data_write/
> > CPU0                 0.23 MiB
> > uncore_imc_free_running_1/uncore_imc_free_running,data_write/
> >
> >        0.000775028 seconds time elapsed
> >
> > ---- end(-1) ----
> >  95: perf stat events uniquifying                                    : FAILED!
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > # ls -la /sys/bus/event_source/devices/uncore_imc_free_running_*/events/
> > /sys/bus/event_source/devices/uncore_imc_free_running_0/events/:
> > total 0
> > drwxr-xr-x. 2 root root    0 Sep 26 04:57 .
> > drwxr-xr-x. 5 root root    0 Sep 26 01:49 ..
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read.unit
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total.unit
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write.unit
> >
> > /sys/bus/event_source/devices/uncore_imc_free_running_1/events/:
> > total 0
> > drwxr-xr-x. 2 root root    0 Sep 26 04:57 .
> > drwxr-xr-x. 5 root root    0 Sep 26 01:49 ..
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_read.unit
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_total.unit
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write.scale
> > -r--r--r--. 1 root root 4096 Sep 26 01:49 data_write.unit
> >
> > - Qiao
> >
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> >
> >
> > On Fri, Sep 19, 2025 at 6:22 AM Ian Rogers <irogers@google.com> wrote:
> > >
> > > The detection of uncore_imc may happen for free running PMUs and the
> > > clockticks event may be present on uncore_clock. Rewrite the test to
> > > detect duplicated/deduplicated events from perf list, not hardcoded to
> > > uncore_imc.
> > >
> > > If perf stat fails then assume it is permissions and skip the test.
> > >
> > > Fixes: 070b315333ee ("perf test: Restrict uniquifying test to machines with 'uncore_imc'")
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > >  .../tests/shell/stat+event_uniquifying.sh     | 109 ++++++++----------
> > >  1 file changed, 49 insertions(+), 60 deletions(-)
> > >
> > > diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > > index bf54bd6c3e2e..b5dec6b6da36 100755
> > > --- a/tools/perf/tests/shell/stat+event_uniquifying.sh
> > > +++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > > @@ -4,74 +4,63 @@
> > >
> > >  set -e
> > >
> > > -stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
> > > -perf_tool=perf
> > >  err=0
> > > +stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
> > >
> > > -test_event_uniquifying() {
> > > -  # We use `clockticks` in `uncore_imc` to verify the uniquify behavior.
> > > -  pmu="uncore_imc"
> > > -  event="clockticks"
> > > -
> > > -  # If the `-A` option is added, the event should be uniquified.
> > > -  #
> > > -  # $perf list -v clockticks
> > > -  #
> > > -  # List of pre-defined events (to be used in -e or -M):
> > > -  #
> > > -  #   uncore_imc_0/clockticks/                           [Kernel PMU event]
> > > -  #   uncore_imc_1/clockticks/                           [Kernel PMU event]
> > > -  #   uncore_imc_2/clockticks/                           [Kernel PMU event]
> > > -  #   uncore_imc_3/clockticks/                           [Kernel PMU event]
> > > -  #   uncore_imc_4/clockticks/                           [Kernel PMU event]
> > > -  #   uncore_imc_5/clockticks/                           [Kernel PMU event]
> > > -  #
> > > -  #   ...
> > > -  #
> > > -  # $perf stat -e clockticks -A -- true
> > > -  #
> > > -  #  Performance counter stats for 'system wide':
> > > -  #
> > > -  # CPU0            3,773,018      uncore_imc_0/clockticks/
> > > -  # CPU0            3,609,025      uncore_imc_1/clockticks/
> > > -  # CPU0                    0      uncore_imc_2/clockticks/
> > > -  # CPU0            3,230,009      uncore_imc_3/clockticks/
> > > -  # CPU0            3,049,897      uncore_imc_4/clockticks/
> > > -  # CPU0                    0      uncore_imc_5/clockticks/
> > > -  #
> > > -  #        0.002029828 seconds time elapsed
> > > -
> > > -  echo "stat event uniquifying test"
> > > -  uniquified_event_array=()
> > > +cleanup() {
> > > +  rm -f "${stat_output}"
> > >
> > > -  # Skip if the machine does not have `uncore_imc` device.
> > > -  if ! ${perf_tool} list pmu | grep -q ${pmu}; then
> > > -    echo "Target does not support PMU ${pmu} [Skipped]"
> > > -    err=2
> > > -    return
> > > -  fi
> > > +  trap - EXIT TERM INT
> > > +}
> > >
> > > -  # Check how many uniquified events.
> > > -  while IFS= read -r line; do
> > > -    uniquified_event=$(echo "$line" | awk '{print $1}')
> > > -    uniquified_event_array+=("${uniquified_event}")
> > > -  done < <(${perf_tool} list -v ${event} | grep ${pmu})
> > > +trap_cleanup() {
> > > +  echo "Unexpected signal in ${FUNCNAME[1]}"
> > > +  cleanup
> > > +  exit 1
> > > +}
> > > +trap trap_cleanup EXIT TERM INT
> > >
> > > -  perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
> > > -  $perf_command
> > > +test_event_uniquifying() {
> > > +  echo "Uniquification of PMU sysfs events test"
> > >
> > > -  # Check the output contains all uniquified events.
> > > -  for uniquified_event in "${uniquified_event_array[@]}"; do
> > > -    if ! cat "${stat_output}" | grep -q "${uniquified_event}"; then
> > > -      echo "Event is not uniquified [Failed]"
> > > -      echo "${perf_command}"
> > > -      cat "${stat_output}"
> > > -      err=1
> > > -      break
> > > -    fi
> > > +  # Read events from perf list with and without -v. With -v the duplicate PMUs
> > > +  # aren't deduplicated. Note, json events are listed by perf list without a
> > > +  # PMU.
> > > +  read -ra pmu_events <<< "$(perf list --raw pmu)"
> > > +  read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
> > > +  # For all non-deduplicated events.
> > > +  for pmu_v_event in "${pmu_v_events[@]}"; do
> > > +    # If the event matches an event in the deduplicated events then it musn't
> > > +    # be an event with duplicate PMUs, continue the outer loop.
> > > +    for pmu_event in "${pmu_events[@]}"; do
> > > +      if [[ "$pmu_v_event" == "$pmu_event" ]]; then
> > > +        continue 2
> > > +      fi
> > > +    done
> > > +    # Strip the suffix from the non-deduplicated event's PMU.
> > > +    event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
> > > +    for pmu_event in "${pmu_events[@]}"; do
> > > +      if [[ "$event" == "$pmu_event" ]]; then
> > > +        echo "Testing event ${event} is uniquified to ${pmu_v_event}"
> > > +        if ! perf stat -e "$event" -A -o ${stat_output} -- true; then
> > > +          echo "Error running perf stat for event '$event'  [Skip]"
> > > +          if [ $err = 0 ]; then
> > > +            err=2
> > > +          fi
> > > +          continue
> > > +        fi
> > > +        # Ensure the non-deduplicated event appears in the output.
> > > +        if ! grep -q "${pmu_v_event}" "${stat_output}"; then
> > > +          echo "Uniquification of PMU sysfs events test [Failed]"
> > > +          cat "${stat_output}"
> > > +          err=1
> > > +        fi
> > > +        break
> > > +      fi
> > > +    done
> > >    done
> > >  }
> > >
> > >  test_event_uniquifying
> > > -rm -f "${stat_output}"
> > > +cleanup
> > >  exit $err
> > > --
> > > 2.51.0.470.ga7dc726c21-goog
> > >
> > >
> >
>


  reply	other threads:[~2025-09-29  2:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 22:21 [PATCH v2 0/3] Test/uniquification related fixes Ian Rogers
2025-09-18 22:22 ` [PATCH v2 1/3] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
2025-09-18 22:22 ` [PATCH v2 2/3] perf evsel: Fix uniquification when PMU given without suffix Ian Rogers
2025-09-18 22:22 ` [PATCH v2 3/3] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
2025-09-26  9:00   ` Qiao Zhao
2025-09-26 16:21     ` Ian Rogers
2025-09-29  2:39       ` Qiao Zhao [this message]
2025-09-19 19:51 ` [PATCH v2 0/3] Test/uniquification related fixes Arnaldo Carvalho de Melo

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=CAATMXfkcWT+SP0eu9By2VdnLoHY8PdCFWa9MwTNzHMZ7t2UB_Q@mail.gmail.com \
    --to=qzhao@redhat.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=atrajeev@linux.ibm.com \
    --cc=ctshao@google.com \
    --cc=howardchu95@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /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).