* [PATCH 1/2] perf test: Fix LBR test by ignoring idle task
@ 2025-05-09 21:30 Namhyung Kim
2025-05-09 21:30 ` [PATCH 2/2] perf test: Update sysfs path for core PMU caps Namhyung Kim
2025-05-13 14:58 ` [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Ian Rogers
0 siblings, 2 replies; 6+ messages in thread
From: Namhyung Kim @ 2025-05-09 21:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
I found 'perf record LBR tests' failing due to empty branch stacks.
$ perf test -v LBR
...
LBR system wide any branch test
Lowering default frequency rate from 4000 to 1000.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
[ perf record: Woken up 8 times to write data ]
[ perf record: Captured and wrote 3.142 MB /tmp/__perf_test.perf.data.dgSBl (3572 samples) ]
LBR system wide any branch test: 3572 samples
LBR system wide any branch test [Failed empty br stack ratio exceed 2%: 3%]
LBR system wide any call test
Lowering default frequency rate from 4000 to 1000.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
[ perf record: Woken up 8 times to write data ]
[ perf record: Captured and wrote 3.337 MB /tmp/__perf_test.perf.data.dgSBl (3967 samples) ]
LBR system wide any call test: 3967 samples
LBR system wide any call test [Failed empty br stack ratio exceed 2%: 9%]
...
The failing cases were in system-wide mode and I realized that the
samples were from the idle tasks (swapper). I suspect going to/from
idle state may affect the LBR contents.
If we can skip empty branch stacks from the idle tasks, the failure
should go away. I can see the following output in perf report -D.
$ perf report -D | grep -m5 -A3 'branch stack: nr:0'
...
--
... branch stack: nr:0
... thread: swapper:0
...... dso: /proc/kcore
--
... branch stack: nr:0
... thread: swapper:0
...... dso: /proc/kcore
--
... branch stack: nr:0
... thread: DefaultEventMan:10282
...... dso: /proc/kcore
--
... branch stack: nr:0
... thread: swapper:0
...... dso: /proc/kcore
--
... branch stack: nr:0
... thread: swapper:0
...... dso: /proc/kcore
$ perf report -D | grep -c 'branch stack: nr:0'
145
$ perf report -D | grep -A3 'branch stack: nr:0' | grep thread | grep -c swapper
i36
$ perf report -D | grep -A3 'branch stack: nr:0' | grep thread | grep -cv swapper
9
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/record_lbr.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
index 8d750ee631f877fd..afad02d0180e023c 100755
--- a/tools/perf/tests/shell/record_lbr.sh
+++ b/tools/perf/tests/shell/record_lbr.sh
@@ -93,7 +93,7 @@ lbr_test() {
return
fi
- zero_nr=$(echo "$out" | grep -c 'branch stack: nr:0' || true)
+ zero_nr=$(echo "$out" | grep -A3 'branch stack: nr:0' | grep thread | grep -cv swapper || true)
r=$(($zero_nr * 100 / $bs_nr))
if [ $r -gt $threshold ]; then
echo "$test [Failed empty br stack ratio exceed $threshold%: $r%]"
--
2.49.0.1015.ga840276032-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] perf test: Update sysfs path for core PMU caps
2025-05-09 21:30 [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Namhyung Kim
@ 2025-05-09 21:30 ` Namhyung Kim
2025-05-13 14:58 ` Ian Rogers
2025-05-13 14:58 ` [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Ian Rogers
1 sibling, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2025-05-09 21:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
While cpu is a system device, it'd be better to use a path for
event_source devices when it checks PMU capability.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/record_lbr.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
index afad02d0180e023c..6fcb5e52b9b4fcf6 100755
--- a/tools/perf/tests/shell/record_lbr.sh
+++ b/tools/perf/tests/shell/record_lbr.sh
@@ -4,7 +4,8 @@
set -e
-if [ ! -f /sys/devices/cpu/caps/branches ] && [ ! -f /sys/devices/cpu_core/caps/branches ]
+if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
+ [ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ]
then
echo "Skip: only x86 CPUs support LBR"
exit 2
--
2.49.0.1015.ga840276032-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] perf test: Fix LBR test by ignoring idle task
2025-05-09 21:30 [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Namhyung Kim
2025-05-09 21:30 ` [PATCH 2/2] perf test: Update sysfs path for core PMU caps Namhyung Kim
@ 2025-05-13 14:58 ` Ian Rogers
2025-05-13 20:46 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2025-05-13 14:58 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Kan Liang, Jiri Olsa, Adrian Hunter,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users
On Fri, May 9, 2025 at 2:30 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> I found 'perf record LBR tests' failing due to empty branch stacks.
>
> $ perf test -v LBR
> ...
> LBR system wide any branch test
> Lowering default frequency rate from 4000 to 1000.
> Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
> [ perf record: Woken up 8 times to write data ]
> [ perf record: Captured and wrote 3.142 MB /tmp/__perf_test.perf.data.dgSBl (3572 samples) ]
> LBR system wide any branch test: 3572 samples
> LBR system wide any branch test [Failed empty br stack ratio exceed 2%: 3%]
> LBR system wide any call test
> Lowering default frequency rate from 4000 to 1000.
> Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
> [ perf record: Woken up 8 times to write data ]
> [ perf record: Captured and wrote 3.337 MB /tmp/__perf_test.perf.data.dgSBl (3967 samples) ]
> LBR system wide any call test: 3967 samples
> LBR system wide any call test [Failed empty br stack ratio exceed 2%: 9%]
> ...
>
> The failing cases were in system-wide mode and I realized that the
> samples were from the idle tasks (swapper). I suspect going to/from
> idle state may affect the LBR contents.
>
> If we can skip empty branch stacks from the idle tasks, the failure
> should go away. I can see the following output in perf report -D.
>
> $ perf report -D | grep -m5 -A3 'branch stack: nr:0'
> ...
> --
> ... branch stack: nr:0
> ... thread: swapper:0
> ...... dso: /proc/kcore
>
> --
> ... branch stack: nr:0
> ... thread: swapper:0
> ...... dso: /proc/kcore
>
> --
> ... branch stack: nr:0
> ... thread: DefaultEventMan:10282
> ...... dso: /proc/kcore
>
> --
> ... branch stack: nr:0
> ... thread: swapper:0
> ...... dso: /proc/kcore
>
> --
> ... branch stack: nr:0
> ... thread: swapper:0
> ...... dso: /proc/kcore
>
> $ perf report -D | grep -c 'branch stack: nr:0'
> 145
>
> $ perf report -D | grep -A3 'branch stack: nr:0' | grep thread | grep -c swapper
> i36
>
> $ perf report -D | grep -A3 'branch stack: nr:0' | grep thread | grep -cv swapper
> 9
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/tests/shell/record_lbr.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
> index 8d750ee631f877fd..afad02d0180e023c 100755
> --- a/tools/perf/tests/shell/record_lbr.sh
> +++ b/tools/perf/tests/shell/record_lbr.sh
> @@ -93,7 +93,7 @@ lbr_test() {
> return
> fi
>
> - zero_nr=$(echo "$out" | grep -c 'branch stack: nr:0' || true)
> + zero_nr=$(echo "$out" | grep -A3 'branch stack: nr:0' | grep thread | grep -cv swapper || true)
> r=$(($zero_nr * 100 / $bs_nr))
> if [ $r -gt $threshold ]; then
> echo "$test [Failed empty br stack ratio exceed $threshold%: $r%]"
> --
> 2.49.0.1015.ga840276032-goog
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf test: Update sysfs path for core PMU caps
2025-05-09 21:30 ` [PATCH 2/2] perf test: Update sysfs path for core PMU caps Namhyung Kim
@ 2025-05-13 14:58 ` Ian Rogers
2025-05-13 20:46 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2025-05-13 14:58 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Kan Liang, Jiri Olsa, Adrian Hunter,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users
On Fri, May 9, 2025 at 2:30 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> While cpu is a system device, it'd be better to use a path for
> event_source devices when it checks PMU capability.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/tests/shell/record_lbr.sh | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
> index afad02d0180e023c..6fcb5e52b9b4fcf6 100755
> --- a/tools/perf/tests/shell/record_lbr.sh
> +++ b/tools/perf/tests/shell/record_lbr.sh
> @@ -4,7 +4,8 @@
>
> set -e
>
> -if [ ! -f /sys/devices/cpu/caps/branches ] && [ ! -f /sys/devices/cpu_core/caps/branches ]
> +if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
> + [ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ]
> then
> echo "Skip: only x86 CPUs support LBR"
> exit 2
> --
> 2.49.0.1015.ga840276032-goog
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf test: Update sysfs path for core PMU caps
2025-05-13 14:58 ` Ian Rogers
@ 2025-05-13 20:46 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-05-13 20:46 UTC (permalink / raw)
To: Ian Rogers
Cc: Namhyung Kim, Kan Liang, Jiri Olsa, Adrian Hunter, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users
On Tue, May 13, 2025 at 07:58:40AM -0700, Ian Rogers wrote:
> On Fri, May 9, 2025 at 2:30 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > While cpu is a system device, it'd be better to use a path for
> > event_source devices when it checks PMU capability.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] perf test: Fix LBR test by ignoring idle task
2025-05-13 14:58 ` [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Ian Rogers
@ 2025-05-13 20:46 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-05-13 20:46 UTC (permalink / raw)
To: Ian Rogers
Cc: Namhyung Kim, Kan Liang, Jiri Olsa, Adrian Hunter, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users
On Tue, May 13, 2025 at 07:58:07AM -0700, Ian Rogers wrote:
> On Fri, May 9, 2025 at 2:30 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > I found 'perf record LBR tests' failing due to empty branch stacks.
<SNIP>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-13 20:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 21:30 [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Namhyung Kim
2025-05-09 21:30 ` [PATCH 2/2] perf test: Update sysfs path for core PMU caps Namhyung Kim
2025-05-13 14:58 ` Ian Rogers
2025-05-13 20:46 ` Arnaldo Carvalho de Melo
2025-05-13 14:58 ` [PATCH 1/2] perf test: Fix LBR test by ignoring idle task Ian Rogers
2025-05-13 20:46 ` Arnaldo Carvalho de Melo
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).