• Vladimir Oltean's avatar
    net: mscc: ocelot: minimize holes in struct ocelot_port · 6d0be600
    Vladimir Oltean authored
    Reorder members of struct ocelot_port to eliminate holes and reduce
    structure size. Pahole says:
    
    Before:
    
    struct ocelot_port {
            struct ocelot *            ocelot;               /*     0     8 */
            struct regmap *            target;               /*     8     8 */
            bool                       vlan_aware;           /*    16     1 */
    
            /* XXX 7 bytes hole, try to pack */
    
            const struct ocelot_bridge_vlan  * pvid_vlan;    /*    24     8 */
            unsigned int               ptp_skbs_in_flight;   /*    32     4 */
            u8                         ptp_cmd;              /*    36     1 */
    
            /* XXX 3 bytes hole, try to pack */
    
            struct sk_buff_head        tx_skbs;              /*    40    96 */
            /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
            u8                         ts_id;                /*   136     1 */
    
            /* XXX 3 bytes hole, try to pack */
    
            phy_interface_t            phy_mode;             /*   140     4 */
            bool                       is_dsa_8021q_cpu;     /*   144     1 */
            bool                       learn_ena;            /*   145     1 */
    
            /* XXX 6 bytes hole, try to pack */
    
            struct net_device *        bond;                 /*   152     8 */
            bool                       lag_tx_active;        /*   160     1 */
    
            /* XXX 1 byte hole, try to pack */
    
            u16                        mrp_ring_id;          /*   162     2 */
    
            /* XXX 4 bytes hole, try to pack */
    
            struct net_device *        bridge;               /*   168     8 */
            int                        bridge_num;           /*   176     4 */
            u8                         stp_state;            /*   180     1 */
    
            /* XXX 3 bytes hole, try to pack */
    
            int                        speed;                /*   184     4 */
    
            /* size: 192, cachelines: 3, members: 18 */
            /* sum members: 161, holes: 7, sum holes: 27 */
            /* padding: 4 */
    };
    
    After:
    
    struct ocelot_port {
            struct ocelot *            ocelot;               /*     0     8 */
            struct regmap *            target;               /*     8     8 */
            struct net_device *        bond;                 /*    16     8 */
            struct net_device *        bridge;               /*    24     8 */
            const struct ocelot_bridge_vlan  * pvid_vlan;    /*    32     8 */
            phy_interface_t            phy_mode;             /*    40     4 */
            unsigned int               ptp_skbs_in_flight;   /*    44     4 */
            struct sk_buff_head        tx_skbs;              /*    48    96 */
            /* --- cacheline 2 boundary (128 bytes) was 16 bytes ago --- */
            u16                        mrp_ring_id;          /*   144     2 */
            u8                         ptp_cmd;              /*   146     1 */
            u8                         ts_id;                /*   147     1 */
            u8                         stp_state;            /*   148     1 */
            bool                       vlan_aware;           /*   149     1 */
            bool                       is_dsa_8021q_cpu;     /*   150     1 */
            bool                       learn_ena;            /*   151     1 */
            bool                       lag_tx_active;        /*   152     1 */
    
            /* XXX 3 bytes hole, try to pack */
    
            int                        bridge_num;           /*   156     4 */
            int                        speed;                /*   160     4 */
    
            /* size: 168, cachelines: 3, members: 18 */
            /* sum members: 161, holes: 1, sum holes: 3 */
            /* padding: 4 */
            /* last cacheline: 40 bytes */
    };
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    6d0be600
ocelot.h 30.8 KB