From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 6E16EB472 for ; Wed, 18 Feb 2015 11:47:37 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 18 Feb 2015 02:47:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,600,1418112000"; d="scan'208";a="667997633" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga001.fm.intel.com with ESMTP; 18 Feb 2015 02:47:34 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.117]) by irsmsx110.ger.corp.intel.com ([169.254.15.236]) with mapi id 14.03.0195.001; Wed, 18 Feb 2015 10:47:34 +0000 From: "Ananyev, Konstantin" To: Olivier MATZ , "Richardson, Bruce" Thread-Topic: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references Thread-Index: AQHQSgLlubcXB2CIb0Ksk8gcVlJrSpz2I0IAgAAFSACAAAIAoIAABMSAgAAEGACAAAJKAIAAAwwAgAAB79A= Date: Wed, 18 Feb 2015 10:47:33 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213EF67E@irsmsx105.ger.corp.intel.com> References: <1424102913-18944-1-git-send-email-sergio.gonzalez.monroy@intel.com> <1424102913-18944-3-git-send-email-sergio.gonzalez.monroy@intel.com> <54E45888.7070603@6wind.com> <20150218093548.GA14884@bricha3-MOBL3> <2601191342CEEE43887BDE71AB977258213EF5E4@irsmsx105.ger.corp.intel.com> <20150218100003.GA14728@bricha3-MOBL3> <54E46612.7050809@6wind.com> <20150218102253.GA6804@bricha3-MOBL3> <54E46A8C.9010105@6wind.com> In-Reply-To: <54E46A8C.9010105@6wind.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references 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: Wed, 18 Feb 2015 10:47:37 -0000 > -----Original Message----- > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 18, 2015 10:34 AM > To: Richardson, Bruce > Cc: Ananyev, Konstantin; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references >=20 > Hi, >=20 > On 02/18/2015 11:22 AM, Bruce Richardson wrote: > > On Wed, Feb 18, 2015 at 11:14:42AM +0100, Olivier MATZ wrote: > >> On 02/18/2015 11:00 AM, Bruce Richardson wrote: > >>> On Wed, Feb 18, 2015 at 09:48:58AM +0000, Ananyev, Konstantin wrote: > >>>> Hi lads, > >>>> > >>>>> -----Original Message----- > >>>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richards= on > >>>>> Sent: Wednesday, February 18, 2015 9:36 AM > >>>>> To: Olivier MATZ > >>>>> Cc: dev@dpdk.org > >>>>> Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT referenc= es > >>>>> > >>>>> On Wed, Feb 18, 2015 at 10:16:56AM +0100, Olivier MATZ wrote: > >>>>>> Hi Sergio, > >>>>>> > >>>>>> On 02/16/2015 05:08 PM, Sergio Gonzalez Monroy wrote: > >>>>>>> This patch removes all references to RTE_MBUF_REFCNT, setting the= refcnt > >>>>>>> field in the mbuf struct permanently. > >>>>>>> > >>>>>>> Signed-off-by: Sergio Gonzalez Monroy > >>>>>> > >>>>>> I think removing the refcount compile option goes in the right > >>>>>> direction. However, activating the refcount will break the applica= tions > >>>>>> that reserve a private zone in mbufs. This is due to the macros > >>>>>> RTE_MBUF_TO_BADDR() and RTE_MBUF_FROM_BADDR() that suppose that > >>>>>> the beginning of the mbuf is 128 bytes (sizeof mbuf) before the > >>>>>> data buffer. > >>>>>> > >>>>> > >>>>> While I understand how the macros make certain assumptions, how doe= s activating > >>>>> the refcnt specifically lead to the problems you describe? Could yo= u explain > >>>>> that part in a bit more detail? > >>>>> > >>>>> Thanks, > >>>>> /Bruce > >>>>> > >>>> > >>>> Olivier, I also don't understand your concern here. > >>>> As I can see, that patch has nothing to do with RTE_MBUF_FROM_BADDR/= RTE_MBUF_FROM_BADDR macros. > >>>> They are still there, for example rte_pktmbuf_detach() still uses it= to restore mbuf's buf_addr. > >>>> The only principal change here, is that we don't rely more on RTE_M= BUF_FROM_BADDR to determine, > >>>> Is that indirect mbuf or not. > >>>> Instead we use a special falg for that purpose: > >>>> > >>>> -#define RTE_MBUF_INDIRECT(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr= ) !=3D (mb)) > >>>> +#define RTE_MBUF_INDIRECT(mb) (mb->ol_flags & IND_ATTACHED_MBUF) > >>>> > >>>> BTW, Sergio as I said before, I think it should be: > >>>> #define RTE_MBUF_INDIRECT(mb) ((mb)->ol_flags & IND_ATTACHED_MBUF) > >>>> > >>>> Konstantin > >>>> > >>>> > >>>>>> For RTE_MBUF_TO_BADDR(), it's relatively easy to replace it. The > >>>>>> mbuf pool could store the size of the private size like it's done > >>>>>> for mbp_priv->mbuf_data_room_size. Using rte_mempool_from_obj(m) > >>>>>> or m->pool, we can retrieve the mbuf pool and this value, then > >>>>>> compute the buffer address. > >>> > >>> Agreed, that makes sense. > >>> > >>>>>> > >>>>>> For RTE_MBUF_FROM_BADDR(), it's more complex. We could ensure that > >>>>>> a backpointer to the mbuf is always located before the data buffer= , > >>>>>> but it looks difficult to do. > >>> > >>> On the other hand, with the proposed refcnt change Sergio proposes, w= e no > >>> longer use this macro in any of the built-in mbuf handling for freein= g mbufs. > >>> Does this need to be solved at anything other than the application le= vel? > >> > >> It's still used in __rte_pktmbuf_prefree_seg() to retrieve the > >> parent mbuf (direct) from the indirect mbuf beeing freed. > >> > > Yes, my bad. > > How was this managed before, since refcnt field seems to be necessary i= n order > > to effectively manage indirect mbufs? Is this just the case that this i= s something > > that never worked and that needs to be solved, or is it something that = was > > working that this patch will now break? >=20 > This is something that never worked before: refcounts are not compatible > with reserving private data in mbufs. This patch does not change the > issue, it is still there. >=20 > Before the patch, an application that wanted to reserve a private > data could disable refcounts at compile-time. > After the patch, the solution is just to avoid using refcounts. I'd say avoid using mbuf_attach/detach. refcnt itself has nothing to do with that. I finally understood what you are talking about ... About private data - I suppose it is a matter of another patch. I still think it would be better to reserve private data space before mbuf,= not after (at mbuf pool initialisation time).=20 Then *BADDR* macros could be unaffected. Konstantin >=20 > Regards, > Olivier >=20