From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [PATCH 1/2] mbuf: add rte_pktmbuff_reset_headroom function Date: Mon, 3 Oct 2016 18:11:53 +0200 Message-ID: <8b1847c7-e1a7-7477-8937-1e49c3ec0a8f@6wind.com> References: <1475151633-6785-1-git-send-email-maxime.coquelin@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: stephen@networkplumber.org, mst@redhat.com, yuanhan.liu@linux.intel.com To: Maxime Coquelin , dev@dpdk.org Return-path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 12E362B88 for ; Mon, 3 Oct 2016 18:12:00 +0200 (CEST) In-Reply-To: <1475151633-6785-1-git-send-email-maxime.coquelin@redhat.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Maxime, On 09/29/2016 02:20 PM, Maxime Coquelin wrote: > Some application use rte_mbuf_raw_alloc() function to improve > performance by not resetting mbuf's fields to their default state. > > This can be however problematic for mbuf consumers that need some > headroom, meaning that data_off field gets decremented after > allocation. When the mbuf is re-used afterwards, there might not > be enough room for the consumer to prepend anything, if the data_off > field is not reset to its default value. > > This patch adds a new rte_pktmbuf_reset_headroom() function that > applications can call to reset the data_off field. > This patch also replaces current data_off affectations in the mbuf > lib with a call to this function. > > Signed-off-by: Maxime Coquelin Sounds like a good idea. Just one small comment below. > > /** > + * Reset the data_off field of a packet mbuf to its default value. > + * > + * The given mbuf must have only one segment. > + * > + * @param m > + * The packet mbuf's data_off field has to be reset. > + */ > +static inline void rte_pktmbuf_reset_headroom(struct rte_mbuf *m) > +{ > + m->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len); > +} Maybe we should also highlight in the API comment that the segment should be empty. Thanks, Olivier