Re: [PATCH] openvswitch: fix sw_flow_key alignment
From: Jesse Gross <hidden>
Date: 2013-08-30 18:22:32
On Fri, Aug 30, 2013 at 10:32 AM, Andy Zhou [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index ad1aeeb..fe7524c4 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c int ovs_flow_init(void) { BUILD_BUG_ON(sizeof(struct sw_flow_key) % sizeof(long)); + BUILD_BUG_ON(sizeof(struct sw_flow_key) % __alignof__(long));
Should this be checking alignof struct sw_flow_key instead of the size?
quoted hunk ↗ jump to hunk
flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0, 0, NULL);diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index b65f885..202c4c4 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h@@ -125,7 +125,7 @@ struct sw_flow_key { } nd; } ipv6; }; -} __aligned(__alignof__(long)); +} __aligned(sizeof(long));
This is going to result in the alignment issue discussed yesterday where on 32-bit machines the 64 bit members potentially become misaligned. The suggestion that Geert made was to just drop this entirely and rely on the natural alignment from these values.