All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Dapeng Mi <dapeng1.mi@linux.intel.com>,
	James Clark <james.clark@linaro.org>, <x86@kernel.org>,
	<linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Manali Shukla <manali.shukla@amd.com>,
	Santosh Shukla <santosh.shukla@amd.com>,
	Ananth Narayan <ananth.narayan@amd.com>,
	Sandipan Das <sandipan.das@amd.com>
Subject: [PATCH v3 3/8] perf test ibs: Skip privilege test on Zen6 and newer platforms
Date: Fri, 8 May 2026 05:59:59 +0000	[thread overview]
Message-ID: <20260508060004.2575-4-ravi.bangoria@amd.com> (raw)
In-Reply-To: <20260508060004.2575-1-ravi.bangoria@amd.com>

IBS on pre-Zen6 platforms lacked a hardware privilege filter, so the
kernel enabled swfilt=1. Zen6 and newer platforms provides privilege
filtering via the RIP[63] bit, making swfilt redundant. Skip the perf
unit test that assumes IBS has no hardware-assisted privilege filter
on Zen6 and newer platforms.

swfilt is ignored by kernel on platforms that support RIP[63] bit filter
i.e. all amd-ibs-swfilt.sh tests will test hardware assisted privilege
filter.

Without the patch on Zen6:

  # sudo ./perf test -vv 77
   77: AMD IBS software filtering:
  --- start ---
  test child forked, pid 30813
  check availability of IBS swfilt
  run perf record with modifier and swfilt
  [FAIL] IBS PMU should not accept exclude_kernel
  ---- end(-1) ----
   77: AMD IBS software filtering                            : FAILED!

With the patch:

  # ./perf test -vv 77
   77: AMD IBS software filtering:
  --- start ---
  test child forked, pid 30903
  check availability of IBS swfilt
  run perf record with modifier and swfilt
  [ perf record: Woken up 2 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  check number of samples with swfilt
  [ perf record: Woken up 4 times to write data ]
  [ perf record: Captured and wrote 0.051 MB - ]
  [ perf record: Woken up 4 times to write data ]
  [ perf record: Captured and wrote 0.063 MB - ]
  ---- end(0) ----
   77: AMD IBS software filtering                            : Ok

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
 tools/perf/tests/shell/amd-ibs-swfilt.sh | 37 +++++++++++++++++++++---
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/shell/amd-ibs-swfilt.sh b/tools/perf/tests/shell/amd-ibs-swfilt.sh
index e7f66df05c4b..e3738436773e 100755
--- a/tools/perf/tests/shell/amd-ibs-swfilt.sh
+++ b/tools/perf/tests/shell/amd-ibs-swfilt.sh
@@ -1,6 +1,33 @@
 #!/bin/bash
 # AMD IBS software filtering
 
+cpu_family() {
+    grep -m1 '^cpu family[[:space:]]*:' /proc/cpuinfo \
+        | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}'
+}
+
+cpu_model() {
+    grep -m1 '^model[[:space:]]*:' /proc/cpuinfo \
+        | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}'
+}
+
+# IBS PMUs does not advertize privilege filtering capability. Rely
+# on Family / Model check.
+hw_priv_filter_supported() {
+    family=$(cpu_family)
+    model=$(cpu_model)
+
+    if (( family > 0x1a )) ||
+       { (( family == 0x1a )) &&
+         { { (( model >= 0x50 && model <= 0x5f )) ||
+             (( model >= 0x80 && model <= 0xaf )) ||
+             (( model >= 0xc0 && model <= 0xcf )); }; }; }; then
+        return 0 # True
+    else
+        return 1 # False
+    fi
+}
+
 ParanoidAndNotRoot() {
   [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
 }
@@ -23,10 +50,12 @@ echo "run perf record with modifier and swfilt"
 err=0
 
 # setting any modifiers should fail
-perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
-if [ $? -eq 0 ]; then
-    echo "[FAIL] IBS PMU should not accept exclude_kernel"
-    exit 1
+if ! hw_priv_filter_supported; then
+    perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
+    if [ $? -eq 0 ]; then
+        echo "[FAIL] IBS PMU should not accept exclude_kernel"
+        exit 1
+    fi
 fi
 
 # setting it with swfilt should be fine
-- 
2.43.0


  parent reply	other threads:[~2026-05-08  6:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  5:59 [PATCH v3 0/8] perf tools amd ibs: Fixes + Zen6 enhancements Ravi Bangoria
2026-05-08  5:59 ` [PATCH v3 1/8] perf test amd ibs: Fix incorrect kernel version check Ravi Bangoria
2026-05-08  5:59 ` [PATCH v3 2/8] perf tool ibs: Sync AMD IBS header file Ravi Bangoria
2026-05-08  5:59 ` Ravi Bangoria [this message]
2026-05-08  6:00 ` [PATCH v3 4/8] perf amd ibs: Suppress bogus TlbRefillLat and DCPhysAd on Zen4+ Ravi Bangoria
2026-05-08 18:20   ` sashiko-bot
2026-05-12  8:49     ` Ravi Bangoria
2026-05-08  6:00 ` [PATCH v3 5/8] perf amd ibs: Make Fetch status bits dependent on PhyAddrValid for newer platforms Ravi Bangoria
2026-05-08  6:00 ` [PATCH v3 6/8] perf amd ibs: Decode Remote-Socket flag in IBS OP raw dump Ravi Bangoria
2026-05-08  6:00 ` [PATCH v3 7/8] perf amd ibs: Decode Streaming-store " Ravi Bangoria
2026-05-08  6:00 ` [PATCH v3 8/8] perf doc: Document new IBS capabilities in man page Ravi Bangoria
2026-05-10  6:41 ` [PATCH v3 0/8] perf tools amd ibs: Fixes + Zen6 enhancements Namhyung Kim

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=20260508060004.2575-4-ravi.bangoria@amd.com \
    --to=ravi.bangoria@amd.com \
    --cc=acme@kernel.org \
    --cc=ananth.narayan@amd.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=manali.shukla@amd.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sandipan.das@amd.com \
    --cc=santosh.shukla@amd.com \
    --cc=x86@kernel.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 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.