From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 512B72A6C for ; Tue, 4 Oct 2016 13:51:44 +0200 (CEST) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7273B4C28; Tue, 4 Oct 2016 11:51:43 +0000 (UTC) Received: from [10.36.5.203] (vpn1-5-203.ams2.redhat.com [10.36.5.203]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u94Bpe4F021595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Oct 2016 07:51:42 -0400 To: Olivier Matz , dev@dpdk.org References: <1475151633-6785-1-git-send-email-maxime.coquelin@redhat.com> <8b1847c7-e1a7-7477-8937-1e49c3ec0a8f@6wind.com> Cc: stephen@networkplumber.org, mst@redhat.com, yuanhan.liu@linux.intel.com From: Maxime Coquelin Message-ID: <41ca04b5-26d6-20eb-baf2-6a34fc003d2b@redhat.com> Date: Tue, 4 Oct 2016 13:51:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <8b1847c7-e1a7-7477-8937-1e49c3ec0a8f@6wind.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 04 Oct 2016 11:51:43 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH 1/2] mbuf: add rte_pktmbuff_reset_headroom function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2016 11:51:44 -0000 On 10/03/2016 06:11 PM, Olivier Matz wrote: > 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. Good point. I'll change to: The given mbuf must have only one segment, which should be empty. Thanks, Maxime