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 AD9CFA318B for ; Fri, 18 Oct 2019 09:53:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97EB01C02B; Fri, 18 Oct 2019 09:53:53 +0200 (CEST) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id CC6401C02A for ; Fri, 18 Oct 2019 09:53:52 +0200 (CEST) Received: by mail-wm1-f66.google.com with SMTP id a6so5071966wma.5 for ; Fri, 18 Oct 2019 00:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=XD+skPpxoU27Pk26yAoh334KLQbzcXVw1eToeXpRufE=; b=H9iZjkUKXmhv9goKoacCbn+91ebpPzVYF6y/12ngMoU9vF3CcvplxT5vBUZi93GE9Z BqqhffkfDzI2kiyD1Kp2eDJacmjuWjfkjOWtjT9nn5t/4klSoCdUYnVd8ADbEJD43g55 /k06F78CiTbdSmjL7lrIOnsOFFJpziEFs+6pa9oIs07Ea5qKxN23uV4cNyDcZa//mgNW 0GKwzq7V100IzsVr0hwbSEcHtpYSBW9niO85f5z106TP4EU/FWSQ7a6BxT2rifcAGXYf fnTS+CiSDtgGKDezZmEm5If4A87dgEqwDonNLDCXPTUF/YRGqCDBEFanG03WNOMmxEx5 XJ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=XD+skPpxoU27Pk26yAoh334KLQbzcXVw1eToeXpRufE=; b=jH5qKuzDuWvWnRIOH70QIy3y9uzkLhzvBepBg2M2Nfh0FCsOyF6oSaqRdG1HLaPKkj QD/2mHf4xa4kG+Ncn5UHC1PQx7Dj9wRz/vmh9Ka9R7yryWNuYwnxFCSM2W6XDDuIJJoi KbIuwmMmx/cK4zJFVXowG5lqc/ua5BmaW3nosxTDQwtAJ/fNJktjyylhKMkqWHAG8ZpV Jl4CTcw1Z9TReXQZOlbUbzrt0SlTBLapWsgI4548/phEPm7syN/nQiTz3xUUmhm5uMYS bjr3jvFH83gq+FyxRoJvnKxr2fIe8DJrQtI2cinHCq2YVJlvmRtha5Lf5AcAsCFHhq4h Z1ig== X-Gm-Message-State: APjAAAW1zRk+i/b/y6ax+IcnCL0+whYrAvLYzaKGmZvAUB0ptxsBXpWq CiB2n9+QHNslZQICM+nBilNL8A== X-Google-Smtp-Source: APXvYqxgoZnfeuj6YGmmNTN+x5TPvYk/R5pCCIibFI1XdSpPNc0JgVn/WKp1nnqUe/+suPWooxKEDw== X-Received: by 2002:a1c:ed0d:: with SMTP id l13mr6256102wmh.54.1571385232405; Fri, 18 Oct 2019 00:53:52 -0700 (PDT) Received: from 6wind.com (2a01cb0c0005a6000226b0fffeed02fc.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:226:b0ff:feed:2fc]) by smtp.gmail.com with ESMTPSA id t8sm4846205wrx.76.2019.10.18.00.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 00:53:51 -0700 (PDT) Date: Fri, 18 Oct 2019 09:53:50 +0200 From: Olivier Matz To: "Wang, Haiyue" Cc: "dev@dpdk.org" , Andrew Rybchenko , "Richardson, Bruce" , Jerin Jacob Kollanukkaran , "Wiles, Keith" , "Ananyev, Konstantin" , Morten =?utf-8?Q?Br=C3=B8rup?= , Stephen Hemminger , Thomas Monjalon Message-ID: <20191018075350.bxrcsxhsgu2uaph7@platinum> References: <20190710092907.5565-1-olivier.matz@6wind.com> <20191017144219.32708-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 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" 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, Bruce ; Wang, > > Haiyue ; Jerin Jacob Kollanukkaran ; Wiles, Keith > > ; Ananyev, Konstantin ; Morten Brørup > > ; 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 the API > > or ABI. > > > > This commit addresses these issues, by enabling the dynamic registration > > of fields or flags: > > > > - a dynamic field is a named area in the rte_mbuf structure, with a > > given size (>= 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. As > > the space in mbuf is limited, the space should only be reserved if 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 possible > > 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 place > > * 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 fields > > (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 only for dynamic flags. Today, we use (1ULL << bit) for ol_flags, which makes me wonder... is the macro really needed after all? :) > BTW, should we have a place to put the registered dynamic fields and flags > names together (a name overview -- detail Link to --> PMD's help page) ? The centralized place will be in rte_mbuf_dyn.h for fields/flags that can are shared between several dpdk areas. Some libraries/pmd could have private dynamic fields/flags. In any case, I think the same namespace than functions should be used. Probably something like this: - "rte_mbuf_dynfield_" in mbuf lib - "rte__dynfield_" in other libs - "rte_net__dynfield_" in pmds - "" in apps > Since rte_mbuf_dynfield:name & rte_mbuf_dynflag:name work as a API style, > users can check how many 'names' registered, developers can check whether > the names they want to use are registered or not ? They don't need to have > to check the rte_errno ... Just a suggestion for user experience. I did not get you point. Does my response above answers to your question? Regards, Olivier