All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier MATZ <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: Bruce Richardson
	<bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: [RFC PATCH 04/14] mbuf: replace data pointer by an offset
Date: Tue, 12 Aug 2014 10:55:37 +0200	[thread overview]
Message-ID: <53E9D689.8010901@6wind.com> (raw)
In-Reply-To: <1407789890-17355-5-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Hi Bruce,

On 08/11/2014 10:44 PM, Bruce Richardson wrote:
> From: Olivier Matz <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
>
> 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-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
>
> This version:
> * Updated original patch to apply to latest on mainline.
> * Disabled vector PMD in config as it relies heavily on the mbuf layout
>
> Signed-off-by: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Remaining references shown by:

git grep 
"\(pkt->data[^_]\)\|\(mb->data[^_]\)\|\(m->data[^_]\)\|\(mbuf->data[^_]\)"

In:
app/test-pmd/ieee1588fwd.c
examples/vhost_xen/main.c
lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c
lib/librte_pmd_pcap/rte_eth_pcap.c
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c

> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -140,6 +140,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. */
> +
>  #ifdef RTE_MBUF_REFCNT
>  	/**
>  	 * 16-bit Reference counter.
> @@ -156,18 +163,12 @@ struct rte_mbuf {
>  #else
>  	uint16_t refcnt_reserved;     /**< Do not use this field */
>  #endif
> -	uint16_t reserved;             /**< Unused field. Required for padding. */
> -	uint16_t ol_flags;            /**< Offload features. */
> -
> -	/* valid for any segment */
> -	struct rte_mbuf *next;  /**< Next segment of scattered packet. */
> -	void* data;             /**< Start address of data in segment buffer. */
> -	uint16_t data_len;      /**< Amount of data in segment buffer. */
>
>  	/* these fields are valid for first segment only */
>  	uint8_t nb_segs;        /**< Number of segments. */
>  	uint8_t in_port;        /**< Input port. */
> -	uint32_t pkt_len;       /**< Total pkt len: sum of all segment data_len. */
> +	uint16_t ol_flags;            /**< Offload features. */
> +	uint16_t reserved;             /**< Unused field. Required for padding. */

I think we should try to keep comments aligned if possible.

>
>  	/* offload features, valid for first segment only */
>  	union rte_vlan_macip vlan_macip;
> @@ -185,7 +186,7 @@ struct rte_mbuf {
>  		uint16_t metadata16[0];
>  		uint32_t metadata32[0];
>  		uint64_t metadata64[0];
> -	};
> +	} __rte_cache_aligned;
>  } __rte_cache_aligned;
>

In my initial patch, there was a "reserved2" field at the end of the
rte_mbuf structure to keep its size to 64 bytes. This is not really
required because of the __rte_cache_aligned, but I wonder if it's a
problem to have metadata not starting on a cache line. There can be
some conflicts if some part of the code use *(uint32 *)(m + 1)
and other part of code m->metadata32[0].

By the way (that's completely off-topic), but I don't really see why
having this metadata at the end of mbuf structure is useful.

> @@ -1523,7 +1523,8 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
>   		}
>
>   		/* Prefetch data of first segment, if configured to do so. */
> -		rte_packet_prefetch(first_seg->data);
> +		rte_packet_prefetch((char *)first_seg->buf_addr +
> +			first_seg->data_off);
>

It seems there is a trailing whitespace here after the "+" (seen by
"git am").


Regards,
Olivier

  parent reply	other threads:[~2014-08-12  8:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11 20:44 [RFC PATCH 00/14] Extend the mbuf structure Bruce Richardson
     [not found] ` <1407789890-17355-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-11 20:44   ` [RFC PATCH 01/14] mbuf: rename RTE_MBUF_SCATTER_GATHER into RTE_MBUF_REFCNT Bruce Richardson
     [not found]     ` <1407789890-17355-2-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-11 21:45       ` Stephen Hemminger
     [not found]         ` <20140811144521.21058e5b-a7a0dvSY7KrRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-08-12  7:59           ` Olivier MATZ
     [not found]             ` <53E9C96F.6050904-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-08-12 16:25               ` Richardson, Bruce
2014-08-11 20:44   ` [RFC PATCH 02/14] mbuf: remove rte_ctrlmbuf Bruce Richardson
     [not found]     ` <1407789890-17355-3-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12  8:27       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 03/14] mbuf: remove the rte_pktmbuf structure Bruce Richardson
     [not found]     ` <1407789890-17355-4-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12  8:38       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 04/14] mbuf: replace data pointer by an offset Bruce Richardson
     [not found]     ` <1407789890-17355-5-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12  8:55       ` Olivier MATZ [this message]
2014-08-11 20:44   ` [RFC PATCH 05/14] mbuf: rename in_port to just port Bruce Richardson
     [not found]     ` <1407789890-17355-6-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12  9:00       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 06/14] mbuf: reorder fields by time-of-use Bruce Richardson
     [not found]     ` <1407789890-17355-7-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12 10:03       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 07/14] ixgbe: rework vector pmd following mbuf changes Bruce Richardson
2014-08-11 20:44   ` [RFC PATCH 08/14] mbuf: split mbuf across two cache lines Bruce Richardson
2014-08-11 20:44   ` [RFC PATCH 09/14] Fix performance regression due to moved pool ptr Bruce Richardson
     [not found]     ` <1407789890-17355-10-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12 11:28       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 10/14] mbuf: set next pointer to NULL on mbuf free Bruce Richardson
2014-08-11 20:44   ` [RFC PATCH 11/14] ixgbe: make mbuf_initializer queue variable global Bruce Richardson
     [not found]     ` <1407789890-17355-12-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-11 21:47       ` Stephen Hemminger
     [not found]         ` <20140811144737.3ef08d36-a7a0dvSY7KrRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org>
2014-08-11 22:03           ` Richardson, Bruce
2014-08-11 20:44   ` [RFC PATCH 12/14] ixgbe: Make vector stores unaligned Bruce Richardson
2014-08-11 20:44   ` [RFC PATCH 13/14] mbuf: cleanup + added in additional mbuf fields Bruce Richardson
     [not found]     ` <1407789890-17355-14-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-08-12 14:18       ` Olivier MATZ
2014-08-11 20:44   ` [RFC PATCH 14/14] ixgbe: Allow vector RX of scattered packets Bruce Richardson
2014-08-12 14:43   ` [RFC PATCH 00/14] Extend the mbuf structure Olivier MATZ
     [not found]     ` <53EA2828.7080005-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-08-20 12:22       ` Richardson, Bruce
2014-08-20  7:08   ` Cao, Min
     [not found]     ` <B6059B2012717B4390714544B1F509E110D591C2-0J0gbvR4kTggGBtAFL8yw7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-08-20 11:11       ` Richardson, Bruce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53E9D689.8010901@6wind.com \
    --to=olivier.matz-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.