diff mbox

[ovs-dev,08/12] dpif-netdev: Reorder elements in dp_netdev_port structure.

Message ID 1475857062-55311-9-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
By reordering the data elements in dp_netdev_port structure, pad bytes
can be reduced and there by saving a cache line.

Before: structure size:136, holes:3, sum padbytes:15, cachelines:3
After: structure size:128, holes:1, sum padbytes:7, cachelines:2

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
Would equivalent packing be achieved by moving the line down before the bool instead? If yes, it would be preferable.

Acked-by: Jarno Rajahalme <jarno@ovn.org>

> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> wrote:
> 
> By reordering the data elements in dp_netdev_port structure, pad bytes
> can be reduced and there by saving a cache line.
> 
> Before: structure size:136, holes:3, sum padbytes:15, cachelines:3
> After: structure size:128, holes:1, sum padbytes:7, cachelines:2
> 
> 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 dfc9cbd..262f4de 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -284,10 +284,10 @@ struct dp_netdev_rxq {
> /* A port in a netdev-based datapath. */
> struct dp_netdev_port {
>     odp_port_t port_no;
> +    unsigned n_rxq;             /* Number of elements in 'rxq' */
>     struct netdev *netdev;
>     struct hmap_node node;      /* Node in dp_netdev's 'ports'. */
>     struct netdev_saved_flags *sf;
> -    unsigned n_rxq;             /* Number of elements in 'rxq' */
>     struct dp_netdev_rxq *rxqs;
>     bool dynamic_txqs;          /* If true XPS will be used. */
>     unsigned *txq_used;         /* Number of threads that uses each tx queue. */
> -- 
> 2.4.11
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Bodireddy, Bhanuprakash Oct. 10, 2016, 3:43 p.m. UTC | #2
>-----Original Message-----
>From: Jarno Rajahalme [mailto:jarno@ovn.org]
>Sent: Friday, October 7, 2016 10:11 PM
>To: Bodireddy, Bhanuprakash <bhanuprakash.bodireddy@intel.com>
>Cc: dev@openvswitch.org
>Subject: Re: [ovs-dev] [PATCH 08/12] dpif-netdev: Reorder elements in
>dp_netdev_port structure.
>
>Would equivalent packing be achieved by moving the line down before the
>bool instead? If yes, it would be preferable.
Absolutely yes, I would do this in v2. 

Regards,
Bhanu Prakash. 

>
>Acked-by: Jarno Rajahalme <jarno@ovn.org>
>
>> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy
><bhanuprakash.bodireddy@intel.com> wrote:
>>
>> By reordering the data elements in dp_netdev_port structure, pad bytes
>> can be reduced and there by saving a cache line.
>>
>> Before: structure size:136, holes:3, sum padbytes:15, cachelines:3
>> After: structure size:128, holes:1, sum padbytes:7, cachelines:2
>>
>> 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
>> dfc9cbd..262f4de 100644
>> --- a/lib/dpif-netdev.c
>> +++ b/lib/dpif-netdev.c
>> @@ -284,10 +284,10 @@ struct dp_netdev_rxq {
>> /* A port in a netdev-based datapath. */ struct dp_netdev_port {
>>     odp_port_t port_no;
>> +    unsigned n_rxq;             /* Number of elements in 'rxq' */
>>     struct netdev *netdev;
>>     struct hmap_node node;      /* Node in dp_netdev's 'ports'. */
>>     struct netdev_saved_flags *sf;
>> -    unsigned n_rxq;             /* Number of elements in 'rxq' */
>>     struct dp_netdev_rxq *rxqs;
>>     bool dynamic_txqs;          /* If true XPS will be used. */
>>     unsigned *txq_used;         /* Number of threads that uses each tx queue.
>*/
>> --
>> 2.4.11
>>
>> _______________________________________________
>> 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 dfc9cbd..262f4de 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -284,10 +284,10 @@  struct dp_netdev_rxq {
 /* A port in a netdev-based datapath. */
 struct dp_netdev_port {
     odp_port_t port_no;
+    unsigned n_rxq;             /* Number of elements in 'rxq' */
     struct netdev *netdev;
     struct hmap_node node;      /* Node in dp_netdev's 'ports'. */
     struct netdev_saved_flags *sf;
-    unsigned n_rxq;             /* Number of elements in 'rxq' */
     struct dp_netdev_rxq *rxqs;
     bool dynamic_txqs;          /* If true XPS will be used. */
     unsigned *txq_used;         /* Number of threads that uses each tx queue. */