From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 174B1A31F3 for ; Fri, 18 Oct 2019 13:24:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D7B551D40E; Fri, 18 Oct 2019 13:24:17 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id E80851D177 for ; Fri, 18 Oct 2019 13:24:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2019 04:24:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,311,1566889200"; d="scan'208";a="348051324" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 18 Oct 2019 04:24:14 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 18 Oct 2019 04:24:14 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 18 Oct 2019 04:24:14 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.176]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.33]) with mapi id 14.03.0439.000; Fri, 18 Oct 2019 19:24:11 +0800 From: "Wang, Haiyue" To: Olivier Matz CC: "dev@dpdk.org" , Andrew Rybchenko , "Richardson, Bruce" , Jerin Jacob Kollanukkaran , "Wiles, Keith" , "Ananyev, Konstantin" , =?iso-8859-1?Q?Morten_Br=F8rup?= , Stephen Hemminger , Thomas Monjalon Thread-Topic: [PATCH v2] mbuf: support dynamic fields and flags Thread-Index: AQHVhPkmy3Bf3WM2d0mLozWwBzvtDqdfncww///kgACAAI1y0P//kmYAgACgaeA= Date: Fri, 18 Oct 2019 11:24:11 +0000 Message-ID: References: <20190710092907.5565-1-olivier.matz@6wind.com> <20191017144219.32708-1-olivier.matz@6wind.com> <20191018075350.bxrcsxhsgu2uaph7@platinum> <20191018094748.3r7dbzqvbb3rsv7u@platinum> In-Reply-To: <20191018094748.3r7dbzqvbb3rsv7u@platinum> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTFmYjM4MDMtYmUwZC00NGZkLThjMjktZTU0MDUxMTJmMWJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN0hMNDgyeVQwUittcUsyU1JzN3Aya0JGYWc5dGVrNjhNNjZhWEZoQXFkRHRqTDFLcCtCXC93ZThiQzdRMm1oOUEifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] mbuf: support dynamic fields and flags X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, October 18, 2019 17:48 > To: Wang, Haiyue > Cc: dev@dpdk.org; Andrew Rybchenko ; Richardso= n, Bruce > ; Jerin Jacob Kollanukkaran ; Wiles, Keith > ; Ananyev, Konstantin ; Morten Br=F8rup > ; Stephen Hemminger ; Thomas Monjalon > > Subject: Re: [PATCH v2] mbuf: support dynamic fields and flags >=20 > On Fri, Oct 18, 2019 at 08:28:02AM +0000, Wang, Haiyue wrote: > > Hi Olivier, > > > > > -----Original Message----- > > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > > Sent: Friday, October 18, 2019 15:54 > > > To: Wang, Haiyue > > > Cc: dev@dpdk.org; Andrew Rybchenko ; Richa= rdson, Bruce > > > ; Jerin Jacob Kollanukkaran ; Wiles, Keith > > > ; Ananyev, Konstantin ; Morten Br=F8rup > > > ; Stephen Hemminger ; Thomas Monjalon > > > > > > Subject: Re: [PATCH v2] mbuf: support dynamic fields and flags > > > > > > Hi Haiyue, > > > > > > On Fri, Oct 18, 2019 at 02:47:50AM +0000, Wang, Haiyue wrote: > > > > Hi Olivier > > > > > > > > > -----Original Message----- > > > > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > > > > Sent: Thursday, October 17, 2019 22:42 > > > > > To: dev@dpdk.org > > > > > Cc: Andrew Rybchenko ; Richardson, Bru= ce > ; > > > Wang, > > > > > Haiyue ; Jerin Jacob Kollanukkaran ; Wiles, Keith > > > > > ; Ananyev, Konstantin ; Morten Br=F8rup > > > > > ; Stephen Hemminger ; Thomas Monjalon > > > > > > > > > > Subject: [PATCH v2] mbuf: support dynamic fields and flags > > > > > > > > > > Many features require to store data inside the mbuf. As the room = in mbuf > > > > > structure is limited, it is not possible to have a field for each > > > > > feature. Also, changing fields in the mbuf structure can break th= e API > > > > > or ABI. > > > > > > > > > > This commit addresses these issues, by enabling the dynamic regis= tration > > > > > of fields or flags: > > > > > > > > > > - a dynamic field is a named area in the rte_mbuf structure, with= a > > > > > given size (>=3D 1 byte) and alignment constraint. > > > > > - a dynamic flag is a named bit in the rte_mbuf structure. > > > > > > > > > > The typical use case is a PMD that registers space for an offload > > > > > feature, when the application requests to enable this feature. A= s > > > > > the space in mbuf is limited, the space should only be reserved i= f it > > > > > is going to be used (i.e when the application explicitly asks for= it). > > > > > > > > > > The registration can be done at any moment, but it is not possibl= e > > > > > to unregister fields or flags for now. > > > > > > > > > > Signed-off-by: Olivier Matz > > > > > Acked-by: Thomas Monjalon > > > > > --- > > > > > > > > > > v2 > > > > > > > > > > * Rebase on top of master: solve conflict with Stephen's patchset > > > > > (packet copy) > > > > > * Add new apis to register a dynamic field/flag at a specific pla= ce > > > > > * Add a dump function (sugg by David) > > > > > * Enhance field registration function to select the best offset, = keeping > > > > > large aligned zones as much as possible (sugg by Konstantin) > > > > > * Use a size_t and unsigned int instead of int when relevant > > > > > (sugg by Konstantin) > > > > > * Use "uint64_t dynfield1[2]" in mbuf instead of 2 uint64_t field= s > > > > > (sugg by Konstantin) > > > > > * Remove unused argument in private function (sugg by Konstantin) > > > > > * Fix and simplify locking (sugg by Konstantin) > > > > > * Fix minor typo > > > > > > > > > > rfc -> v1 > > > > > > > > > > * Rebase on top of master > > > > > * Change registration API to use a structure instead of > > > > > variables, getting rid of #defines (Stephen's comment) > > > > > * Update flag registration to use a similar API as fields. > > > > > * Change max name length from 32 to 64 (sugg. by Thomas) > > > > > * Enhance API documentation (Haiyue's and Andrew's comments) > > > > > * Add a debug log at registration > > > > > * Add some words in release note > > > > > * Did some performance tests (sugg. by Andrew): > > > > > On my platform, reading a dynamic field takes ~3 cycles more > > > > > than a static field, and ~2 cycles more for writing. > > > > > > > > > > app/test/test_mbuf.c | 145 ++++++- > > > > > doc/guides/rel_notes/release_19_11.rst | 7 + > > > > > lib/librte_mbuf/Makefile | 2 + > > > > > lib/librte_mbuf/meson.build | 6 +- > > > > > lib/librte_mbuf/rte_mbuf.h | 23 +- > > > > > lib/librte_mbuf/rte_mbuf_dyn.c | 548 +++++++++++++++++++= ++++++ > > > > > lib/librte_mbuf/rte_mbuf_dyn.h | 226 ++++++++++ > > > > > lib/librte_mbuf/rte_mbuf_version.map | 7 + > > > > > 8 files changed, 959 insertions(+), 5 deletions(-) > > > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.c > > > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.h > > > > > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > > > index b9c2b2500..01cafad59 100644 > > > > > --- a/app/test/test_mbuf.c > > > > > +++ b/app/test/test_mbuf.c > > > > > @@ -28,6 +28,7 @@ > > > > > #include > > > > > > > > [snip] > > > > > > > > > +/** > > > > > + * Helper macro to access to a dynamic field. > > > > > + */ > > > > > +#define RTE_MBUF_DYNFIELD(m, offset, type) ((type)((uintptr_t)(m= ) + (offset))) > > > > > + > > > > > > > > The suggested macro is missed ? ;-) > > > > /** > > > > * Helper macro to access to a dynamic flag. > > > > */ > > > > #define RTE_MBUF_DYNFLAG(offset) (1ULL << (offset)) > > > > > > Yes, sorry. > > > > > > Thinking a bit more about it, I wonder if the macros below aren't > > > more consistent with the dynamic field (because they take the mbuf > > > as parameter)? > > > > > > #define RTE_MBUF_SET_DYNFLAG(m, bitnum, val) ... > > > #define RTE_MBUF_GET_DYNFLAG(m, bitnum) ... > > > > > > They could even be static inline functions. > > > > > > On the other hand, these helpers would be generic to ol_flags, not on= ly > > > for dynamic flags. Today, we use (1ULL << bit) for ol_flags, which ma= kes > > > me wonder... is the macro really needed after all? :) > > > > > > > I used as this: > > 1). in PMD: > > mb->ol_flags |=3D RTE_MBUF_DYNFLAG(ol_offset); > > > > > > 2). In testpmd > > if (mb->ol_flags & RTE_MBUF_DYNFLAG(ol_offset)) > > ... > > > > The above two macros look better in real use. >=20 > I just looked at http://patchwork.dpdk.org/patch/60908/ > In the patch, a mask is used instead of a bit number, which is indeed > better in terms of performance. This makes the macro not that useful, > given there is a specific helper. >=20 'a mask is used instead of a bit number' good practice, yes, then no need this macro, thanks for sharing. ;-)