All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Fix: Align buffers from objstack_alloc on sizeof(void *)
@ 2014-05-16  2:10 rongqing.li
  0 siblings, 0 replies; 2+ messages in thread
From: rongqing.li @ 2014-05-16  2:10 UTC (permalink / raw)
  To: jeremie.galarneau, lttng-dev, mathieu.desnoyers, simon.marchi

From: Fredrik Markström <fredrik.markstrom@gmail.com>

The buffers from objstack_alloc will store the pointer, so it must
be aligned on pointer, or else it will cause issue on the cpu
which does not support unaligned addresses access

Signed-off-by: Fredrik Markstrom <fredrik.markstrom@gmail.com>
Signed-off-by: Roy Li <rongqing.li@windriver.com>
---
 formats/ctf/metadata/objstack.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/formats/ctf/metadata/objstack.c b/formats/ctf/metadata/objstack.c
index 9e264a4..0e7d04e 100644
--- a/formats/ctf/metadata/objstack.c
+++ b/formats/ctf/metadata/objstack.c
@@ -39,7 +39,7 @@ struct objstack_node {
 	struct bt_list_head node;
 	size_t len;
 	size_t used_len;
-	char data[];
+	char __attribute__ ((aligned (sizeof(void *)))) data[];
 };
 
 BT_HIDDEN
@@ -118,6 +118,8 @@ void *objstack_alloc(struct objstack *objstack, size_t len)
 	struct objstack_node *last_node;
 	void *p;
 
+	len = ALIGN(len, sizeof(void *));
+
 	/* Get last node */
 	last_node = bt_list_entry(objstack->head.prev,
 			struct objstack_node, node);
-- 
1.7.10.4


_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

* Re: [PATCH v2] Fix: Align buffers from objstack_alloc on sizeof(void *)
       [not found] <1400206238-11343-1-git-send-email-rongqing.li@windriver.com>
@ 2014-05-16 15:52 ` Jérémie Galarneau
  0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Galarneau @ 2014-05-16 15:52 UTC (permalink / raw)
  To: Rongqing Li; +Cc: lttng-dev

#include <babeltrace/align.h> is missing. I've added it and merged.

Also, note that you should use git format-patch's
--subject-prefix="PATCH project_name" option. It makes it easier to
keep track of patches since this mailing list is shared between
multiple projects.

Thanks!
Jérémie

On Thu, May 15, 2014 at 10:10 PM,  <rongqing.li@windriver.com> wrote:
> From: Fredrik Markström <fredrik.markstrom@gmail.com>
>
> The buffers from objstack_alloc will store the pointer, so it must
> be aligned on pointer, or else it will cause issue on the cpu
> which does not support unaligned addresses access
>
> Signed-off-by: Fredrik Markstrom <fredrik.markstrom@gmail.com>
> Signed-off-by: Roy Li <rongqing.li@windriver.com>
> ---
>  formats/ctf/metadata/objstack.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/formats/ctf/metadata/objstack.c b/formats/ctf/metadata/objstack.c
> index 9e264a4..0e7d04e 100644
> --- a/formats/ctf/metadata/objstack.c
> +++ b/formats/ctf/metadata/objstack.c
> @@ -39,7 +39,7 @@ struct objstack_node {
>         struct bt_list_head node;
>         size_t len;
>         size_t used_len;
> -       char data[];
> +       char __attribute__ ((aligned (sizeof(void *)))) data[];
>  };
>
>  BT_HIDDEN
> @@ -118,6 +118,8 @@ void *objstack_alloc(struct objstack *objstack, size_t len)
>         struct objstack_node *last_node;
>         void *p;
>
> +       len = ALIGN(len, sizeof(void *));
> +
>         /* Get last node */
>         last_node = bt_list_entry(objstack->head.prev,
>                         struct objstack_node, node);
> --
> 1.7.10.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

end of thread, other threads:[~2014-05-16 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16  2:10 [PATCH v2] Fix: Align buffers from objstack_alloc on sizeof(void *) rongqing.li
     [not found] <1400206238-11343-1-git-send-email-rongqing.li@windriver.com>
2014-05-16 15:52 ` Jérémie Galarneau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.