linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr
@ 2023-03-15 12:13 Thomas Richter
  2023-03-15 16:42 ` Namhyung Kim
  2023-04-18 19:56 ` Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Richter @ 2023-03-15 12:13 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme, robh, jolsa
  Cc: svens, gor, sumanthk, hca, Thomas Richter

The test case ./perf test 'Setup struct perf_event_attr' fails.
On s390 this output is observed:

 # ./perf test -Fvvvv 17
 17: Setup struct perf_event_attr                                    :
 --- start ---
 running './tests/attr/test-stat-C0'
 Using CPUID IBM,8561,703,T01,3.6,002f
 .....
 Event event:base-stat
      fd = 1
      group_fd = -1
      flags = 0|8
      cpu = *
      type = 0
      size = 128     <<<--- wrong, specified in file base-stat
      config = 0
      sample_period = 0
      sample_type = 65536
      ...
 'PERF_TEST_ATTR=/tmp/tmpgw574wvg ./perf stat -o \
	/tmp/tmpgw574wvg/perf.data -e cycles -C 0 kill >/dev/null \
	2>&1 ret '1', expected '1'
  loading result events
    Event event-0-0-4
      fd = 4
      group_fd = -1
      cpu = 0
      pid = -1
      flags = 8
      type = 0
      size = 136     <<<--- actual size used in system call
      .....
  compare
    matching [event-0-0-4]
      to [event:base-stat]
      [cpu] 0 *
      [flags] 8 0|8
      [type] 0 0
      [size] 136 128
    ->FAIL
    match: [event-0-0-4] matches []
  expected size=136, got 128
  FAILED './tests/attr/test-stat-C0' - match failure

This mismatch is caused by
commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
which enlarges the structure perf_event_attr by 8 bytes.

Fix this by adjusting the expected value of size.

Output after:
 # ./perf test -Fvvvv 17
 17: Setup struct perf_event_attr                                    :
 --- start ---
 running './tests/attr/test-stat-C0'
 Using CPUID IBM,8561,703,T01,3.6,002f
 ...
  matched
  compare
    matching [event-0-0-4]
      to [event:base-stat]
      [cpu] 0 *
      [flags] 8 0|8
      [type] 0 0
      [size] 136 136
      ....
   ->OK
   match: [event-0-0-4] matches ['event:base-stat']
 matched

Fixes: 09519ec3b19e ("perf: Add perf_event_attr::config3")

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
 tools/perf/tests/attr/base-record       | 2 +-
 tools/perf/tests/attr/base-stat         | 2 +-
 tools/perf/tests/attr/system-wide-dummy | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
index 3ef07a12aa14..27c21271a16c 100644
--- a/tools/perf/tests/attr/base-record
+++ b/tools/perf/tests/attr/base-record
@@ -5,7 +5,7 @@ group_fd=-1
 flags=0|8
 cpu=*
 type=0|1
-size=128
+size=136
 config=0
 sample_period=*
 sample_type=263
diff --git a/tools/perf/tests/attr/base-stat b/tools/perf/tests/attr/base-stat
index 408164456530..a21fb65bc012 100644
--- a/tools/perf/tests/attr/base-stat
+++ b/tools/perf/tests/attr/base-stat
@@ -5,7 +5,7 @@ group_fd=-1
 flags=0|8
 cpu=*
 type=0
-size=128
+size=136
 config=0
 sample_period=0
 sample_type=65536
diff --git a/tools/perf/tests/attr/system-wide-dummy b/tools/perf/tests/attr/system-wide-dummy
index 8fec06eda5f9..2f3e3eb728eb 100644
--- a/tools/perf/tests/attr/system-wide-dummy
+++ b/tools/perf/tests/attr/system-wide-dummy
@@ -7,7 +7,7 @@ cpu=*
 pid=-1
 flags=8
 type=1
-size=128
+size=136
 config=9
 sample_period=4000
 sample_type=455
-- 
2.39.1


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

* Re: [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr
  2023-03-15 12:13 [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr Thomas Richter
@ 2023-03-15 16:42 ` Namhyung Kim
  2023-04-18 19:56 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2023-03-15 16:42 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, acme, robh, jolsa, svens, gor,
	sumanthk, hca

Hello,

On Wed, Mar 15, 2023 at 5:15 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> The test case ./perf test 'Setup struct perf_event_attr' fails.
> On s390 this output is observed:
>
>  # ./perf test -Fvvvv 17
>  17: Setup struct perf_event_attr                                    :
>  --- start ---
>  running './tests/attr/test-stat-C0'
>  Using CPUID IBM,8561,703,T01,3.6,002f
>  .....
>  Event event:base-stat
>       fd = 1
>       group_fd = -1
>       flags = 0|8
>       cpu = *
>       type = 0
>       size = 128     <<<--- wrong, specified in file base-stat
>       config = 0
>       sample_period = 0
>       sample_type = 65536
>       ...
>  'PERF_TEST_ATTR=/tmp/tmpgw574wvg ./perf stat -o \
>         /tmp/tmpgw574wvg/perf.data -e cycles -C 0 kill >/dev/null \
>         2>&1 ret '1', expected '1'
>   loading result events
>     Event event-0-0-4
>       fd = 4
>       group_fd = -1
>       cpu = 0
>       pid = -1
>       flags = 8
>       type = 0
>       size = 136     <<<--- actual size used in system call
>       .....
>   compare
>     matching [event-0-0-4]
>       to [event:base-stat]
>       [cpu] 0 *
>       [flags] 8 0|8
>       [type] 0 0
>       [size] 136 128
>     ->FAIL
>     match: [event-0-0-4] matches []
>   expected size=136, got 128
>   FAILED './tests/attr/test-stat-C0' - match failure
>
> This mismatch is caused by
> commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> which enlarges the structure perf_event_attr by 8 bytes.
>
> Fix this by adjusting the expected value of size.
>
> Output after:
>  # ./perf test -Fvvvv 17
>  17: Setup struct perf_event_attr                                    :
>  --- start ---
>  running './tests/attr/test-stat-C0'
>  Using CPUID IBM,8561,703,T01,3.6,002f
>  ...
>   matched
>   compare
>     matching [event-0-0-4]
>       to [event:base-stat]
>       [cpu] 0 *
>       [flags] 8 0|8
>       [type] 0 0
>       [size] 136 136
>       ....
>    ->OK
>    match: [event-0-0-4] matches ['event:base-stat']
>  matched
>
> Fixes: 09519ec3b19e ("perf: Add perf_event_attr::config3")
>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/tests/attr/base-record       | 2 +-
>  tools/perf/tests/attr/base-stat         | 2 +-
>  tools/perf/tests/attr/system-wide-dummy | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/tests/attr/base-record b/tools/perf/tests/attr/base-record
> index 3ef07a12aa14..27c21271a16c 100644
> --- a/tools/perf/tests/attr/base-record
> +++ b/tools/perf/tests/attr/base-record
> @@ -5,7 +5,7 @@ group_fd=-1
>  flags=0|8
>  cpu=*
>  type=0|1
> -size=128
> +size=136
>  config=0
>  sample_period=*
>  sample_type=263
> diff --git a/tools/perf/tests/attr/base-stat b/tools/perf/tests/attr/base-stat
> index 408164456530..a21fb65bc012 100644
> --- a/tools/perf/tests/attr/base-stat
> +++ b/tools/perf/tests/attr/base-stat
> @@ -5,7 +5,7 @@ group_fd=-1
>  flags=0|8
>  cpu=*
>  type=0
> -size=128
> +size=136
>  config=0
>  sample_period=0
>  sample_type=65536
> diff --git a/tools/perf/tests/attr/system-wide-dummy b/tools/perf/tests/attr/system-wide-dummy
> index 8fec06eda5f9..2f3e3eb728eb 100644
> --- a/tools/perf/tests/attr/system-wide-dummy
> +++ b/tools/perf/tests/attr/system-wide-dummy
> @@ -7,7 +7,7 @@ cpu=*
>  pid=-1
>  flags=8
>  type=1
> -size=128
> +size=136
>  config=9
>  sample_period=4000
>  sample_type=455
> --
> 2.39.1
>

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

* Re: [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr
  2023-03-15 12:13 [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr Thomas Richter
  2023-03-15 16:42 ` Namhyung Kim
@ 2023-04-18 19:56 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2023-04-18 19:56 UTC (permalink / raw)
  To: Thomas Richter
  Cc: linux-kernel, linux-perf-users, acme, jolsa, svens, gor, sumanthk,
	hca

On Wed, Mar 15, 2023 at 7:13 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> The test case ./perf test 'Setup struct perf_event_attr' fails.
> On s390 this output is observed:
>
>  # ./perf test -Fvvvv 17
>  17: Setup struct perf_event_attr                                    :
>  --- start ---
>  running './tests/attr/test-stat-C0'
>  Using CPUID IBM,8561,703,T01,3.6,002f
>  .....
>  Event event:base-stat
>       fd = 1
>       group_fd = -1
>       flags = 0|8
>       cpu = *
>       type = 0
>       size = 128     <<<--- wrong, specified in file base-stat
>       config = 0
>       sample_period = 0
>       sample_type = 65536
>       ...
>  'PERF_TEST_ATTR=/tmp/tmpgw574wvg ./perf stat -o \
>         /tmp/tmpgw574wvg/perf.data -e cycles -C 0 kill >/dev/null \
>         2>&1 ret '1', expected '1'
>   loading result events
>     Event event-0-0-4
>       fd = 4
>       group_fd = -1
>       cpu = 0
>       pid = -1
>       flags = 8
>       type = 0
>       size = 136     <<<--- actual size used in system call
>       .....
>   compare
>     matching [event-0-0-4]
>       to [event:base-stat]
>       [cpu] 0 *
>       [flags] 8 0|8
>       [type] 0 0
>       [size] 136 128
>     ->FAIL
>     match: [event-0-0-4] matches []
>   expected size=136, got 128
>   FAILED './tests/attr/test-stat-C0' - match failure
>
> This mismatch is caused by
> commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> which enlarges the structure perf_event_attr by 8 bytes.
>
> Fix this by adjusting the expected value of size.
>
> Output after:
>  # ./perf test -Fvvvv 17
>  17: Setup struct perf_event_attr                                    :
>  --- start ---
>  running './tests/attr/test-stat-C0'
>  Using CPUID IBM,8561,703,T01,3.6,002f
>  ...
>   matched
>   compare
>     matching [event-0-0-4]
>       to [event:base-stat]
>       [cpu] 0 *
>       [flags] 8 0|8
>       [type] 0 0
>       [size] 136 136
>       ....
>    ->OK
>    match: [event-0-0-4] matches ['event:base-stat']
>  matched
>
> Fixes: 09519ec3b19e ("perf: Add perf_event_attr::config3")

Shouldn't a kernel with this change work with an old version of perf without?

Anyways, looks like the change is needed regardless.

Acked-by: Rob Herring <robh@kernel.org>

>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
>  tools/perf/tests/attr/base-record       | 2 +-
>  tools/perf/tests/attr/base-stat         | 2 +-
>  tools/perf/tests/attr/system-wide-dummy | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

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

end of thread, other threads:[~2023-04-18 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-15 12:13 [PATCH] perf/test: Fix wrong size for perf test Setup struct perf_event_attr Thomas Richter
2023-03-15 16:42 ` Namhyung Kim
2023-04-18 19:56 ` Rob Herring

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