]> git.droids-corp.org - dpdk.git/commitdiff
mbuf: move pool pointer in first half
authorThomas Monjalon <thomas@monjalon.net>
Thu, 29 Oct 2020 00:55:43 +0000 (01:55 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 12 Nov 2020 15:39:10 +0000 (16:39 +0100)
According to the Technical Board decision
(http://mails.dpdk.org/archives/dev/2020-November/191859.html),
the mempool pointer in the mbuf struct is moved
from the second to the first half.
It may increase performance in some cases
on systems having 64-byte cache line, i.e. mbuf split in two cache lines.

Due to this change, all fields after "pool" are moved up.
Hopefully no vector data path is impacted.

Moving this field gives more space to dynfield1
while dropping the temporary dynfield0.

This is how the mbuf layout looks like (pahole-style):

word  type                              name                byte  size
 0    void *                            buf_addr;         /*   0 +  8 */
 1    rte_iova_t                        buf_iova          /*   8 +  8 */
      /* --- RTE_MARKER64               rearm_data;                   */
 2    uint16_t                          data_off;         /*  16 +  2 */
      uint16_t                          refcnt;           /*  18 +  2 */
      uint16_t                          nb_segs;          /*  20 +  2 */
      uint16_t                          port;             /*  22 +  2 */
 3    uint64_t                          ol_flags;         /*  24 +  8 */
      /* --- RTE_MARKER                 rx_descriptor_fields1;        */
 4    uint32_t             union        packet_type;      /*  32 +  4 */
      uint32_t                          pkt_len;          /*  36 +  4 */
 5    uint16_t                          data_len;         /*  40 +  2 */
      uint16_t                          vlan_tci;         /*  42 +  2 */
 5.5  uint64_t             union        hash;             /*  44 +  8 */
 6.5  uint16_t                          vlan_tci_outer;   /*  52 +  2 */
      uint16_t                          buf_len;          /*  54 +  2 */
 7    struct rte_mempool *              pool;             /*  56 +  8 */
      /* --- RTE_MARKER                 cacheline1;                   */
 8    struct rte_mbuf *                 next;             /*  64 +  8 */
 9    uint64_t             union        tx_offload;       /*  72 +  8 */
10    struct rte_mbuf_ext_shared_info * shinfo;           /*  80 +  8 */
11    uint16_t                          priv_size;        /*  88 +  2 */
      uint16_t                          timesync;         /*  90 +  2 */
11.5  uint32_t                          dynfield1[9];     /*  92 + 36 */
16    /* --- END                                             128      */

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
doc/guides/rel_notes/deprecation.rst
lib/librte_kni/rte_kni_common.h
lib/librte_mbuf/rte_mbuf.h
lib/librte_mbuf/rte_mbuf_core.h
lib/librte_mbuf/rte_mbuf_dyn.c

index f3258eb3f72530e72f4f0b106c8d2dbc758066c2..efb09f0c5e7338cfa251dd3f7077c112cf72d615 100644 (file)
@@ -81,13 +81,6 @@ Deprecation Notices
   us extending existing enum/define.
   One solution can be using a fixed size array instead of ``.*MAX.*`` value.
 
-* mbuf: Some fields will be converted to dynamic API in DPDK 20.11
-  in order to reserve more space for the dynamic fields, as explained in
-  `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_.
-  As a consequence, the layout of the ``struct rte_mbuf`` will be re-arranged,
-  avoiding impact on vectorized implementation of the driver datapaths,
-  while evaluating performance gains of a better use of the first cache line.
-
 * ethdev: The flow director API, including ``rte_eth_conf.fdir_conf`` field,
   and the related structures (``rte_fdir_*`` and ``rte_eth_fdir_*``),
   will be removed in DPDK 20.11.
index 36d66e2ffab7af8d94c2cd8f7ec0f647fc0b8123..ffb3182731a0b3d97e11b56aeb6fc9d7f6755c62 100644 (file)
@@ -84,10 +84,11 @@ struct rte_kni_mbuf {
        char pad2[4];
        uint32_t pkt_len;       /**< Total pkt len: sum of all segment data_len. */
        uint16_t data_len;      /**< Amount of data in segment buffer. */
+       char pad3[14];
+       void *pool;
 
        /* fields on second cache line */
        __attribute__((__aligned__(RTE_CACHE_LINE_MIN_SIZE)))
-       void *pool;
        void *next;             /**< Physical address of next mbuf in kernel. */
 };
 
index 3190a29ccecfa55792d6e5352a39d3146bc81957..c4c9ebfaa03b4fc21db8a641983226d909ed4172 100644 (file)
@@ -1107,7 +1107,6 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr,
 static inline void
 rte_mbuf_dynfield_copy(struct rte_mbuf *mdst, const struct rte_mbuf *msrc)
 {
-       memcpy(&mdst->dynfield0, msrc->dynfield0, sizeof(mdst->dynfield0));
        memcpy(&mdst->dynfield1, msrc->dynfield1, sizeof(mdst->dynfield1));
 }
 
index debaace95a57583e336338ff8b4d25ac40613f7e..567551deabc76d3fe50f56911eee662f658da4b5 100644 (file)
@@ -586,12 +586,11 @@ struct rte_mbuf {
 
        uint16_t buf_len;         /**< Length of segment buffer. */
 
-       uint64_t dynfield0[1]; /**< Reserved for dynamic fields. */
+       struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
 
        /* second cache line - fields only used in slow path or on TX */
        RTE_MARKER cacheline1 __rte_cache_min_aligned;
 
-       struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
        struct rte_mbuf *next;    /**< Next segment of scattered packet. */
 
        /* fields to support TX offloads */
@@ -645,7 +644,7 @@ struct rte_mbuf {
        /** Timesync flags for use with IEEE1588. */
        uint16_t timesync;
 
-       uint32_t dynfield1[7]; /**< Reserved for dynamic fields. */
+       uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */
 } __rte_cache_aligned;
 
 /**
index fd3e019a22b152aaefc0cb64248375bc529d2116..7d5e942bf0d8c72cc30f6b5094fa44a608f998a8 100644 (file)
@@ -125,7 +125,6 @@ init_shared_mem(void)
                 * rte_mbuf_dynfield_copy().
                 */
                memset(shm, 0, sizeof(*shm));
-               mark_free(dynfield0);
                mark_free(dynfield1);
 
                /* init free_flags */