diff mbox

[ovs-dev,07/12] dpif-netdev: Cache align netdev_flow_keys.

Message ID 1475857062-55311-8-git-send-email-bhanuprakash.bodireddy@intel.com
State Changes Requested
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Bodireddy, Bhanuprakash Oct. 7, 2016, 4:17 p.m. UTC
Aligning the 'keys' array seems to positively impact performance.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/dpif-netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jarno Rajahalme Oct. 7, 2016, 9:10 p.m. UTC | #1
> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> wrote:
> 
> Aligning the 'keys' array seems to positively impact performance.
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
> Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
> ---
> lib/dpif-netdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index d0bb191..dfc9cbd 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -4157,7 +4157,7 @@ dp_netdev_input__(struct dp_netdev_pmd_thread *pmd,
>     /* Sparse or MSVC doesn't like variable length array. */
>     enum { PKT_ARRAY_SIZE = NETDEV_MAX_BURST };
> #endif
> -    struct netdev_flow_key keys[PKT_ARRAY_SIZE];
> +    struct netdev_flow_key keys[PKT_ARRAY_SIZE] __attribute__((aligned(64)));

Due to compiler compatibility you must use OVS_ALIGNED_VAR(64) instead.

>     struct packet_batch_per_flow batches[PKT_ARRAY_SIZE];
>     long long now = time_msec();
>     size_t newcnt, n_batches, i;
> -- 
> 2.4.11
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Daniele Di Proietto Oct. 7, 2016, 10:45 p.m. UTC | #2
2016-10-07 14:10 GMT-07:00 Jarno Rajahalme <jarno@ovn.org>:

>
> > On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy <
> bhanuprakash.bodireddy@intel.com> wrote:
> >
> > Aligning the 'keys' array seems to positively impact performance.
> >
> > Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
> > Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
> > ---
> > lib/dpif-netdev.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> > index d0bb191..dfc9cbd 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -4157,7 +4157,7 @@ dp_netdev_input__(struct dp_netdev_pmd_thread *pmd,
> >     /* Sparse or MSVC doesn't like variable length array. */
> >     enum { PKT_ARRAY_SIZE = NETDEV_MAX_BURST };
> > #endif
> > -    struct netdev_flow_key keys[PKT_ARRAY_SIZE];
> > +    struct netdev_flow_key keys[PKT_ARRAY_SIZE]
> __attribute__((aligned(64)));
>
> Due to compiler compatibility you must use OVS_ALIGNED_VAR(64) instead.
>

I would also use the CACHE_LINE_SIZE define, instead of 64

Thanks,

Daniele


> >     struct packet_batch_per_flow batches[PKT_ARRAY_SIZE];
> >     long long now = time_msec();
> >     size_t newcnt, n_batches, i;
> > --
> > 2.4.11
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
Bodireddy, Bhanuprakash Oct. 10, 2016, 3:44 p.m. UTC | #3
>-----Original Message-----

>From: Daniele Di Proietto [mailto:diproiettod@ovn.org]

>Sent: Friday, October 7, 2016 11:46 PM

>To: Bodireddy, Bhanuprakash <bhanuprakash.bodireddy@intel.com>

>Cc: dev@openvswitch.org; Jarno Rajahalme <jarno@ovn.org>

>Subject: Re: [ovs-dev] [PATCH 07/12] dpif-netdev: Cache align

>netdev_flow_keys.

>

>

>

>2016-10-07 14:10 GMT-07:00 Jarno Rajahalme <jarno@ovn.org>:

>

>> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy

><bhanuprakash.bodireddy@intel.com> wrote:

>>

>> Aligning the 'keys' array seems to positively impact performance.

>>

>> Signed-off-by: Bhanuprakash Bodireddy

><bhanuprakash.bodireddy@intel.com>

>> Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>

>> ---

>> lib/dpif-netdev.c | 2 +-

>> 1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c

>> index d0bb191..dfc9cbd 100644

>> --- a/lib/dpif-netdev.c

>> +++ b/lib/dpif-netdev.c

>> @@ -4157,7 +4157,7 @@ dp_netdev_input__(struct

>dp_netdev_pmd_thread *pmd,

>>     /* Sparse or MSVC doesn't like variable length array. */

>>     enum { PKT_ARRAY_SIZE = NETDEV_MAX_BURST };

>> #endif

>> -    struct netdev_flow_key keys[PKT_ARRAY_SIZE];

>> +    struct netdev_flow_key keys[PKT_ARRAY_SIZE]

>__attribute__((aligned(64)));

>

>Due to compiler compatibility you must use OVS_ALIGNED_VAR(64) instead.

>

>I would also use the CACHE_LINE_SIZE define, instead of 64


Agree, I would change to OVS_ALIGNED_VAR(CACHE_LINE_SIZE) when I send v2.

Regards,
Bhanu Prakash. 


>Thanks,

>Daniele

>

>>     struct packet_batch_per_flow batches[PKT_ARRAY_SIZE];

>>     long long now = time_msec();

>>     size_t newcnt, n_batches, i;

>> --

>> 2.4.11

>>

>> _______________________________________________

>> dev mailing list

>> dev@openvswitch.org

>> http://openvswitch.org/mailman/listinfo/dev

>

>_______________________________________________

>dev mailing list

>dev@openvswitch.org

>http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d0bb191..dfc9cbd 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4157,7 +4157,7 @@  dp_netdev_input__(struct dp_netdev_pmd_thread *pmd,
     /* Sparse or MSVC doesn't like variable length array. */
     enum { PKT_ARRAY_SIZE = NETDEV_MAX_BURST };
 #endif
-    struct netdev_flow_key keys[PKT_ARRAY_SIZE];
+    struct netdev_flow_key keys[PKT_ARRAY_SIZE] __attribute__((aligned(64)));
     struct packet_batch_per_flow batches[PKT_ARRAY_SIZE];
     long long now = time_msec();
     size_t newcnt, n_batches, i;