diff mbox series

[v2,net-next,7/7] net: dsa: combine two holes in struct dsa_switch_tree

Message ID 20220105132141.2648876-8-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series Cleanup to main DSA structures | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers warning 1 maintainers not CCed: olteanv@gmail.com
netdev/build_clang success Errors and warnings before: 26 this patch: 26
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean Jan. 5, 2022, 1:21 p.m. UTC
There is a 7 byte hole after dst->setup and a 4 byte hole after
dst->default_proto. Combining them, we have a single hole of just 3
bytes on 64 bit machines.

Before:

pahole -C dsa_switch_tree net/dsa/slave.o
struct dsa_switch_tree {
        struct list_head           list;                 /*     0    16 */
        struct list_head           ports;                /*    16    16 */
        struct raw_notifier_head   nh;                   /*    32     8 */
        unsigned int               index;                /*    40     4 */
        struct kref                refcount;             /*    44     4 */
        struct net_device * *      lags;                 /*    48     8 */
        bool                       setup;                /*    56     1 */

        /* XXX 7 bytes hole, try to pack */

        /* --- cacheline 1 boundary (64 bytes) --- */
        const struct dsa_device_ops  * tag_ops;          /*    64     8 */
        enum dsa_tag_protocol      default_proto;        /*    72     4 */

        /* XXX 4 bytes hole, try to pack */

        struct dsa_platform_data * pd;                   /*    80     8 */
        struct list_head           rtable;               /*    88    16 */
        unsigned int               lags_len;             /*   104     4 */
        unsigned int               last_switch;          /*   108     4 */

        /* size: 112, cachelines: 2, members: 13 */
        /* sum members: 101, holes: 2, sum holes: 11 */
        /* last cacheline: 48 bytes */
};

After:

pahole -C dsa_switch_tree net/dsa/slave.o
struct dsa_switch_tree {
        struct list_head           list;                 /*     0    16 */
        struct list_head           ports;                /*    16    16 */
        struct raw_notifier_head   nh;                   /*    32     8 */
        unsigned int               index;                /*    40     4 */
        struct kref                refcount;             /*    44     4 */
        struct net_device * *      lags;                 /*    48     8 */
        const struct dsa_device_ops  * tag_ops;          /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        enum dsa_tag_protocol      default_proto;        /*    64     4 */
        bool                       setup;                /*    68     1 */

        /* XXX 3 bytes hole, try to pack */

        struct dsa_platform_data * pd;                   /*    72     8 */
        struct list_head           rtable;               /*    80    16 */
        unsigned int               lags_len;             /*    96     4 */
        unsigned int               last_switch;          /*   100     4 */

        /* size: 104, cachelines: 2, members: 13 */
        /* sum members: 101, holes: 1, sum holes: 3 */
        /* last cacheline: 40 bytes */
};

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 include/net/dsa.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Florian Fainelli Jan. 5, 2022, 6:34 p.m. UTC | #1
On 1/5/22 5:21 AM, Vladimir Oltean wrote:
> There is a 7 byte hole after dst->setup and a 4 byte hole after
> dst->default_proto. Combining them, we have a single hole of just 3
> bytes on 64 bit machines.
> 
> Before:
> 
> pahole -C dsa_switch_tree net/dsa/slave.o
> struct dsa_switch_tree {
>         struct list_head           list;                 /*     0    16 */
>         struct list_head           ports;                /*    16    16 */
>         struct raw_notifier_head   nh;                   /*    32     8 */
>         unsigned int               index;                /*    40     4 */
>         struct kref                refcount;             /*    44     4 */
>         struct net_device * *      lags;                 /*    48     8 */
>         bool                       setup;                /*    56     1 */
> 
>         /* XXX 7 bytes hole, try to pack */
> 
>         /* --- cacheline 1 boundary (64 bytes) --- */
>         const struct dsa_device_ops  * tag_ops;          /*    64     8 */
>         enum dsa_tag_protocol      default_proto;        /*    72     4 */
> 
>         /* XXX 4 bytes hole, try to pack */
> 
>         struct dsa_platform_data * pd;                   /*    80     8 */
>         struct list_head           rtable;               /*    88    16 */
>         unsigned int               lags_len;             /*   104     4 */
>         unsigned int               last_switch;          /*   108     4 */
> 
>         /* size: 112, cachelines: 2, members: 13 */
>         /* sum members: 101, holes: 2, sum holes: 11 */
>         /* last cacheline: 48 bytes */
> };
> 
> After:
> 
> pahole -C dsa_switch_tree net/dsa/slave.o
> struct dsa_switch_tree {
>         struct list_head           list;                 /*     0    16 */
>         struct list_head           ports;                /*    16    16 */
>         struct raw_notifier_head   nh;                   /*    32     8 */
>         unsigned int               index;                /*    40     4 */
>         struct kref                refcount;             /*    44     4 */
>         struct net_device * *      lags;                 /*    48     8 */
>         const struct dsa_device_ops  * tag_ops;          /*    56     8 */
>         /* --- cacheline 1 boundary (64 bytes) --- */
>         enum dsa_tag_protocol      default_proto;        /*    64     4 */
>         bool                       setup;                /*    68     1 */
> 
>         /* XXX 3 bytes hole, try to pack */
> 
>         struct dsa_platform_data * pd;                   /*    72     8 */
>         struct list_head           rtable;               /*    80    16 */
>         unsigned int               lags_len;             /*    96     4 */
>         unsigned int               last_switch;          /*   100     4 */
> 
>         /* size: 104, cachelines: 2, members: 13 */
>         /* sum members: 101, holes: 1, sum holes: 3 */
>         /* last cacheline: 40 bytes */
> };
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index cbbac75138d9..5d0fec6db3ae 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -136,9 +136,6 @@  struct dsa_switch_tree {
 	 */
 	struct net_device **lags;
 
-	/* Has this tree been applied to the hardware? */
-	bool setup;
-
 	/* Tagging protocol operations */
 	const struct dsa_device_ops *tag_ops;
 
@@ -147,6 +144,9 @@  struct dsa_switch_tree {
 	 */
 	enum dsa_tag_protocol default_proto;
 
+	/* Has this tree been applied to the hardware? */
+	bool setup;
+
 	/*
 	 * Configuration data for the platform device that owns
 	 * this dsa switch tree instance.