[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aMSWbjo-qY7JYAoY@x1>
Date: Fri, 12 Sep 2025 18:53:50 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>, Ravi Bangoria <ravi.bangoria@....com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>,
Collin Funk <collin.funk1@...il.com>,
James Clark <james.clark@...aro.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] perf test: AMD IBS swfilt skip kernel tests if
paranoia is >1
On Mon, Sep 08, 2025 at 04:35:11PM -0700, Namhyung Kim wrote:
> Hi Ian,
>
> On Mon, Sep 08, 2025 at 03:17:27PM -0700, Ian Rogers wrote:
> > If not root and the perf_event_paranoid is set >1 swfilt will fail to
> > open the event failing the test. Add check to skip the test in that
> > case.
>
> Thanks for the fix!
I'm taking this as an Acked-by, ok?
- Arnaldo
> >
> > Some corrections to the kernel/user sample count test.
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> > tools/perf/tests/shell/amd-ibs-swfilt.sh | 57 +++++++++++++++++-------
> > 1 file changed, 41 insertions(+), 16 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/amd-ibs-swfilt.sh b/tools/perf/tests/shell/amd-ibs-swfilt.sh
> > index 7045ec72ba4c..80d5bf8db40c 100755
> > --- a/tools/perf/tests/shell/amd-ibs-swfilt.sh
> > +++ b/tools/perf/tests/shell/amd-ibs-swfilt.sh
> > @@ -1,6 +1,10 @@
> > #!/bin/bash
> > # AMD IBS software filtering
> >
> > +ParanoidAndNotRoot() {
> > + [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
> > +}
> > +
> > echo "check availability of IBS swfilt"
> >
> > # check if IBS PMU is available
> > @@ -16,6 +20,7 @@ if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then
> > fi
> >
> > 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
> > @@ -31,11 +36,17 @@ if [ $? -ne 0 ]; then
> > exit 1
> > fi
> >
> > -# setting it with swfilt=1 should be fine
> > -perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
> > -if [ $? -ne 0 ]; then
> > - echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
> > - exit 1
> > +if ! ParanoidAndNotRoot 1
> > +then
> > + # setting it with swfilt=1 should be fine
> > + perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
> > + if [ $? -ne 0 ]; then
> > + echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
> > + exit 1
> > + fi
> > +else
> > + echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
> > + err=2
> > fi
> >
> > # check ibs_fetch PMU as well
> > @@ -46,22 +57,36 @@ if [ $? -ne 0 ]; then
> > fi
> >
> > # check system wide recording
> > -perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
> > -if [ $? -ne 0 ]; then
> > - echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
> > - exit 1
> > +if ! ParanoidAndNotRoot 1
> > +then
> > + perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
> > + if [ $? -ne 0 ]; then
> > + echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
> > + exit 1
> > + fi
> > +else
> > + echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
> > + err=2
> > fi
> >
> > echo "check number of samples with swfilt"
> >
> > -kernel_sample=$(perf record -e ibs_op/swfilt/u -o- true | perf script -i- -F misc | grep -c ^K)
> > -if [ ${kernel_sample} -ne 0 ]; then
> > - echo "[FAIL] unexpected kernel samples: " ${kernel_sample}
> > - exit 1
> > -fi
> > -
> > -user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
> > +user_sample=$(perf record -e ibs_op/swfilt/u -o- true | perf script -i- -F misc | grep -c ^U)
>
> I think it should count kernel samples now (with ^K) as it sets 'u'
> modifier (exclude_kernel).
>
>
> > if [ ${user_sample} -ne 0 ]; then
> > echo "[FAIL] unexpected user samples: " ${user_sample}
>
> So that it should not have unexpected kernel samples.
>
>
> > exit 1
> > fi
> > +
> > +if ! ParanoidAndNotRoot 1
> > +then
> > + kernel_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^K)
> > + if [ ${kernel_sample} -ne 0 ]; then
> > + echo "[FAIL] unexpected kernel samples: " ${kernel_sample}
>
> Vice versa. It should count unexpected user samples from 'k' modifier.
>
> Thanks,
> Namhyung
>
>
> > + exit 1
> > + fi
> > +else
> > + echo "[SKIP] not root and perf_event_paranoid too high for exclude_user"
> > + err=2
> > +fi
> > +
> > +exit $err
> > --
> > 2.51.0.384.g4c02a37b29-goog
> >
Powered by blists - more mailing lists