From: Weilin Wang <weilin.wang@intel.com>
Intel TPEBS sampling mode is supported through perf record. The counting mode
code uses perf record to capture retire_latency value and use it in metric
calculation. This test checks the counting mode code on Intel platforms.
Signed-off-by: Weilin Wang <weilin.wang@intel.com>
---
.../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
new file mode 100755
index 000000000000..c60b29add980
--- /dev/null
+++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# 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 ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
--
2.43.0
On Sat, Jul 20, 2024 at 02:21:01AM -0400, weilin.wang@intel.com wrote:
> From: Weilin Wang <weilin.wang@intel.com>
>
> Intel TPEBS sampling mode is supported through perf record. The counting mode
> code uses perf record to capture retire_latency value and use it in metric
> calculation. This test checks the counting mode code on Intel platforms.
root@x1:~# perf test -vvvvv 123
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 2600160
Testing without --record-tpebs
Testing with --record-tpebs
---- end(-1) ----
123: test Intel TPEBS counting mode : FAILED!
root@x1:~# grep -m1 "model name" /proc/cpuinfo
model name : 13th Gen Intel(R) Core(TM) i7-1365U
root@x1:~#
What am I missing?
The current codebase is in tmp.perf-tools-next
- Arnaldo
> Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> ---
> .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
> create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
>
> diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> new file mode 100755
> index 000000000000..c60b29add980
> --- /dev/null
> +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> @@ -0,0 +1,19 @@
> +#!/bin/bash
> +# test Intel TPEBS counting mode
> +# SPDX-License-Identifier: GPL-2.0
> +
> +set -e
> +grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
> +
> +# Use this event for testing because it should exist in all platforms
> +event=cache-misses:R
> +
> +# 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 ]] || exit 1
> +
> +# In platforms that do not support TPEBS, it should execute without error.
> +echo "Testing with --record-tpebs"
> +result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> +[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
> --
> 2.43.0
>
On Mon, Aug 12, 2024 at 10:24:40PM -0300, Arnaldo Carvalho de Melo wrote:
> On Sat, Jul 20, 2024 at 02:21:01AM -0400, weilin.wang@intel.com wrote:
> > From: Weilin Wang <weilin.wang@intel.com>
> >
> > Intel TPEBS sampling mode is supported through perf record. The counting mode
> > code uses perf record to capture retire_latency value and use it in metric
> > calculation. This test checks the counting mode code on Intel platforms.
>
> root@x1:~# perf test -vvvvv 123
> 123: test Intel TPEBS counting mode:
> --- start ---
> test child forked, pid 2600160
> Testing without --record-tpebs
> Testing with --record-tpebs
> ---- end(-1) ----
> 123: test Intel TPEBS counting mode : FAILED!
> root@x1:~# grep -m1 "model name" /proc/cpuinfo
> model name : 13th Gen Intel(R) Core(TM) i7-1365U
> root@x1:~#
>
> What am I missing?
>
> The current codebase is in tmp.perf-tools-next
acme@x1:~/git/perf-tools-next$ uname -a
Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26 20:05:41 UTC 2024 x86_64 GNU/Linux
> - Arnaldo
>
> > Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> > ---
> > .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> > create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
> >
> > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > new file mode 100755
> > index 000000000000..c60b29add980
> > --- /dev/null
> > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > @@ -0,0 +1,19 @@
> > +#!/bin/bash
> > +# test Intel TPEBS counting mode
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +set -e
> > +grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
> > +
> > +# Use this event for testing because it should exist in all platforms
> > +event=cache-misses:R
> > +
> > +# 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 ]] || exit 1
> > +
> > +# In platforms that do not support TPEBS, it should execute without error.
> > +echo "Testing with --record-tpebs"
> > +result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> > +[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
> > --
> > 2.43.0
> >
> -----Original Message-----
> From: Arnaldo Carvalho de Melo <acme@kernel.org>
> Sent: Monday, August 12, 2024 6:26 PM
> To: Wang, Weilin <weilin.wang@intel.com>
> Cc: Namhyung Kim <namhyung@kernel.org>; Ian Rogers
> <irogers@google.com>; Peter Zijlstra <peterz@infradead.org>; Ingo Molnar
> <mingo@redhat.com>; Alexander Shishkin
> <alexander.shishkin@linux.intel.com>; Jiri Olsa <jolsa@kernel.org>; Hunter,
> Adrian <adrian.hunter@intel.com>; Kan Liang <kan.liang@linux.intel.com>;
> linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor, Perry
> <perry.taylor@intel.com>; Alt, Samantha <samantha.alt@intel.com>; Biggers,
> Caleb <caleb.biggers@intel.com>
> Subject: Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting
> mode
>
> On Mon, Aug 12, 2024 at 10:24:40PM -0300, Arnaldo Carvalho de Melo
> wrote:
> > On Sat, Jul 20, 2024 at 02:21:01AM -0400, weilin.wang@intel.com wrote:
> > > From: Weilin Wang <weilin.wang@intel.com>
> > >
> > > Intel TPEBS sampling mode is supported through perf record. The counting
> mode
> > > code uses perf record to capture retire_latency value and use it in metric
> > > calculation. This test checks the counting mode code on Intel platforms.
> >
> > root@x1:~# perf test -vvvvv 123
> > 123: test Intel TPEBS counting mode:
> > --- start ---
> > test child forked, pid 2600160
> > Testing without --record-tpebs
> > Testing with --record-tpebs
> > ---- end(-1) ----
> > 123: test Intel TPEBS counting mode : FAILED!
> > root@x1:~# grep -m1 "model name" /proc/cpuinfo
> > model name : 13th Gen Intel(R) Core(TM) i7-1365U
> > root@x1:~#
> >
> > What am I missing?
> >
> > The current codebase is in tmp.perf-tools-next
>
> acme@x1:~/git/perf-tools-next$ uname -a
> Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26
> 20:05:41 UTC 2024 x86_64 GNU/Linux
>
Hi Arnaldo,
I just checkout the code and tested it. The failure is caused by a seg fault on a
perf_tool struct that is not initialized correctly. I think this is related to the patches
on struct perf_tool in this branch that applied right before the tpebs patches.
I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since
Ian updated the code to replace this function, I think I need some advice on how
to use the new code to initialize perf_tool correctly here. Should I call the
perf_tool__init()?
Thanks,
Weilin
> > - Arnaldo
> >
> > > Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> > > ---
> > > .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
> > > 1 file changed, 19 insertions(+)
> > > create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > >
> > > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > new file mode 100755
> > > index 000000000000..c60b29add980
> > > --- /dev/null
> > > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > @@ -0,0 +1,19 @@
> > > +#!/bin/bash
> > > +# test Intel TPEBS counting mode
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +
> > > +set -e
> > > +grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
> > > +
> > > +# Use this event for testing because it should exist in all platforms
> > > +event=cache-misses:R
> > > +
> > > +# 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 ]] || exit 1
> > > +
> > > +# In platforms that do not support TPEBS, it should execute without error.
> > > +echo "Testing with --record-tpebs"
> > > +result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> > > +[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
> > > --
> > > 2.43.0
> > >
On Tue, Aug 13, 2024 at 10:18 AM Wang, Weilin <weilin.wang@intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Sent: Monday, August 12, 2024 6:26 PM
> > To: Wang, Weilin <weilin.wang@intel.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>; Ian Rogers
> > <irogers@google.com>; Peter Zijlstra <peterz@infradead.org>; Ingo Molnar
> > <mingo@redhat.com>; Alexander Shishkin
> > <alexander.shishkin@linux.intel.com>; Jiri Olsa <jolsa@kernel.org>; Hunter,
> > Adrian <adrian.hunter@intel.com>; Kan Liang <kan.liang@linux.intel.com>;
> > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor, Perry
> > <perry.taylor@intel.com>; Alt, Samantha <samantha.alt@intel.com>; Biggers,
> > Caleb <caleb.biggers@intel.com>
> > Subject: Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting
> > mode
> >
> > On Mon, Aug 12, 2024 at 10:24:40PM -0300, Arnaldo Carvalho de Melo
> > wrote:
> > > On Sat, Jul 20, 2024 at 02:21:01AM -0400, weilin.wang@intel.com wrote:
> > > > From: Weilin Wang <weilin.wang@intel.com>
> > > >
> > > > Intel TPEBS sampling mode is supported through perf record. The counting
> > mode
> > > > code uses perf record to capture retire_latency value and use it in metric
> > > > calculation. This test checks the counting mode code on Intel platforms.
> > >
> > > root@x1:~# perf test -vvvvv 123
> > > 123: test Intel TPEBS counting mode:
> > > --- start ---
> > > test child forked, pid 2600160
> > > Testing without --record-tpebs
> > > Testing with --record-tpebs
> > > ---- end(-1) ----
> > > 123: test Intel TPEBS counting mode : FAILED!
> > > root@x1:~# grep -m1 "model name" /proc/cpuinfo
> > > model name : 13th Gen Intel(R) Core(TM) i7-1365U
> > > root@x1:~#
> > >
> > > What am I missing?
> > >
> > > The current codebase is in tmp.perf-tools-next
> >
> > acme@x1:~/git/perf-tools-next$ uname -a
> > Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26
> > 20:05:41 UTC 2024 x86_64 GNU/Linux
> >
>
> Hi Arnaldo,
> I just checkout the code and tested it. The failure is caused by a seg fault on a
> perf_tool struct that is not initialized correctly. I think this is related to the patches
> on struct perf_tool in this branch that applied right before the tpebs patches.
>
> I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since
> Ian updated the code to replace this function, I think I need some advice on how
> to use the new code to initialize perf_tool correctly here. Should I call the
> perf_tool__init()?
Yep. If you've added or refactored a tool struct the intent now is
that you call perf_tool__init then override the functions you want to
override. I don't mind to rebase those changes over your changes,
Arnaldo if you want to drop those changes.
Thanks,
Ian
>
>
> Thanks,
> Weilin
>
>
> > > - Arnaldo
> > >
> > > > Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> > > > ---
> > > > .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
> > > > 1 file changed, 19 insertions(+)
> > > > create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > >
> > > > diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > > new file mode 100755
> > > > index 000000000000..c60b29add980
> > > > --- /dev/null
> > > > +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
> > > > @@ -0,0 +1,19 @@
> > > > +#!/bin/bash
> > > > +# test Intel TPEBS counting mode
> > > > +# SPDX-License-Identifier: GPL-2.0
> > > > +
> > > > +set -e
> > > > +grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
> > > > +
> > > > +# Use this event for testing because it should exist in all platforms
> > > > +event=cache-misses:R
> > > > +
> > > > +# 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 ]] || exit 1
> > > > +
> > > > +# In platforms that do not support TPEBS, it should execute without error.
> > > > +echo "Testing with --record-tpebs"
> > > > +result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
> > > > +[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
> > > > --
> > > > 2.43.0
> > > >
On Tue, Aug 13, 2024 at 10:48:21AM -0700, Ian Rogers wrote:
> On Tue, Aug 13, 2024 at 10:18 AM Wang, Weilin <weilin.wang@intel.com> wrote:
> > I just checkout the code and tested it. The failure is caused by a seg fault on a
> > perf_tool struct that is not initialized correctly. I think this is related to the patches
> > on struct perf_tool in this branch that applied right before the tpebs patches.
> > I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since
> > Ian updated the code to replace this function, I think I need some advice on how
> > to use the new code to initialize perf_tool correctly here. Should I call the
> > perf_tool__init()?
> Yep. If you've added or refactored a tool struct the intent now is
> that you call perf_tool__init then override the functions you want to
> override. I don't mind to rebase those changes over your changes,
> Arnaldo if you want to drop those changes.
So I'm adding the patch below, which should be enough, right?
Now:
root@x1:~# perf test tpebs
123: test Intel TPEBS counting mode : Ok
root@x1:~# set -o vi
root@x1:~# perf test tpebs
123: test Intel TPEBS counting mode : Ok
root@x1:~# perf test -v tpebs
123: test Intel TPEBS counting mode : Ok
root@x1:~# perf test -vvv tpebs
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 16603
Testing without --record-tpebs
Testing with --record-tpebs
---- end(0) ----
123: test Intel TPEBS counting mode : Ok
root@x1:~#
diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c
index 3729caeba645a3e8..50a3c3e0716065f8 100644
--- a/tools/perf/util/intel-tpebs.c
+++ b/tools/perf/util/intel-tpebs.c
@@ -164,11 +164,12 @@ static void *__sample_reader(void *arg)
.path = PERF_DATA,
.file.fd = child->out,
};
- struct perf_tool tool = {
- .sample = process_sample_event,
- .feature = process_feature_event,
- .attr = perf_event__process_attr,
- };
+ struct perf_tool tool;
+
+ perf_tool__init(&tool, /*ordered_events=*/false);
+ tool.sample = process_sample_event;
+ tool.feature = process_feature_event;
+ tool.attr = perf_event__process_attr;
session = perf_session__new(&data, &tool);
if (IS_ERR(session))
Thanks for root causing, my mistake,
- Arnaldo
On Tue, Aug 13, 2024 at 03:27:39PM -0300, Arnaldo Carvalho de Melo wrote: > On Tue, Aug 13, 2024 at 10:48:21AM -0700, Ian Rogers wrote: > > On Tue, Aug 13, 2024 at 10:18 AM Wang, Weilin <weilin.wang@intel.com> wrote: > > > I just checkout the code and tested it. The failure is caused by a seg fault on a > > > perf_tool struct that is not initialized correctly. I think this is related to the patches > > > on struct perf_tool in this branch that applied right before the tpebs patches. > > > > I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since > > > Ian updated the code to replace this function, I think I need some advice on how > > > to use the new code to initialize perf_tool correctly here. Should I call the > > > perf_tool__init()? > > > Yep. If you've added or refactored a tool struct the intent now is > > that you call perf_tool__init then override the functions you want to > > override. I don't mind to rebase those changes over your changes, > > Arnaldo if you want to drop those changes. > > So I'm adding the patch below, which should be enough, right? Everything is in tmp.perf-tools-next, will move to perf-tools-next at the end of the day/early tomorrow, after the container build tests finish. - Arnaldo
© 2016 - 2025 Red Hat, Inc.