linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tests: Make leader sampling test work without branch event
@ 2024-11-15 16:15 James Clark
  2024-11-15 18:54 ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: James Clark @ 2024-11-15 16:15 UTC (permalink / raw)
  To: linux-perf-users
  Cc: James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Dapeng Mi, Veronika Molnarova, linux-kernel

Arm a57 only has speculative branch events so this test fails there. The
test doesn't depend on branch instructions so change it to instructions
which is pretty much guaranteed to be everywhere. The
test_branch_counter() test above already tests for the existence of the
branches event and skips if its not present.

Signed-off-by: James Clark <james.clark@linaro.org>
---
 tools/perf/tests/shell/record.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 85d512f5a126..0fc7a909ae9b 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -231,7 +231,8 @@ test_cgroup() {
 
 test_leader_sampling() {
   echo "Basic leader sampling test"
-  if ! perf record -o "${perfdata}" -e "{branches,branches}:Su" perf test -w brstack 2> /dev/null
+  if ! perf record -o "${perfdata}" -e "{instructions,instructions}:Su" -- \
+    perf test -w brstack 2> /dev/null
   then
     echo "Leader sampling [Failed record]"
     err=1
@@ -241,16 +242,16 @@ test_leader_sampling() {
   perf script -i "${perfdata}" > $script_output
   while IFS= read -r line
   do
-    # Check if the two branches counts are equal in each record
-    branches=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="branches:") print $(i-1)}')
-    if [ $(($index%2)) -ne 0 ] && [ ${branches}x != ${prev_branches}x ]
+    # Check if the two instruction counts are equal in each record
+    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="instructions:") print $(i-1)}')
+    if [ $(($index%2)) -ne 0 ] && [ ${instructions}x != ${prev_instructions}x ]
     then
-      echo "Leader sampling [Failed inconsistent branches count]"
+      echo "Leader sampling [Failed inconsistent instructions count]"
       err=1
       return
     fi
     index=$(($index+1))
-    prev_branches=$branches
+    prev_instructions=$instructions
   done < $script_output
   echo "Basic leader sampling test [Success]"
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests: Make leader sampling test work without branch event
  2024-11-15 16:15 [PATCH] perf tests: Make leader sampling test work without branch event James Clark
@ 2024-11-15 18:54 ` Ian Rogers
  2024-11-16 19:28   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2024-11-15 18:54 UTC (permalink / raw)
  To: James Clark
  Cc: linux-perf-users, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Liang, Kan,
	Dapeng Mi, Veronika Molnarova, linux-kernel

On Fri, Nov 15, 2024 at 8:16 AM James Clark <james.clark@linaro.org> wrote:
>
> Arm a57 only has speculative branch events so this test fails there. The
> test doesn't depend on branch instructions so change it to instructions
> which is pretty much guaranteed to be everywhere. The
> test_branch_counter() test above already tests for the existence of the
> branches event and skips if its not present.
>
> Signed-off-by: James Clark <james.clark@linaro.org>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/record.sh | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 85d512f5a126..0fc7a909ae9b 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -231,7 +231,8 @@ test_cgroup() {
>
>  test_leader_sampling() {
>    echo "Basic leader sampling test"
> -  if ! perf record -o "${perfdata}" -e "{branches,branches}:Su" perf test -w brstack 2> /dev/null
> +  if ! perf record -o "${perfdata}" -e "{instructions,instructions}:Su" -- \
> +    perf test -w brstack 2> /dev/null
>    then
>      echo "Leader sampling [Failed record]"
>      err=1
> @@ -241,16 +242,16 @@ test_leader_sampling() {
>    perf script -i "${perfdata}" > $script_output
>    while IFS= read -r line
>    do
> -    # Check if the two branches counts are equal in each record
> -    branches=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="branches:") print $(i-1)}')
> -    if [ $(($index%2)) -ne 0 ] && [ ${branches}x != ${prev_branches}x ]
> +    # Check if the two instruction counts are equal in each record
> +    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="instructions:") print $(i-1)}')
> +    if [ $(($index%2)) -ne 0 ] && [ ${instructions}x != ${prev_instructions}x ]
>      then
> -      echo "Leader sampling [Failed inconsistent branches count]"
> +      echo "Leader sampling [Failed inconsistent instructions count]"
>        err=1
>        return
>      fi
>      index=$(($index+1))
> -    prev_branches=$branches
> +    prev_instructions=$instructions
>    done < $script_output
>    echo "Basic leader sampling test [Success]"
>  }
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests: Make leader sampling test work without branch event
  2024-11-15 18:54 ` Ian Rogers
@ 2024-11-16 19:28   ` Arnaldo Carvalho de Melo
  2024-12-21  7:08     ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-16 19:28 UTC (permalink / raw)
  To: Ian Rogers
  Cc: James Clark, linux-perf-users, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, Liang, Kan, Dapeng Mi, Veronika Molnarova,
	linux-kernel

On Fri, Nov 15, 2024 at 10:54:43AM -0800, Ian Rogers wrote:
> On Fri, Nov 15, 2024 at 8:16 AM James Clark <james.clark@linaro.org> wrote:
> >
> > Arm a57 only has speculative branch events so this test fails there. The
> > test doesn't depend on branch instructions so change it to instructions
> > which is pretty much guaranteed to be everywhere. The
> > test_branch_counter() test above already tests for the existence of the
> > branches event and skips if its not present.
> >
> > Signed-off-by: James Clark <james.clark@linaro.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] perf tests: Make leader sampling test work without branch event
  2024-11-16 19:28   ` Arnaldo Carvalho de Melo
@ 2024-12-21  7:08     ` Ian Rogers
  2024-12-23  9:04       ` Mi, Dapeng
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2024-12-21  7:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Liang, Kan, James Clark, Dapeng Mi
  Cc: linux-perf-users, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Veronika Molnarova, linux-kernel

On Sat, Nov 16, 2024 at 11:28 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Fri, Nov 15, 2024 at 10:54:43AM -0800, Ian Rogers wrote:
> > On Fri, Nov 15, 2024 at 8:16 AM James Clark <james.clark@linaro.org> wrote:
> > >
> > > Arm a57 only has speculative branch events so this test fails there. The
> > > test doesn't depend on branch instructions so change it to instructions
> > > which is pretty much guaranteed to be everywhere. The
> > > test_branch_counter() test above already tests for the existence of the
> > > branches event and skips if its not present.
> > >
> > > Signed-off-by: James Clark <james.clark@linaro.org>
> >
> > Reviewed-by: Ian Rogers <irogers@google.com>
>
> Thanks, applied to perf-tools-next,

Rebasing on perf-tools-next I see this failing on my Intel Tigerlake
laptop. An example script output for:
```
 perf record -o "${perfdata}" -e "{instructions,instructions}:Su"
```
is:
```
            perf  352917 49604.160314:          3 instructions:
7f155caca323 [unknown]
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.160314:          3 instructions:
7f155caca323 [unknown]
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.160317:         18 instructions:
7f155cacaf3d _dl_start+0x3d
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.160317:         18 instructions:
7f155cacaf3d _dl_start+0x3d
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.160319:          3 instructions:
7f155cacaf44 _dl_start+0x44
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.160319:          3 instructions:
7f155cacaf44 _dl_start+0x44
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.161099:        120 instructions:
ffffffff8ce00080 [unknown] ([unknown])
            perf  352917 49604.161099:     181013 instructions:
ffffffff8ce00080 [unknown] ([unknown])
            perf  352917 49604.161115:       8811 instructions:
7f155cad22d0 strcmp+0x8b0
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.161115:       8811 instructions:
7f155cad22d0 strcmp+0x8b0
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.161130:      10483 instructions:
7f155caba508 _dl_new_object+0x198
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.161130:      10483 instructions:
7f155caba508 _dl_new_object+0x198
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.165156:     177355 instructions:
7f155cab90a4 _dl_lookup_symbol_x+0x44
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
            perf  352917 49604.165156:   13313598 instructions:
7f155cab90a4 _dl_lookup_symbol_x+0x44
(/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
...
```

Dapeng/Kan, any thoughts why the counts don't match for instructions
but did for branches?

Thanks,
Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests: Make leader sampling test work without branch event
  2024-12-21  7:08     ` Ian Rogers
@ 2024-12-23  9:04       ` Mi, Dapeng
  2025-01-09 21:43         ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Mi, Dapeng @ 2024-12-23  9:04 UTC (permalink / raw)
  To: Ian Rogers, Arnaldo Carvalho de Melo, Liang, Kan, James Clark
  Cc: linux-perf-users, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Veronika Molnarova, linux-kernel


On 12/21/2024 3:08 PM, Ian Rogers wrote:
> On Sat, Nov 16, 2024 at 11:28 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
>> On Fri, Nov 15, 2024 at 10:54:43AM -0800, Ian Rogers wrote:
>>> On Fri, Nov 15, 2024 at 8:16 AM James Clark <james.clark@linaro.org> wrote:
>>>> Arm a57 only has speculative branch events so this test fails there. The
>>>> test doesn't depend on branch instructions so change it to instructions
>>>> which is pretty much guaranteed to be everywhere. The
>>>> test_branch_counter() test above already tests for the existence of the
>>>> branches event and skips if its not present.
>>>>
>>>> Signed-off-by: James Clark <james.clark@linaro.org>
>>> Reviewed-by: Ian Rogers <irogers@google.com>
>> Thanks, applied to perf-tools-next,
> Rebasing on perf-tools-next I see this failing on my Intel Tigerlake
> laptop. An example script output for:
> ```
>  perf record -o "${perfdata}" -e "{instructions,instructions}:Su"
> ```
> is:
> ```
>             perf  352917 49604.160314:          3 instructions:
> 7f155caca323 [unknown]
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.160314:          3 instructions:
> 7f155caca323 [unknown]
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.160317:         18 instructions:
> 7f155cacaf3d _dl_start+0x3d
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.160317:         18 instructions:
> 7f155cacaf3d _dl_start+0x3d
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.160319:          3 instructions:
> 7f155cacaf44 _dl_start+0x44
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.160319:          3 instructions:
> 7f155cacaf44 _dl_start+0x44
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.161099:        120 instructions:
> ffffffff8ce00080 [unknown] ([unknown])
>             perf  352917 49604.161099:     181013 instructions:
> ffffffff8ce00080 [unknown] ([unknown])
>             perf  352917 49604.161115:       8811 instructions:
> 7f155cad22d0 strcmp+0x8b0
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.161115:       8811 instructions:
> 7f155cad22d0 strcmp+0x8b0
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.161130:      10483 instructions:
> 7f155caba508 _dl_new_object+0x198
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.161130:      10483 instructions:
> 7f155caba508 _dl_new_object+0x198
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.165156:     177355 instructions:
> 7f155cab90a4 _dl_lookup_symbol_x+0x44
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
>             perf  352917 49604.165156:   13313598 instructions:
> 7f155cab90a4 _dl_lookup_symbol_x+0x44
> (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> ...
> ```
>
> Dapeng/Kan, any thoughts why the counts don't match for instructions
> but did for branches?


That looks strange,  what's your kernel version and perf-tool version? I
just tried the latest perf-tools-next branch, but I don't see this issue.



>
> Thanks,
> Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests: Make leader sampling test work without branch event
  2024-12-23  9:04       ` Mi, Dapeng
@ 2025-01-09 21:43         ` Ian Rogers
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-01-09 21:43 UTC (permalink / raw)
  To: Mi, Dapeng, Liang, Kan
  Cc: Arnaldo Carvalho de Melo, James Clark, linux-perf-users,
	Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Veronika Molnarova,
	linux-kernel

On Mon, Dec 23, 2024 at 1:04 AM Mi, Dapeng <dapeng1.mi@linux.intel.com> wrote:
>
>
> On 12/21/2024 3:08 PM, Ian Rogers wrote:
> > On Sat, Nov 16, 2024 at 11:28 AM Arnaldo Carvalho de Melo
> > <acme@kernel.org> wrote:
> >> On Fri, Nov 15, 2024 at 10:54:43AM -0800, Ian Rogers wrote:
> >>> On Fri, Nov 15, 2024 at 8:16 AM James Clark <james.clark@linaro.org> wrote:
> >>>> Arm a57 only has speculative branch events so this test fails there. The
> >>>> test doesn't depend on branch instructions so change it to instructions
> >>>> which is pretty much guaranteed to be everywhere. The
> >>>> test_branch_counter() test above already tests for the existence of the
> >>>> branches event and skips if its not present.
> >>>>
> >>>> Signed-off-by: James Clark <james.clark@linaro.org>
> >>> Reviewed-by: Ian Rogers <irogers@google.com>
> >> Thanks, applied to perf-tools-next,
> > Rebasing on perf-tools-next I see this failing on my Intel Tigerlake
> > laptop. An example script output for:
> > ```
> >  perf record -o "${perfdata}" -e "{instructions,instructions}:Su"
> > ```
> > is:
> > ```
> >             perf  352917 49604.160314:          3 instructions:
> > 7f155caca323 [unknown]
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.160314:          3 instructions:
> > 7f155caca323 [unknown]
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.160317:         18 instructions:
> > 7f155cacaf3d _dl_start+0x3d
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.160317:         18 instructions:
> > 7f155cacaf3d _dl_start+0x3d
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.160319:          3 instructions:
> > 7f155cacaf44 _dl_start+0x44
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.160319:          3 instructions:
> > 7f155cacaf44 _dl_start+0x44
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.161099:        120 instructions:
> > ffffffff8ce00080 [unknown] ([unknown])
> >             perf  352917 49604.161099:     181013 instructions:
> > ffffffff8ce00080 [unknown] ([unknown])
> >             perf  352917 49604.161115:       8811 instructions:
> > 7f155cad22d0 strcmp+0x8b0
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.161115:       8811 instructions:
> > 7f155cad22d0 strcmp+0x8b0
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.161130:      10483 instructions:
> > 7f155caba508 _dl_new_object+0x198
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.161130:      10483 instructions:
> > 7f155caba508 _dl_new_object+0x198
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.165156:     177355 instructions:
> > 7f155cab90a4 _dl_lookup_symbol_x+0x44
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> >             perf  352917 49604.165156:   13313598 instructions:
> > 7f155cab90a4 _dl_lookup_symbol_x+0x44
> > (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
> > ...
> > ```
> >
> > Dapeng/Kan, any thoughts why the counts don't match for instructions
> > but did for branches?
>
>
> That looks strange,  what's your kernel version and perf-tool version? I
> just tried the latest perf-tools-next branch, but I don't see this issue.

It seems to have cleared up for me. I'll speak up again if I can get a
reproduction.

Thanks,
Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-09 21:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 16:15 [PATCH] perf tests: Make leader sampling test work without branch event James Clark
2024-11-15 18:54 ` Ian Rogers
2024-11-16 19:28   ` Arnaldo Carvalho de Melo
2024-12-21  7:08     ` Ian Rogers
2024-12-23  9:04       ` Mi, Dapeng
2025-01-09 21:43         ` Ian Rogers

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).