From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <konstantin.ananyev@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 3956CADE8
 for <dev@dpdk.org>; Wed, 18 Feb 2015 10:49:02 +0100 (CET)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga102.fm.intel.com with ESMTP; 18 Feb 2015 01:49:00 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.09,600,1418112000"; d="scan'208";a="679649749"
Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159])
 by fmsmga002.fm.intel.com with ESMTP; 18 Feb 2015 01:48:59 -0800
Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by
 IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Wed, 18 Feb 2015 09:48:58 +0000
Received: from irsmsx105.ger.corp.intel.com ([169.254.7.117]) by
 irsmsx155.ger.corp.intel.com ([169.254.14.159]) with mapi id 14.03.0195.001;
 Wed, 18 Feb 2015 09:48:58 +0000
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>, Olivier MATZ
 <olivier.matz@6wind.com>
Thread-Topic: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references
Thread-Index: AQHQSgLlubcXB2CIb0Ksk8gcVlJrSpz2I0IAgAAFSACAAAIAoA==
Date: Wed, 18 Feb 2015 09:48:58 +0000
Message-ID: <2601191342CEEE43887BDE71AB977258213EF5E4@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>
In-Reply-To: <20150218093548.GA14884@bricha3-MOBL3>
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" <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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 18 Feb 2015 09:49:02 -0000

Hi lads,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> 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 references
>=20
> 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 refc=
nt
> > >field in the mbuf struct permanently.
> > >
> > >Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.co=
m>
> >
> > I think removing the refcount compile option goes in the right
> > direction. However, activating the refcount will break the applications
> > 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.
> >
>=20
> While I understand how the macros make certain assumptions, how does acti=
vating
> the refcnt specifically lead to the problems you describe? Could you expl=
ain
> that part in a bit more detail?
>=20
> Thanks,
> /Bruce
>=20

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_MB=
UF_FROM_BADDR macros.
They are still there, for example rte_pktmbuf_detach() still uses it to res=
tore mbuf's buf_addr.
The only principal change here, is that we don't rely more  on RTE_MBUF_FRO=
M_BADDR to determine,
Is that indirect mbuf or not.=20
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)
=20
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.
> >
> > 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.
> >
> > Another idea would be to add a field in indirect mbufs that stores
> > the pointer to the "parent" mbuf.
> >
> > Regards,
> > Olivier
> >