public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libperf: fix alignment trap in perf stat
@ 2019-08-22  9:07 Gerald BAEZA
  2019-08-22 15:24 ` Arnaldo Carvalho de Melo
  2019-08-23 12:29 ` [tip: perf/core] libperf: Fix alignment trap with xyarray contents in 'perf stat' tip-bot2 for Gerald BAEZA
  0 siblings, 2 replies; 3+ messages in thread
From: Gerald BAEZA @ 2019-08-22  9:07 UTC (permalink / raw)
  To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	alexander.shishkin@linux.intel.com, jolsa@redhat.com,
	namhyung@kernel.org, linux-kernel@vger.kernel.org
  Cc: Gerald BAEZA, Alexandre TORGUE

Following the patch 'perf stat: Fix --no-scale', an
alignment trap happens in process_counter_values()
on ARMv7 platforms due to the attempt to copy non
64 bits aligned double words (pointed by 'count')
via a NEON vectored instruction ('vld1' with 64
bits alignment constraint).

This patch sets a 64 bits alignment constraint on
'contents[]' field in 'struct xyarray' since the
'count' pointer used above points to such a
structure.

Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
---
 tools/perf/lib/include/internal/xyarray.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/lib/include/internal/xyarray.h b/tools/perf/lib/include/internal/xyarray.h
index 3bf70e4..51e35d6 100644
--- a/tools/perf/lib/include/internal/xyarray.h
+++ b/tools/perf/lib/include/internal/xyarray.h
@@ -2,6 +2,7 @@
 #ifndef __LIBPERF_INTERNAL_XYARRAY_H
 #define __LIBPERF_INTERNAL_XYARRAY_H
 
+#include <linux/compiler.h>
 #include <sys/types.h>
 
 struct xyarray {
@@ -10,7 +11,7 @@ struct xyarray {
 	size_t entries;
 	size_t max_x;
 	size_t max_y;
-	char contents[];
+	char contents[] __aligned(8);
 };
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
-- 
2.7.4

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

* Re: [PATCH] libperf: fix alignment trap in perf stat
  2019-08-22  9:07 [PATCH] libperf: fix alignment trap in perf stat Gerald BAEZA
@ 2019-08-22 15:24 ` Arnaldo Carvalho de Melo
  2019-08-23 12:29 ` [tip: perf/core] libperf: Fix alignment trap with xyarray contents in 'perf stat' tip-bot2 for Gerald BAEZA
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-08-22 15:24 UTC (permalink / raw)
  To: Gerald BAEZA
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, linux-kernel, Alexandre TORGUE, Andi Kleen,
	Mathieu Poirier

Em Thu, Aug 22, 2019 at 09:07:01AM +0000, Gerald BAEZA escreveu:
> Following the patch 'perf stat: Fix --no-scale', an
> alignment trap happens in process_counter_values()
> on ARMv7 platforms due to the attempt to copy non
> 64 bits aligned double words (pointed by 'count')
> via a NEON vectored instruction ('vld1' with 64
> bits alignment constraint).
> 
> This patch sets a 64 bits alignment constraint on
> 'contents[]' field in 'struct xyarray' since the
> 'count' pointer used above points to such a
> structure.

You forgot to add Mathieu and Andi, which I just did.

I think this is ok and I'm applying, please holler anyone if think this
isn't the case,

- Arnaldo
 
> Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
> ---
>  tools/perf/lib/include/internal/xyarray.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/lib/include/internal/xyarray.h b/tools/perf/lib/include/internal/xyarray.h
> index 3bf70e4..51e35d6 100644
> --- a/tools/perf/lib/include/internal/xyarray.h
> +++ b/tools/perf/lib/include/internal/xyarray.h
> @@ -2,6 +2,7 @@
>  #ifndef __LIBPERF_INTERNAL_XYARRAY_H
>  #define __LIBPERF_INTERNAL_XYARRAY_H
>  
> +#include <linux/compiler.h>
>  #include <sys/types.h>
>  
>  struct xyarray {
> @@ -10,7 +11,7 @@ struct xyarray {
>  	size_t entries;
>  	size_t max_x;
>  	size_t max_y;
> -	char contents[];
> +	char contents[] __aligned(8);
>  };
>  
>  struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
> -- 
> 2.7.4

-- 

- Arnaldo

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

* [tip: perf/core] libperf: Fix alignment trap with xyarray contents in 'perf stat'
  2019-08-22  9:07 [PATCH] libperf: fix alignment trap in perf stat Gerald BAEZA
  2019-08-22 15:24 ` Arnaldo Carvalho de Melo
@ 2019-08-23 12:29 ` tip-bot2 for Gerald BAEZA
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Gerald BAEZA @ 2019-08-23 12:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Gerald Baeza, Alexander Shishkin, Alexandre Torgue, Andi Kleen,
	Jiri Olsa, Mathieu Poirier, Namhyung Kim, Peter Zijlstra,
	Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     d9c5c083416500e95da098c01be092b937def7fa
Gitweb:        https://git.kernel.org/tip/d9c5c083416500e95da098c01be092b937def7fa
Author:        Gerald BAEZA <gerald.baeza@st.com>
AuthorDate:    Thu, 22 Aug 2019 09:07:01 
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 22 Aug 2019 17:16:57 -03:00

libperf: Fix alignment trap with xyarray contents in 'perf stat'

Following the patch 'perf stat: Fix --no-scale', an alignment trap
happens in process_counter_values() on ARMv7 platforms due to the
attempt to copy non 64 bits aligned double words (pointed by 'count')
via a NEON vectored instruction ('vld1' with 64 bits alignment
constraint).

This patch sets a 64 bits alignment constraint on 'contents[]' field in
'struct xyarray' since the 'count' pointer used above points to such a
structure.

Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1566464769-16374-1-git-send-email-gerald.baeza@st.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/lib/include/internal/xyarray.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/lib/include/internal/xyarray.h b/tools/perf/lib/include/internal/xyarray.h
index 3bf70e4..51e35d6 100644
--- a/tools/perf/lib/include/internal/xyarray.h
+++ b/tools/perf/lib/include/internal/xyarray.h
@@ -2,6 +2,7 @@
 #ifndef __LIBPERF_INTERNAL_XYARRAY_H
 #define __LIBPERF_INTERNAL_XYARRAY_H
 
+#include <linux/compiler.h>
 #include <sys/types.h>
 
 struct xyarray {
@@ -10,7 +11,7 @@ struct xyarray {
 	size_t entries;
 	size_t max_x;
 	size_t max_y;
-	char contents[];
+	char contents[] __aligned(8);
 };
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);

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

end of thread, other threads:[~2019-08-23 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-22  9:07 [PATCH] libperf: fix alignment trap in perf stat Gerald BAEZA
2019-08-22 15:24 ` Arnaldo Carvalho de Melo
2019-08-23 12:29 ` [tip: perf/core] libperf: Fix alignment trap with xyarray contents in 'perf stat' tip-bot2 for Gerald BAEZA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox