[RFC,net-next,01/11] net: enetc: optimize struct enetc_rx_swbd layout

Message ID 20230206100837.451300-2-vladimir.oltean@nxp.com
State New
Headers
Series NXP ENETC AF_XDP zero-copy sockets |

Commit Message

Vladimir Oltean Feb. 6, 2023, 10:08 a.m. UTC
  Eliminate a 4 byte hole on arm64, to be able to introduce a new member
to this structure in a future patch without increasing the overall
structure size.

Before:

struct enetc_rx_swbd {
        struct page *              page;                 /*     0     8 */
        enum dma_data_direction    dir;                  /*     8     4 */

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

        dma_addr_t                 dma;                  /*    16     8 */
        u16                        page_offset;          /*    24     2 */
        u16                        len;                  /*    26     2 */

        /* size: 32, cachelines: 1, members: 5 */
        /* sum members: 24, holes: 1, sum holes: 4 */
        /* padding: 4 */
        /* last cacheline: 32 bytes */
};

After:

struct enetc_rx_swbd {
        struct page *              page;                 /*     0     8 */
        dma_addr_t                 dma;                  /*     8     8 */
        enum dma_data_direction    dir;                  /*    16     4 */
        u16                        page_offset;          /*    20     2 */
        u16                        len;                  /*    22     2 */

        /* size: 24, cachelines: 1, members: 5 */
        /* last cacheline: 24 bytes */
};

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index e21d096c5a90..704aa1f9dfa3 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -48,10 +48,10 @@  struct enetc_tx_swbd {
 	(SKB_WITH_OVERHEAD(ENETC_RXB_TRUESIZE) - XDP_PACKET_HEADROOM)
 
 struct enetc_rx_swbd {
-	dma_addr_t dma;
 	struct page *page;
-	u16 page_offset;
+	dma_addr_t dma;
 	enum dma_data_direction dir;
+	u16 page_offset;
 	u16 len;
 };