linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf test: Add skip to --per-thread test
@ 2022-04-29  6:13 Ian Rogers
  2022-05-02  9:39 ` Thomas Richter
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2022-04-29  6:13 UTC (permalink / raw)
  To: Thomas Richter, linux-kernel, linux-perf-users, acme, Jiri Olsa,
	Namhyung Kim
  Cc: svens, gor, sumanthk, hca, Ian Rogers

As reported in:
https://lore.kernel.org/linux-perf-users/20220428122821.3652015-1-tmricht@linux.ibm.com/
the 'instructions:u' event may not be supported. Add a skip using 'perf
stat'.

Switch some code away from pipe to make the failures clearer.

Reported-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/shell/record.sh | 44 +++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index cd1cf14259b8..efc0cb07a929 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -5,11 +5,43 @@
 set -e
 
 err=0
+perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
+
+cleanup() {
+  rm -f ${perfdata}
+  rm -f ${perfdata}.old
+  trap - exit term int
+}
+
+trap_cleanup() {
+  cleanup
+  exit 1
+}
+trap trap_cleanup exit term int
+
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  perf record -e instructions:u --per-thread -o- true 2> /dev/null \
-    | perf report -i- -q \
-    | egrep -q true
+  if ! perf stat -e instructions:u --quiet true
+  then
+    echo "Per-thread record [Skipped instructions:u not supported]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
+    return
+  fi
+  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
+  then
+    echo "Per-thread record of instructions:u [Failed]"
+    err=1
+    return
+  fi
+  if ! perf report -i ${perfdata} -q | egrep -q true
+  then
+    echo "Per-thread record [Failed missing output]"
+    err=1
+    return
+  fi
   echo "Basic --per-thread mode test [Success]"
 }
 
@@ -18,6 +50,10 @@ test_register_capture() {
   if ! perf list | egrep -q 'br_inst_retired.near_call'
   then
     echo "Register capture test [Skipped missing instruction]"
+    if [ $err -ne 1 ]
+    then
+      err=2
+    fi
     return
   fi
   if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
@@ -39,4 +75,6 @@ test_register_capture() {
 
 test_per_thread
 test_register_capture
+
+cleanup
 exit $err
-- 
2.36.0.464.gb9c8b46e94-goog


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

* Re: [PATCH] perf test: Add skip to --per-thread test
  2022-04-29  6:13 [PATCH] perf test: Add skip to --per-thread test Ian Rogers
@ 2022-05-02  9:39 ` Thomas Richter
  2022-05-03  4:33   ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Richter @ 2022-05-02  9:39 UTC (permalink / raw)
  To: Ian Rogers, linux-kernel, linux-perf-users, acme, Jiri Olsa,
	Namhyung Kim
  Cc: svens, gor, sumanthk, hca

On 4/29/22 08:13, Ian Rogers wrote:
> As reported in:
> https://lore.kernel.org/linux-perf-users/20220428122821.3652015-1-tmricht@linux.ibm.com/
> the 'instructions:u' event may not be supported. Add a skip using 'perf
> stat'.
> 
> Switch some code away from pipe to make the failures clearer.
> 
> Reported-by: Thomas Richter <tmricht@linux.ibm.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/tests/shell/record.sh | 44 +++++++++++++++++++++++++++++---
>  1 file changed, 41 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index cd1cf14259b8..efc0cb07a929 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -5,11 +5,43 @@
>  set -e
>  
>  err=0
> +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> +
> +cleanup() {
> +  rm -f ${perfdata}
> +  rm -f ${perfdata}.old
> +  trap - exit term int
> +}
> +
> +trap_cleanup() {
> +  cleanup
> +  exit 1
> +}
> +trap trap_cleanup exit term int
> +
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> -  perf record -e instructions:u --per-thread -o- true 2> /dev/null \
> -    | perf report -i- -q \
> -    | egrep -q true
> +  if ! perf stat -e instructions:u --quiet true
> +  then
> +    echo "Per-thread record [Skipped instructions:u not supported]"
> +    if [ $err -ne 1 ]
> +    then
> +      err=2
> +    fi
> +    return
> +  fi
> +  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
> +  then
> +    echo "Per-thread record of instructions:u [Failed]"
> +    err=1
> +    return
> +  fi
> +  if ! perf report -i ${perfdata} -q | egrep -q true
> +  then
> +    echo "Per-thread record [Failed missing output]"
> +    err=1
> +    return
> +  fi
>    echo "Basic --per-thread mode test [Success]"
>  }
>  
> @@ -18,6 +50,10 @@ test_register_capture() {
>    if ! perf list | egrep -q 'br_inst_retired.near_call'
>    then
>      echo "Register capture test [Skipped missing instruction]"
> +    if [ $err -ne 1 ]
> +    then
> +      err=2
> +    fi
>      return
>    fi
>    if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> @@ -39,4 +75,6 @@ test_register_capture() {
>  
>  test_per_thread
>  test_register_capture
> +
> +cleanup
>  exit $err

Ian,

thanks very much for looking into this.
I have tested your patch on several configurations and to be perfect, please
change this line:
# git diff
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index efc0cb07a929..9cb8494f314d 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -21,7 +21,7 @@ trap trap_cleanup exit term int
 
 test_per_thread() {
   echo "Basic --per-thread mode test"
-  if ! perf stat -e instructions:u --quiet true
+  if ! perf record -e instructions:u --quiet true 2> /dev/null
   then
     echo "Per-thread record [Skipped instructions:u not supported]"
     if [ $err -ne 1 ]
# 

This runs fine, just use record instead of stat, you use perf record later
on anyway.

With this change you have my
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
-- 
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

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

* Re: [PATCH] perf test: Add skip to --per-thread test
  2022-05-02  9:39 ` Thomas Richter
@ 2022-05-03  4:33   ` Ian Rogers
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2022-05-03  4:33 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, acme, Jiri Olsa, Namhyung Kim,
	svens, gor, sumanthk, hca

On Mon, May 2, 2022 at 2:39 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> On 4/29/22 08:13, Ian Rogers wrote:
> > As reported in:
> > https://lore.kernel.org/linux-perf-users/20220428122821.3652015-1-tmricht@linux.ibm.com/
> > the 'instructions:u' event may not be supported. Add a skip using 'perf
> > stat'.
> >
> > Switch some code away from pipe to make the failures clearer.
> >
> > Reported-by: Thomas Richter <tmricht@linux.ibm.com>
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/tests/shell/record.sh | 44 +++++++++++++++++++++++++++++---
> >  1 file changed, 41 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> > index cd1cf14259b8..efc0cb07a929 100755
> > --- a/tools/perf/tests/shell/record.sh
> > +++ b/tools/perf/tests/shell/record.sh
> > @@ -5,11 +5,43 @@
> >  set -e
> >
> >  err=0
> > +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> > +
> > +cleanup() {
> > +  rm -f ${perfdata}
> > +  rm -f ${perfdata}.old
> > +  trap - exit term int
> > +}
> > +
> > +trap_cleanup() {
> > +  cleanup
> > +  exit 1
> > +}
> > +trap trap_cleanup exit term int
> > +
> >  test_per_thread() {
> >    echo "Basic --per-thread mode test"
> > -  perf record -e instructions:u --per-thread -o- true 2> /dev/null \
> > -    | perf report -i- -q \
> > -    | egrep -q true
> > +  if ! perf stat -e instructions:u --quiet true
> > +  then
> > +    echo "Per-thread record [Skipped instructions:u not supported]"
> > +    if [ $err -ne 1 ]
> > +    then
> > +      err=2
> > +    fi
> > +    return
> > +  fi
> > +  if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null
> > +  then
> > +    echo "Per-thread record of instructions:u [Failed]"
> > +    err=1
> > +    return
> > +  fi
> > +  if ! perf report -i ${perfdata} -q | egrep -q true
> > +  then
> > +    echo "Per-thread record [Failed missing output]"
> > +    err=1
> > +    return
> > +  fi
> >    echo "Basic --per-thread mode test [Success]"
> >  }
> >
> > @@ -18,6 +50,10 @@ test_register_capture() {
> >    if ! perf list | egrep -q 'br_inst_retired.near_call'
> >    then
> >      echo "Register capture test [Skipped missing instruction]"
> > +    if [ $err -ne 1 ]
> > +    then
> > +      err=2
> > +    fi
> >      return
> >    fi
> >    if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
> > @@ -39,4 +75,6 @@ test_register_capture() {
> >
> >  test_per_thread
> >  test_register_capture
> > +
> > +cleanup
> >  exit $err
>
> Ian,
>
> thanks very much for looking into this.
> I have tested your patch on several configurations and to be perfect, please
> change this line:
> # git diff
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index efc0cb07a929..9cb8494f314d 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -21,7 +21,7 @@ trap trap_cleanup exit term int
>
>  test_per_thread() {
>    echo "Basic --per-thread mode test"
> -  if ! perf stat -e instructions:u --quiet true
> +  if ! perf record -e instructions:u --quiet true 2> /dev/null
>    then
>      echo "Per-thread record [Skipped instructions:u not supported]"
>      if [ $err -ne 1 ]
> #
>
> This runs fine, just use record instead of stat, you use perf record later
> on anyway.
>
> With this change you have my
> Tested-by: Thomas Richter <tmricht@linux.ibm.com>

Thanks! Done, but I also add a '-o' in v2 so the perf.data file is
cleaned up by the cleanup function.

Ian

> --
> Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> --
> Vorsitzender des Aufsichtsrats: Gregor Pillen
> Geschäftsführung: David Faller
> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

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

end of thread, other threads:[~2022-05-03  4:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29  6:13 [PATCH] perf test: Add skip to --per-thread test Ian Rogers
2022-05-02  9:39 ` Thomas Richter
2022-05-03  4:33   ` 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).