Align pointers in hna list elements

Message ID 1243965365-6526-1-git-send-email-sven.eckelmann@gmx.de (mailing list archive)
State Superseded, archived
Headers

Commit Message

Sven Eckelmann June 2, 2009, 5:56 p.m. UTC
  Architectures like SuperARM or Xscale needs aligned data for multi-byte
operations. GCC can create instructions sequences for packed data, but
must know that something will not be aligned. Since list_add will
operate on untyped data over void-pointers it cannot know that
hna_global_entry is packed and will create only a fast and unsafe
version for load and store operations.
It is only important for the first 5 bytes of hna_global_entry to be
packed we can force these elements to be aligned without changing
the relative addresses of the first bytes.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman/hna.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Nathan Wharton June 2, 2009, 6:56 p.m. UTC | #1
On Tue, Jun 2, 2009 at 12:56 PM, Sven Eckelmann <sven.eckelmann@gmx.de> wrote:
> Architectures like SuperARM or Xscale needs aligned data for multi-byte
> operations. GCC can create instructions sequences for packed data, but
> must know that something will not be aligned. Since list_add will
> operate on untyped data over void-pointers it cannot know that
> hna_global_entry is packed and will create only a fast and unsafe
> version for load and store operations.
> It is only important for the first 5 bytes of hna_global_entry to be
> packed we can force these elements to be aligned without changing
> the relative addresses of the first bytes.
>

It looks good here.  I am running this combined with the previous 3
patches with cpu/alignment set to bus error on problems.
  
Marek Lindner June 3, 2009, 11:16 a.m. UTC | #2
On Wednesday 03 June 2009 18:39:26 Sven Eckelmann wrote:
> Architectures like SuperARM or Xscale needs aligned data for multi-byte
> operations. GCC can create instructions sequences for packed data, but
> must know that something will not be aligned. Since list_add will
> operate on untyped data over void-pointers it cannot know that
> hna_global_entry is packed and will create only a fast and unsafe
> version for load and store operations.
> It is only important for the first 5 bytes of hna_global_entry to be
> packed we can force these elements to be aligned without changing
> the relative addresses of the first bytes.


Sven, thanks a lot for your patches and thanks for your debugging help, 
Nathan. I just applied these patches. :-)

Regards,
Marek
  

Patch

diff --git a/batman/hna.h b/batman/hna.h
index 6063324..3e7049e 100644
--- a/batman/hna.h
+++ b/batman/hna.h
@@ -58,8 +58,8 @@  struct hna_global_entry
 {
 	uint32_t addr;
 	uint8_t netmask;
-	struct orig_node *curr_orig_node;
-	struct list_head_first orig_list;
+	struct orig_node *curr_orig_node ALIGN_WORD;
+	struct list_head_first orig_list ALIGN_WORD;
 } __attribute__((packed));
 
 struct hna_orig_ptr