[dpdk-dev] [PATCH 01/13] mbuf: replace data pointer by an offset

Olivier MATZ olivier.matz at 6wind.com
Mon Sep 8 11:52:31 CEST 2014


Hi Bruce,

On 09/03/2014 05:49 PM, Bruce Richardson wrote:
> From: Olivier Matz <olivier.matz at 6wind.com>
> 
> Original patch:
>  The mbuf structure already contains a pointer to the beginning of the
>  buffer (m->buf_addr). It is not needed to use 8 bytes again to store
>  another pointer to the beginning of the data.
> 
>  Using a 16 bits unsigned integer is enough as we know that a mbuf is
>  never longer than 64KB. We gain 6 bytes in the structure thanks to
>  this modification.
> 
>  Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
> 
> This version:
> * Updated original patch to apply to latest on mainline.
> * Disabled vector PMD in config as it relies heavily on the mbuf layout
>   This will be re-enabled in a subsequent commit once vPMD has been
>   reworked to take account of mbuf changes.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
>
> [...]
>
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index 32e8474..669e7f5 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -119,6 +119,13 @@ struct rte_mbuf {
>  	void *buf_addr;           /**< Virtual address of segment buffer. */
>  	phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */
>  	uint16_t buf_len;         /**< Length of segment buffer. */
> +
> +	/* valid for any segment */
> +	struct rte_mbuf *next;    /**< Next segment of scattered packet. */
> +	uint16_t data_off;
> +	uint16_t data_len;        /**< Amount of data in segment buffer. */
> +	uint32_t pkt_len;         /**< Total pkt len: sum of all segments. */
> +

Here, the compiler will add some padding between "buf_len" and "next"
(6 bytes in 64bits, 2 in 32bits). Shouldn't we add "reserved" fields
or at least a comment ? Another idea would be to reorganize the fields
to avoid padding, if possible.

Except this remarq, Acked-by: Olivier Matz <olivier.matz at 6wind.com>


More information about the dev mailing list