• Eric Dumazet's avatar
    mlx4: reorganize struct mlx4_en_tx_ring · e3f42f84
    Eric Dumazet authored
    Goal is to reorganize this critical structure to increase performance.
    
    ndo_start_xmit() should only dirty one cache line, and access as few
    cache lines as possible.
    
    Add sp_ (Slow Path) prefix to fields that are not used in fast path,
    to make clear what is going on.
    
    After this patch pahole reports something much better, as all
    ndo_start_xmit() needed fields are packed into two cache lines instead
    of seven or eight
    
    struct mlx4_en_tx_ring {
    	u32                        last_nr_txbb;         /*     0   0x4 */
    	u32                        cons;                 /*   0x4   0x4 */
    	long unsigned int          wake_queue;           /*   0x8   0x8 */
    	struct netdev_queue *      tx_queue;             /*  0x10   0x8 */
    	u32                        (*free_tx_desc)(struct mlx4_en_priv *, struct mlx4_en_tx_ring *, int, u8, u64, int); /*  0x18   0x8 */
    	struct mlx4_en_rx_ring *   recycle_ring;         /*  0x20   0x8 */
    
    	/* XXX 24 bytes hole, try to pack */
    
    	/* --- cacheline 1 boundary (64 bytes) --- */
    	u32                        prod;                 /*  0x40   0x4 */
    	unsigned int               tx_dropped;           /*  0x44   0x4 */
    	long unsigned int          bytes;                /*  0x48   0x8 */
    	long unsigned int          packets;              /*  0x50   0x8 */
    	long unsigned int          tx_csum;              /*  0x58   0x8 */
    	long unsigned int          tso_packets;          /*  0x60   0x8 */
    	long unsigned int          xmit_more;            /*  0x68   0x8 */
    	struct mlx4_bf             bf;                   /*  0x70  0x18 */
    	/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
    	__be32                     doorbell_qpn;         /*  0x88   0x4 */
    	__be32                     mr_key;               /*  0x8c   0x4 */
    	u32                        size;                 /*  0x90   0x4 */
    	u32                        size_mask;            /*  0x94   0x4 */
    	u32                        full_size;            /*  0x98   0x4 */
    	u32                        buf_size;             /*  0x9c   0x4 */
    	void *                     buf;                  /*  0xa0   0x8 */
    	struct mlx4_en_tx_info *   tx_info;              /*  0xa8   0x8 */
    	int                        qpn;                  /*  0xb0   0x4 */
    	u8                         queue_index;          /*  0xb4   0x1 */
    	bool                       bf_enabled;           /*  0xb5   0x1 */
    	bool                       bf_alloced;           /*  0xb6   0x1 */
    	u8                         hwtstamp_tx_type;     /*  0xb7   0x1 */
    	u8 *                       bounce_buf;           /*  0xb8   0x8 */
    	/* --- cacheline 3 boundary (192 bytes) --- */
    	long unsigned int          queue_stopped;        /*  0xc0   0x8 */
    	struct mlx4_hwq_resources  sp_wqres;             /*  0xc8  0x58 */
    	/* --- cacheline 4 boundary (256 bytes) was 32 bytes ago --- */
    	struct mlx4_qp             sp_qp;                /* 0x120  0x30 */
    	/* --- cacheline 5 boundary (320 bytes) was 16 bytes ago --- */
    	struct mlx4_qp_context     sp_context;           /* 0x150  0xf8 */
    	/* --- cacheline 9 boundary (576 bytes) was 8 bytes ago --- */
    	cpumask_t                  sp_affinity_mask;     /* 0x248  0x20 */
    	enum mlx4_qp_state         sp_qp_state;          /* 0x268   0x4 */
    	u16                        sp_stride;            /* 0x26c   0x2 */
    	u16                        sp_cqn;               /* 0x26e   0x2 */
    
    	/* size: 640, cachelines: 10, members: 36 */
    	/* sum members: 600, holes: 1, sum holes: 24 */
    	/* padding: 16 */
    };
    
    Instead of this silly placement :
    
    struct mlx4_en_tx_ring {
    	u32                        last_nr_txbb;         /*     0   0x4 */
    	u32                        cons;                 /*   0x4   0x4 */
    	long unsigned int          wake_queue;           /*   0x8   0x8 */
    
    	/* XXX 48 bytes hole, try to pack */
    
    	/* --- cacheline 1 boundary (64 bytes) --- */
    	u32                        prod;                 /*  0x40   0x4 */
    
    	/* XXX 4 bytes hole, try to pack */
    
    	long unsigned int          bytes;                /*  0x48   0x8 */
    	long unsigned int          packets;              /*  0x50   0x8 */
    	long unsigned int          tx_csum;              /*  0x58   0x8 */
    	long unsigned int          tso_packets;          /*  0x60   0x8 */
    	long unsigned int          xmit_more;            /*  0x68   0x8 */
    	unsigned int               tx_dropped;           /*  0x70   0x4 */
    
    	/* XXX 4 bytes hole, try to pack */
    
    	struct mlx4_bf             bf;                   /*  0x78  0x18 */
    	/* --- cacheline 2 boundary (128 bytes) was 16 bytes ago --- */
    	long unsigned int          queue_stopped;        /*  0x90   0x8 */
    	cpumask_t                  affinity_mask;        /*  0x98  0x10 */
    	struct mlx4_qp             qp;                   /*  0xa8  0x30 */
    	/* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */
    	struct mlx4_hwq_resources  wqres;                /*  0xd8  0x58 */
    	/* --- cacheline 4 boundary (256 bytes) was 48 bytes ago --- */
    	u32                        size;                 /* 0x130   0x4 */
    	u32                        size_mask;            /* 0x134   0x4 */
    	u16                        stride;               /* 0x138   0x2 */
    
    	/* XXX 2 bytes hole, try to pack */
    
    	u32                        full_size;            /* 0x13c   0x4 */
    	/* --- cacheline 5 boundary (320 bytes) --- */
    	u16                        cqn;                  /* 0x140   0x2 */
    
    	/* XXX 2 bytes hole, try to pack */
    
    	u32                        buf_size;             /* 0x144   0x4 */
    	__be32                     doorbell_qpn;         /* 0x148   0x4 */
    	__be32                     mr_key;               /* 0x14c   0x4 */
    	void *                     buf;                  /* 0x150   0x8 */
    	struct mlx4_en_tx_info *   tx_info;              /* 0x158   0x8 */
    	struct mlx4_en_rx_ring *   recycle_ring;         /* 0x160   0x8 */
    	u32                        (*free_tx_desc)(struct mlx4_en_priv *, struct mlx4_en_tx_ring *, int, u8, u64, int); /* 0x168   0x8 */
    	u8 *                       bounce_buf;           /* 0x170   0x8 */
    	struct mlx4_qp_context     context;              /* 0x178  0xf8 */
    	/* --- cacheline 9 boundary (576 bytes) was 48 bytes ago --- */
    	int                        qpn;                  /* 0x270   0x4 */
    	enum mlx4_qp_state         qp_state;             /* 0x274   0x4 */
    	u8                         queue_index;          /* 0x278   0x1 */
    	bool                       bf_enabled;           /* 0x279   0x1 */
    	bool                       bf_alloced;           /* 0x27a   0x1 */
    
    	/* XXX 5 bytes hole, try to pack */
    
    	/* --- cacheline 10 boundary (640 bytes) --- */
    	struct netdev_queue *      tx_queue;             /* 0x280   0x8 */
    	int                        hwtstamp_tx_type;     /* 0x288   0x4 */
    
    	/* size: 704, cachelines: 11, members: 36 */
    	/* sum members: 587, holes: 6, sum holes: 65 */
    	/* padding: 52 */
    };
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reviewed-by: default avatarTariq Toukan <tariqt@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    e3f42f84
mlx4_en.h 23.1 KB