[ovs-dev] [PATCH] openvswitch: Fix alignment of struct sw_flow_key.

David Miller davem at davemloft.net
Thu Sep 5 18:17:51 UTC 2013


From: Jesse Gross <jesse at nicira.com>
Date: Thu,  5 Sep 2013 10:41:27 -0700

> -} __aligned(__alignof__(long));
> +} __aligned(8); /* 8 byte alignment ensures this can be accessed as a long */

This kind of stuff drives me crazy.

If the issue is the type, therefore at least use an expression that
mentions the type explicitly.  And mention the actual type that
matters.  "long" isn't it.

These half-hearted attempts to fix this problem are just papering
around the issue and do not address the real issue directly.

I don't want to apply changes like this.

You don't want "8 byte alignment", you want the alignment necessary
for the types contained in the structure to be accessed without
generating exceptions.  You might also want the "quickest" alignment,
and there are ways to express that as well.

This structure doesn't even contain a "long".  "long" isn't even
64-bit on some architectures, and you certainly have 64-bit types in
this thing (__be64).

Let's start from the beginning, what are you actually trying to
accomplish here that isn't handled automatically by the compiler
already?

Is it "proper" alignment?  That is handled automatically by the
compiler.  Is it "fast" alignment?  In what context and in what ways
is that important in this specific case?



More information about the dev mailing list