[PATCH v1] perf test: Restrict uniquifying test to machines with uncore_imc

Chun-Tse Shao posted 1 patch 6 months, 3 weeks ago
tools/perf/tests/shell/stat+event_uniquifying.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
[PATCH v1] perf test: Restrict uniquifying test to machines with uncore_imc
Posted by Chun-Tse Shao 6 months, 3 weeks ago
The test would fail if target machine does not have `uncore_imc` devices.
Since event uniquifying behavior is similar among different
architectures, we are restricting the test to only run on machines with
`uncore_imc` devices.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Chun-Tse Shao <ctshao@google.com>
---
 tools/perf/tests/shell/stat+event_uniquifying.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
index 5ec35c52b7d9..5a51fbaa13bb 100755
--- a/tools/perf/tests/shell/stat+event_uniquifying.sh
+++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
@@ -9,7 +9,8 @@ perf_tool=perf
 err=0

 test_event_uniquifying() {
-  # We use `clockticks` to verify the uniquify behavior.
+  # 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.
@@ -43,11 +44,17 @@ test_event_uniquifying() {
   echo "stat event uniquifying test"
   uniquified_event_array=()

+  # 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]"
+    return
+  fi
+
   # 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 "\[Kernel PMU event\]")
+  done < <(${perf_tool} list -v ${event} | grep ${pmu})

   perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
   $perf_command
--
2.49.0.1143.g0be31eac6b-goog
Re: [PATCH v1] perf test: Restrict uniquifying test to machines with uncore_imc
Posted by Chun-Tse Shao 6 months, 1 week ago
Ping.

Thanks,
CT

On Wed, May 21, 2025 at 3:45 PM Chun-Tse Shao <ctshao@google.com> wrote:
>
> The test would fail if target machine does not have `uncore_imc` devices.
> Since event uniquifying behavior is similar among different
> architectures, we are restricting the test to only run on machines with
> `uncore_imc` devices.
>
> Suggested-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> ---
>  tools/perf/tests/shell/stat+event_uniquifying.sh | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
> index 5ec35c52b7d9..5a51fbaa13bb 100755
> --- a/tools/perf/tests/shell/stat+event_uniquifying.sh
> +++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
> @@ -9,7 +9,8 @@ perf_tool=perf
>  err=0
>
>  test_event_uniquifying() {
> -  # We use `clockticks` to verify the uniquify behavior.
> +  # 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.
> @@ -43,11 +44,17 @@ test_event_uniquifying() {
>    echo "stat event uniquifying test"
>    uniquified_event_array=()
>
> +  # 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]"
> +    return
> +  fi
> +
>    # 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 "\[Kernel PMU event\]")
> +  done < <(${perf_tool} list -v ${event} | grep ${pmu})
>
>    perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
>    $perf_command
> --
> 2.49.0.1143.g0be31eac6b-goog
>
Re: [PATCH v1] perf test: Restrict uniquifying test to machines with uncore_imc
Posted by Ian Rogers 6 months, 1 week ago
On Tue, Jun 3, 2025 at 9:21 AM Chun-Tse Shao <ctshao@google.com> wrote:
>
> Ping.
>
> Thanks,
> CT
>
> On Wed, May 21, 2025 at 3:45 PM Chun-Tse Shao <ctshao@google.com> wrote:
> >
> > The test would fail if target machine does not have `uncore_imc` devices.
> > Since event uniquifying behavior is similar among different
> > architectures, we are restricting the test to only run on machines with
> > `uncore_imc` devices.
> >
> > Suggested-by: Ian Rogers <irogers@google.com>
> > Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> > ---
> >  tools/perf/tests/shell/stat+event_uniquifying.sh | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > index 5ec35c52b7d9..5a51fbaa13bb 100755
> > --- a/tools/perf/tests/shell/stat+event_uniquifying.sh
> > +++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > @@ -9,7 +9,8 @@ perf_tool=perf
> >  err=0
> >
> >  test_event_uniquifying() {
> > -  # We use `clockticks` to verify the uniquify behavior.
> > +  # We use `clockticks` in `uncore_imc` to verify the uniquify behavior.
> > +  pmu="uncore_imc"
> >    event="clockticks"

I'm a little concerned the test will only run on Intel server CPUs.
Another event that is on a lot of PMUs and needs uniquify is "temp1"
by way of the hwmon PMUs. Essentially the first temperature event on a
hwmon PMU will always have a temp1 name.

```
$ perf list temp1

List of pre-defined events (to be used in -e or -M):


hwmon:
 temp1
      [Temperature in unit acpitz named temp1. Unit: hwmon_acpitz]
 temp_core_12 OR temp14
      [Temperature in unit coretemp named Core 12. crit=100'C,max=80'C
crit_alarm=0'C. Unit:
       hwmon_coretemp]
 temp_core_16 OR temp18
      [Temperature in unit coretemp named Core 16. crit=100'C,max=80'C
crit_alarm=0'C. Unit:
       hwmon_coretemp]
 temp_core_8 OR temp10
      [Temperature in unit coretemp named Core 8. crit=100'C,max=80'C
crit_alarm=0'C. Unit:
       hwmon_coretemp]
 temp_package_id_0 OR temp1
      [Temperature in unit coretemp named Package id 0.
crit=100'C,max=80'C crit_alarm=0'C. Unit:
       hwmon_coretemp]
 temp1
      [Temperature in unit iwlwifi_1 named temp1. Unit: hwmon_iwlwifi_1]
 temp_composite OR temp1
      [Temperature in unit nvme named Composite.
alarm=0'C,crit=84.85'C,max=80.85'C,
       min=-273.15'C. Unit: hwmon_nvme]
 temp1
      [Temperature in unit spd5118 named temp1.
crit=85'C,enable=0.001'C,lcrit=0'C,max=55'C,
       min=0'C crit_alarm=0'C,lcrit_alarm=0'C,min_alarm=0'C. Unit:
hwmon_spd5118]
$ perf stat -e temp1 true

Performance counter stats for 'true':

18,446,744,073,709,284.00 'C   hwmon_acpitz/temp1/

            40.00 'C   hwmon_coretemp/temp1/
            30.00 'C   hwmon_iwlwifi_1/temp1/
            38.85 'C   hwmon_nvme/temp1/
            43.75 'C   hwmon_spd5118/temp1/

      0.001488897 seconds time elapsed

      0.000000000 seconds user
      0.001568000 seconds sys
```

Thanks,
Ian

> >
> >    # If the `-A` option is added, the event should be uniquified.
> > @@ -43,11 +44,17 @@ test_event_uniquifying() {
> >    echo "stat event uniquifying test"
> >    uniquified_event_array=()
> >
> > +  # 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]"
> > +    return
> > +  fi
> > +
> >    # 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 "\[Kernel PMU event\]")
> > +  done < <(${perf_tool} list -v ${event} | grep ${pmu})
> >
> >    perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
> >    $perf_command
> > --
> > 2.49.0.1143.g0be31eac6b-goog
> >