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

2013-09-06 Thread David Laight
> -} __aligned(__alignof__(long)); > +} __aligned(8); /* 8 byte alignment ensures this can be accessed as a long */ Don't you really want __aligned(MAX(__alignof__(__be64), sizeof (long))) ? David ___ dev mailing list dev@openvswitch.org http

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

2013-09-05 Thread David Miller
From: Geert Uytterhoeven Date: Thu, 5 Sep 2013 21:20:16 +0200 > Why don't you abort the loop if a difference is found? We are optimizing for a match. ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev

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

2013-09-05 Thread David Miller
From: Jesse Gross Date: Thu, 5 Sep 2013 12:17:05 -0700 > sw_flow_key alignment was declared as " __aligned(__alignof__(long))". > However, this breaks on the m68k architecture where long is 32 bit in > size but 16 bit aligned by default. This aligns to the size of a long to > ensure that we can

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

2013-09-05 Thread Joe Perches
On Thu, 2013-09-05 at 14:40 -0400, David Miller wrote: > From: Jesse Gross > Date: Thu, 5 Sep 2013 11:36:19 -0700 > > On Thu, Sep 5, 2013 at 11:17 AM, David Miller wrote: > >> From: Jesse Gross > >> Date: Thu, 5 Sep 2013 10:41:27 -0700 > >> > >>> -} __aligned(__alignof__(long)); > >>> +} __alig

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

2013-09-05 Thread Geert Uytterhoeven
On Thu, Sep 5, 2013 at 9:17 PM, Jesse Gross wrote: > --- a/net/openvswitch/flow.c > +++ b/net/openvswitch/flow.c > @@ -1981,6 +1981,7 @@ nla_put_failure: > * Returns zero if successful or a negative error code. */ > int ovs_flow_init(void) > { > + BUILD_BUG_ON(__alignof__(struct sw_flow_

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

2013-09-05 Thread Geert Uytterhoeven
On Thu, Sep 5, 2013 at 8:40 PM, David Miller wrote: > When doing comparisons, this structure is being accessed as a byte > array in 'long' sized chunks, not by its members. Therefore, the Like ... an optimized memcmp() does? Which handles all (un)alignment well? >> To completely honest, I think

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

2013-09-05 Thread Jesse Gross
On Thu, Sep 5, 2013 at 12:20 PM, Geert Uytterhoeven wrote: > Why don't you abort the loop if a difference is found? > Or is this a security-related struct where you want to protect against > timing attacks? It's more expensive to test for a difference on every iteration in the common case where t

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

2013-09-05 Thread Jesse Gross
On Thu, Sep 5, 2013 at 11:40 AM, David Miller wrote: > From: Jesse Gross > Date: Thu, 5 Sep 2013 11:36:19 -0700 > >> On Thu, Sep 5, 2013 at 11:17 AM, David Miller wrote: >>> From: Jesse Gross >>> Date: Thu, 5 Sep 2013 10:41:27 -0700 >>> -} __aligned(__alignof__(long)); +} __aligned(8

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

2013-09-05 Thread David Miller
From: Jesse Gross Date: Thu, 5 Sep 2013 11:36:19 -0700 > On Thu, Sep 5, 2013 at 11:17 AM, David Miller wrote: >> From: Jesse Gross >> 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 >>

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

2013-09-05 Thread Jesse Gross
sw_flow_key alignment was declared as " __aligned(__alignof__(long))". However, this breaks on the m68k architecture where long is 32 bit in size but 16 bit aligned by default. This aligns to the size of a long to ensure that we can always do comparsions in full long-sized chunks. It also adds an a

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

2013-09-05 Thread Jesse Gross
On Thu, Sep 5, 2013 at 11:17 AM, David Miller wrote: > From: Jesse Gross > 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

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

2013-09-05 Thread David Miller
From: Jesse Gross 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 e

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

2013-09-05 Thread Jesse Gross
sw_flow_key alignment was declared as " __aligned(__alignof__(long))". However, this breaks on the m68k architecture where long is 32 bit in size but 16 bit aligned by default. This aligns to 8 bytes to ensure that long is always covered without reducing native alignment. It also adds an additional