linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
@ 2025-01-28  4:37 Ian Rogers
  2025-01-28 17:42 ` Namhyung Kim
  2025-01-29 17:57 ` Falcon, Thomas
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Rogers @ 2025-01-28  4:37 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, James Clark, Weilin Wang,
	linux-perf-users, linux-kernel

Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
hypervisor the cache-misses event may not be present. Skip the test
under this condition.

Refactor the output code to be placed in a file so that on a signal
the file can be dumped. This was necessary to catch the issue above as
the failing perf record command would fail without output.

Signed-off-by: Ian Rogers <irogers@google.com>
---
v2: Fix lost :R and use :p with record as it is ignored by perf stat.
---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++--------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
index 695dcb93bb5e..a330ecdb7ba5 100755
--- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
+++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
@@ -20,31 +20,39 @@ then
   exit 2
 fi
 
+stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
+
 cleanup() {
+  rm -rf "${stat_output}"
   trap - EXIT TERM INT
 }
 
 trap_cleanup() {
   echo "Unexpected signal in ${FUNCNAME[1]}"
+  cat "${stat_output}"
   cleanup
   exit 1
 }
 trap trap_cleanup EXIT TERM INT
 
-# Use this event for testing because it should exist in all platforms
-event=cache-misses:R
-
-# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as above
-alt_name=/cache-misses/R
+# Event to be used in tests
+event=cache-misses
 
-# Without this cmd option, default value or zero is returned
-#echo "Testing without --record-tpebs"
-#result=$(perf stat -e "$event" true 2>&1)
-#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
+if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_output}" 2>&1
+then
+  echo "Missing ${event} support"
+  cleanup
+  exit 2
+fi
 
 test_with_record_tpebs() {
   echo "Testing with --record-tpebs"
-  result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+  if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 > "${stat_output}" 2>&1
+  then
+    echo "Testing with --record-tpebs [Failed perf stat]"
+    cat "${stat_output}"
+    exit 1
+  fi
 
   # Expected output:
   # $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
@@ -57,16 +65,16 @@ test_with_record_tpebs() {
   #                  0      cache-misses:R
   #
   #        0.013963299 seconds time elapsed
-  if [[ ! "$result" =~ "perf record" ]]
+  if ! grep "perf record" "${stat_output}"
   then
     echo "Testing with --record-tpebs [Failed missing perf record]"
-    echo "$result"
+    cat "${stat_output}"
     exit 1
   fi
-  if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
+  if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R" "${stat_output}"
   then
     echo "Testing with --record-tpebs [Failed missing event name]"
-    echo "$result"
+    cat "${stat_output}"
     exit 1
   fi
   echo "Testing with --record-tpebs [Success]"
-- 
2.48.1.262.g85cc9f2d1e-goog


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

* Re: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
  2025-01-28  4:37 [PATCH v2] perf test: Skip Intel TPEBS under hypervisor Ian Rogers
@ 2025-01-28 17:42 ` Namhyung Kim
  2025-01-28 17:59   ` Ian Rogers
  2025-01-29 17:57 ` Falcon, Thomas
  1 sibling, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2025-01-28 17:42 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, Weilin Wang, linux-perf-users,
	linux-kernel

On Mon, Jan 27, 2025 at 08:37:39PM -0800, Ian Rogers wrote:
> Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
> hypervisor the cache-misses event may not be present. Skip the test
> under this condition.
> 
> Refactor the output code to be placed in a file so that on a signal
> the file can be dumped. This was necessary to catch the issue above as
> the failing perf record command would fail without output.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> v2: Fix lost :R and use :p with record as it is ignored by perf stat.
> ---
>  .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++--------
>  1 file changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> index 695dcb93bb5e..a330ecdb7ba5 100755
> --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> @@ -20,31 +20,39 @@ then
>    exit 2
>  fi
>  
> +stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
> +
>  cleanup() {
> +  rm -rf "${stat_output}"
>    trap - EXIT TERM INT
>  }
>  
>  trap_cleanup() {
>    echo "Unexpected signal in ${FUNCNAME[1]}"
> +  cat "${stat_output}"
>    cleanup
>    exit 1
>  }
>  trap trap_cleanup EXIT TERM INT
>  
> -# Use this event for testing because it should exist in all platforms
> -event=cache-misses:R
> -
> -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as above
> -alt_name=/cache-misses/R
> +# Event to be used in tests
> +event=cache-misses
>  
> -# Without this cmd option, default value or zero is returned
> -#echo "Testing without --record-tpebs"
> -#result=$(perf stat -e "$event" true 2>&1)
> -#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
> +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_output}" 2>&1

Shouldn't it simply be

  if ! perf list hw | grep -q cache-misses

?  Doesn't it work on hybrid?

Thanks,
Namhyung


> +then
> +  echo "Missing ${event} support"
> +  cleanup
> +  exit 2
> +fi
>  
>  test_with_record_tpebs() {
>    echo "Testing with --record-tpebs"
> -  result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> +  if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 > "${stat_output}" 2>&1
> +  then
> +    echo "Testing with --record-tpebs [Failed perf stat]"
> +    cat "${stat_output}"
> +    exit 1
> +  fi
>  
>    # Expected output:
>    # $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
> @@ -57,16 +65,16 @@ test_with_record_tpebs() {
>    #                  0      cache-misses:R
>    #
>    #        0.013963299 seconds time elapsed
> -  if [[ ! "$result" =~ "perf record" ]]
> +  if ! grep "perf record" "${stat_output}"
>    then
>      echo "Testing with --record-tpebs [Failed missing perf record]"
> -    echo "$result"
> +    cat "${stat_output}"
>      exit 1
>    fi
> -  if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
> +  if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R" "${stat_output}"
>    then
>      echo "Testing with --record-tpebs [Failed missing event name]"
> -    echo "$result"
> +    cat "${stat_output}"
>      exit 1
>    fi
>    echo "Testing with --record-tpebs [Success]"
> -- 
> 2.48.1.262.g85cc9f2d1e-goog
> 

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

* Re: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
  2025-01-28 17:42 ` Namhyung Kim
@ 2025-01-28 17:59   ` Ian Rogers
  2025-01-29 22:10     ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2025-01-28 17:59 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, Weilin Wang, linux-perf-users,
	linux-kernel

On Tue, Jan 28, 2025 at 9:42 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Mon, Jan 27, 2025 at 08:37:39PM -0800, Ian Rogers wrote:
> > Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
> > hypervisor the cache-misses event may not be present. Skip the test
> > under this condition.
> >
> > Refactor the output code to be placed in a file so that on a signal
> > the file can be dumped. This was necessary to catch the issue above as
> > the failing perf record command would fail without output.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > v2: Fix lost :R and use :p with record as it is ignored by perf stat.
> > ---
> >  .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++--------
> >  1 file changed, 22 insertions(+), 14 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > index 695dcb93bb5e..a330ecdb7ba5 100755
> > --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > @@ -20,31 +20,39 @@ then
> >    exit 2
> >  fi
> >
> > +stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
> > +
> >  cleanup() {
> > +  rm -rf "${stat_output}"
> >    trap - EXIT TERM INT
> >  }
> >
> >  trap_cleanup() {
> >    echo "Unexpected signal in ${FUNCNAME[1]}"
> > +  cat "${stat_output}"
> >    cleanup
> >    exit 1
> >  }
> >  trap trap_cleanup EXIT TERM INT
> >
> > -# Use this event for testing because it should exist in all platforms
> > -event=cache-misses:R
> > -
> > -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as above
> > -alt_name=/cache-misses/R
> > +# Event to be used in tests
> > +event=cache-misses
> >
> > -# Without this cmd option, default value or zero is returned
> > -#echo "Testing without --record-tpebs"
> > -#result=$(perf stat -e "$event" true 2>&1)
> > -#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
> > +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_output}" 2>&1
>
> Shouldn't it simply be
>
>   if ! perf list hw | grep -q cache-misses

No, because that would succeed even if precise events weren't supported.

> ?  Doesn't it work on hybrid?

Untested, but I don't see a difference between grepping an event from
a file to using a match in a bash line. Neither specify a PMU so it is
unclear to me why you'd think this would break.

Thanks,
Ian

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

* Re: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
  2025-01-28  4:37 [PATCH v2] perf test: Skip Intel TPEBS under hypervisor Ian Rogers
  2025-01-28 17:42 ` Namhyung Kim
@ 2025-01-29 17:57 ` Falcon, Thomas
  2025-01-30 16:41   ` Ian Rogers
  1 sibling, 1 reply; 6+ messages in thread
From: Falcon, Thomas @ 2025-01-29 17:57 UTC (permalink / raw)
  To: james.clark@linaro.org, alexander.shishkin@linux.intel.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	peterz@infradead.org, acme@kernel.org, mingo@redhat.com,
	mark.rutland@arm.com, Hunter, Adrian, namhyung@kernel.org,
	jolsa@kernel.org, kan.liang@linux.intel.com, irogers@google.com,
	Wang, Weilin

On Mon, 2025-01-27 at 20:37 -0800, Ian Rogers wrote:
> Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
> hypervisor the cache-misses event may not be present. Skip the test
> under this condition.
> 
> Refactor the output code to be placed in a file so that on a signal
> the file can be dumped. This was necessary to catch the issue above
> as
> the failing perf record command would fail without output.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Hi, sorry, but I'm unable to apply this patch to perf-tools or perf-
tools-next? What repository should I use to test this?

Thanks,
Tom

> ---
> v2: Fix lost :R and use :p with record as it is ignored by perf stat.
> ---
>  .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++------
> --
>  1 file changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> index 695dcb93bb5e..a330ecdb7ba5 100755
> --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> @@ -20,31 +20,39 @@ then
>    exit 2
>  fi
>  
> +stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
> +
>  cleanup() {
> +  rm -rf "${stat_output}"
>    trap - EXIT TERM INT
>  }
>  
>  trap_cleanup() {
>    echo "Unexpected signal in ${FUNCNAME[1]}"
> +  cat "${stat_output}"
>    cleanup
>    exit 1
>  }
>  trap trap_cleanup EXIT TERM INT
>  
> -# Use this event for testing because it should exist in all
> platforms
> -event=cache-misses:R
> -
> -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather
> than as above
> -alt_name=/cache-misses/R
> +# Event to be used in tests
> +event=cache-misses
>  
> -# Without this cmd option, default value or zero is returned
> -#echo "Testing without --record-tpebs"
> -#result=$(perf stat -e "$event" true 2>&1)
> -#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
> +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 >
> "${stat_output}" 2>&1
> +then
> +  echo "Missing ${event} support"
> +  cleanup
> +  exit 2
> +fi
>  
>  test_with_record_tpebs() {
>    echo "Testing with --record-tpebs"
> -  result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> +  if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 >
> "${stat_output}" 2>&1
> +  then
> +    echo "Testing with --record-tpebs [Failed perf stat]"
> +    cat "${stat_output}"
> +    exit 1
> +  fi
>  
>    # Expected output:
>    # $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
> @@ -57,16 +65,16 @@ test_with_record_tpebs() {
>    #                  0      cache-misses:R
>    #
>    #        0.013963299 seconds time elapsed
> -  if [[ ! "$result" =~ "perf record" ]]
> +  if ! grep "perf record" "${stat_output}"
>    then
>      echo "Testing with --record-tpebs [Failed missing perf record]"
> -    echo "$result"
> +    cat "${stat_output}"
>      exit 1
>    fi
> -  if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
> +  if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R"
> "${stat_output}"
>    then
>      echo "Testing with --record-tpebs [Failed missing event name]"
> -    echo "$result"
> +    cat "${stat_output}"
>      exit 1
>    fi
>    echo "Testing with --record-tpebs [Success]"


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

* Re: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
  2025-01-28 17:59   ` Ian Rogers
@ 2025-01-29 22:10     ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2025-01-29 22:10 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, Weilin Wang, linux-perf-users,
	linux-kernel

On Tue, Jan 28, 2025 at 09:59:38AM -0800, Ian Rogers wrote:
> On Tue, Jan 28, 2025 at 9:42 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Mon, Jan 27, 2025 at 08:37:39PM -0800, Ian Rogers wrote:
> > > Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
> > > hypervisor the cache-misses event may not be present. Skip the test
> > > under this condition.
> > >
> > > Refactor the output code to be placed in a file so that on a signal
> > > the file can be dumped. This was necessary to catch the issue above as
> > > the failing perf record command would fail without output.
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > > v2: Fix lost :R and use :p with record as it is ignored by perf stat.
> > > ---
> > >  .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++--------
> > >  1 file changed, 22 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > index 695dcb93bb5e..a330ecdb7ba5 100755
> > > --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > @@ -20,31 +20,39 @@ then
> > >    exit 2
> > >  fi
> > >
> > > +stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
> > > +
> > >  cleanup() {
> > > +  rm -rf "${stat_output}"
> > >    trap - EXIT TERM INT
> > >  }
> > >
> > >  trap_cleanup() {
> > >    echo "Unexpected signal in ${FUNCNAME[1]}"
> > > +  cat "${stat_output}"
> > >    cleanup
> > >    exit 1
> > >  }
> > >  trap trap_cleanup EXIT TERM INT
> > >
> > > -# Use this event for testing because it should exist in all platforms
> > > -event=cache-misses:R
> > > -
> > > -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as above
> > > -alt_name=/cache-misses/R
> > > +# Event to be used in tests
> > > +event=cache-misses
> > >
> > > -# Without this cmd option, default value or zero is returned
> > > -#echo "Testing without --record-tpebs"
> > > -#result=$(perf stat -e "$event" true 2>&1)
> > > -#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
> > > +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 > "${stat_output}" 2>&1
> >
> > Shouldn't it simply be
> >
> >   if ! perf list hw | grep -q cache-misses
> 
> No, because that would succeed even if precise events weren't supported.

Oh I see.

> 
> > ?  Doesn't it work on hybrid?
> 
> Untested, but I don't see a difference between grepping an event from
> a file to using a match in a bash line. Neither specify a PMU so it is
> unclear to me why you'd think this would break.

No specific reason.  I thought checking `perf list` would be more
intuitive and then started to think there should be a reason.

Thanks,
Namhyung


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

* Re: [PATCH v2] perf test: Skip Intel TPEBS under hypervisor
  2025-01-29 17:57 ` Falcon, Thomas
@ 2025-01-30 16:41   ` Ian Rogers
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-01-30 16:41 UTC (permalink / raw)
  To: Falcon, Thomas
  Cc: james.clark@linaro.org, alexander.shishkin@linux.intel.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	peterz@infradead.org, acme@kernel.org, mingo@redhat.com,
	mark.rutland@arm.com, Hunter, Adrian, namhyung@kernel.org,
	jolsa@kernel.org, kan.liang@linux.intel.com, Wang, Weilin

On Wed, Jan 29, 2025 at 9:57 AM Falcon, Thomas <thomas.falcon@intel.com> wrote:
>
> On Mon, 2025-01-27 at 20:37 -0800, Ian Rogers wrote:
> > Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
> > hypervisor the cache-misses event may not be present. Skip the test
> > under this condition.
> >
> > Refactor the output code to be placed in a file so that on a signal
> > the file can be dumped. This was necessary to catch the issue above
> > as
> > the failing perf record command would fail without output.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Hi, sorry, but I'm unable to apply this patch to perf-tools or perf-
> tools-next? What repository should I use to test this?

Hi Tom,

sorry for this. I'll rebase/squash Google's patches [1] for this test
and resend as v2. I hadn't realized how much was missing when sending
this.

Thanks,
Ian

[1] https://github.com/googleprodkernel/linux-perf/commits/google_tools_master/tools/perf/tests/shell/test_stat_intel_tpebs.sh

> Thanks,
> Tom
>
> > ---
> > v2: Fix lost :R and use :p with record as it is ignored by perf stat.
> > ---
> >  .../perf/tests/shell/test_stat_intel_tpebs.sh | 36 +++++++++++------
> > --
> >  1 file changed, 22 insertions(+), 14 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > index 695dcb93bb5e..a330ecdb7ba5 100755
> > --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > @@ -20,31 +20,39 @@ then
> >    exit 2
> >  fi
> >
> > +stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
> > +
> >  cleanup() {
> > +  rm -rf "${stat_output}"
> >    trap - EXIT TERM INT
> >  }
> >
> >  trap_cleanup() {
> >    echo "Unexpected signal in ${FUNCNAME[1]}"
> > +  cat "${stat_output}"
> >    cleanup
> >    exit 1
> >  }
> >  trap trap_cleanup EXIT TERM INT
> >
> > -# Use this event for testing because it should exist in all
> > platforms
> > -event=cache-misses:R
> > -
> > -# Hybrid platforms output like "cpu_atom/cache-misses/R", rather
> > than as above
> > -alt_name=/cache-misses/R
> > +# Event to be used in tests
> > +event=cache-misses
> >
> > -# Without this cmd option, default value or zero is returned
> > -#echo "Testing without --record-tpebs"
> > -#result=$(perf stat -e "$event" true 2>&1)
> > -#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
> > +if ! perf record -e "${event}:p" -a -o /dev/null sleep 0.01 >
> > "${stat_output}" 2>&1
> > +then
> > +  echo "Missing ${event} support"
> > +  cleanup
> > +  exit 2
> > +fi
> >
> >  test_with_record_tpebs() {
> >    echo "Testing with --record-tpebs"
> > -  result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> > +  if ! perf stat -e "${event}:R" --record-tpebs -a sleep 0.01 >
> > "${stat_output}" 2>&1
> > +  then
> > +    echo "Testing with --record-tpebs [Failed perf stat]"
> > +    cat "${stat_output}"
> > +    exit 1
> > +  fi
> >
> >    # Expected output:
> >    # $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
> > @@ -57,16 +65,16 @@ test_with_record_tpebs() {
> >    #                  0      cache-misses:R
> >    #
> >    #        0.013963299 seconds time elapsed
> > -  if [[ ! "$result" =~ "perf record" ]]
> > +  if ! grep "perf record" "${stat_output}"
> >    then
> >      echo "Testing with --record-tpebs [Failed missing perf record]"
> > -    echo "$result"
> > +    cat "${stat_output}"
> >      exit 1
> >    fi
> > -  if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
> > +  if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R"
> > "${stat_output}"
> >    then
> >      echo "Testing with --record-tpebs [Failed missing event name]"
> > -    echo "$result"
> > +    cat "${stat_output}"
> >      exit 1
> >    fi
> >    echo "Testing with --record-tpebs [Success]"
>

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

end of thread, other threads:[~2025-01-30 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-28  4:37 [PATCH v2] perf test: Skip Intel TPEBS under hypervisor Ian Rogers
2025-01-28 17:42 ` Namhyung Kim
2025-01-28 17:59   ` Ian Rogers
2025-01-29 22:10     ` Namhyung Kim
2025-01-29 17:57 ` Falcon, Thomas
2025-01-30 16:41   ` 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).