From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id BDBDF239 for ; Thu, 28 Feb 2019 06:10:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 21:10:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,422,1544515200"; d="scan'208";a="324064653" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 27 Feb 2019 21:10:44 -0800 Received: from fmsmsx108.amr.corp.intel.com ([169.254.9.86]) by fmsmsx107.amr.corp.intel.com ([169.254.6.110]) with mapi id 14.03.0415.000; Wed, 27 Feb 2019 21:10:44 -0800 From: "Eads, Gage" To: Olivier Matz CC: "dev@dpdk.org" , "arybchenko@solarflare.com" , "Richardson, Bruce" , "Ananyev, Konstantin" , "gavin.hu@arm.com" , "Honnappa.Nagarahalli@arm.com" , "nd@arm.com" , "thomas@monjalon.net" Thread-Topic: [PATCH 1/7] stack: introduce rte stack library Thread-Index: AQHUzPb2PeLP4Ke7QkWQ7e1tt3hJwaX0iXSA Date: Thu, 28 Feb 2019 05:10:43 +0000 Message-ID: <9184057F7FC11744A2107296B6B8EB1E541ECD55@FMSMSX108.amr.corp.intel.com> References: <20190222160655.3346-1-gage.eads@intel.com> <20190222160655.3346-2-gage.eads@intel.com> <20190225104322.pxzf32gyhbeeq4tp@platinum> In-Reply-To: <20190225104322.pxzf32gyhbeeq4tp@platinum> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWJiNmEzNzUtM2Y4NS00MGUzLThkMWMtOTZlOGE0MDBjZTA3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZzl3RE5UN2VrcTlzM01sUWlJYUlVK0VRQ0ozcmdaajBTUXBZZmp2R0JUREVEWGV6dzhYN0toNWdadlBhYXJ6KyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.106] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/7] stack: introduce rte stack library 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: , X-List-Received-Date: Thu, 28 Feb 2019 05:10:46 -0000 > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Monday, February 25, 2019 4:43 AM > To: Eads, Gage > Cc: dev@dpdk.org; arybchenko@solarflare.com; Richardson, Bruce > ; Ananyev, Konstantin > ; gavin.hu@arm.com; > Honnappa.Nagarahalli@arm.com; nd@arm.com; thomas@monjalon.net > Subject: Re: [PATCH 1/7] stack: introduce rte stack library >=20 > Hi Gage, >=20 > Please find few comments below. >=20 > On Fri, Feb 22, 2019 at 10:06:49AM -0600, Gage Eads wrote: > > The rte_stack library provides an API for configuration and use of a > > bounded stack of pointers. Push and pop operations are MT-safe, > > allowing concurrent access, and the interface supports pushing and > > popping multiple pointers at a time. > > > > The library's interface is modeled after another DPDK data structure, > > rte_ring, and its lock-based implementation is derived from the stack > > mempool handler. An upcoming commit will migrate the stack mempool > > handler to rte_stack. > > > > Signed-off-by: Gage Eads >=20 > [...] >=20 > > --- /dev/null > > +++ b/doc/guides/prog_guide/stack_lib.rst > > @@ -0,0 +1,26 @@ > > +.. SPDX-License-Identifier: BSD-3-Clause > > + Copyright(c) 2019 Intel Corporation. > > + > > +Stack Library > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +DPDK's stack library provides an API for configuration and use of a > > +bounded stack of pointers. > > + > > +The stack library provides the following basic operations: > > + > > +* Create a uniquely named stack of a user-specified size and using a = user- > specified socket. > > + > > +* Push and pop a burst of one or more stack objects (pointers). These > function are multi-threading safe. > > + > > +* Free a previously created stack. > > + > > +* Lookup a pointer to a stack by its name. > > + > > +* Query a stack's current depth and number of free entries. >=20 > It seems the 80-cols limitation also applies to documentation: > https://mails.dpdk.org/archives/dev/2019-February/124917.html >=20 Sure, will fix in v2. > [...] >=20 > > --- /dev/null > > +++ b/lib/librte_stack/rte_stack.h > > @@ -0,0 +1,277 @@ > > +/* SPDX-License-Identifier: BSD-3-Clause > > + * Copyright(c) 2019 Intel Corporation */ > > + > > +/** > > + * @file rte_stack.h > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * RTE Stack. > > + * librte_stack provides an API for configuration and use of a > > +bounded stack of > > + * pointers. Push and pop operations are MT-safe, allowing concurrent > > +access, > > + * and the interface supports pushing and popping multiple pointers at= a time. > > + */ > > + > > +#ifndef _RTE_STACK_H_ > > +#define _RTE_STACK_H_ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#include > > +#include > > +#include > > + > > +#define RTE_TAILQ_STACK_NAME "RTE_STACK" > > +#define RTE_STACK_MZ_PREFIX "STK_" > > +/**< The maximum length of a stack name. */ #define > > +RTE_STACK_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ > > + sizeof(RTE_STACK_MZ_PREFIX) + 1) > > + > > +/* Structure containing the LIFO, its current length, and a lock for > > +mutual > > + * exclusion. > > + */ > > +struct rte_lifo { > > + rte_spinlock_t lock; /**< LIFO lock */ > > + uint32_t len; /**< LIFO len */ > > + void *objs[]; /**< LIFO pointer table */ }; > > + > > +/* The RTE stack structure contains the LIFO structure itself, plus > > +metadata > > + * such as its name and memzone pointer. > > + */ > > +struct rte_stack { > > + /** Name of the stack. */ > > + char name[RTE_STACK_NAMESIZE] __rte_cache_aligned; > > + /** Memzone containing the rte_stack structure */ > > + const struct rte_memzone *memzone; > > + uint32_t capacity; /**< Usable size of the stack */ > > + uint32_t flags; /**< Flags supplied at creation */ > > + struct rte_lifo lifo; /**< LIFO structure */ } __rte_cache_aligned; > > + > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * @internal Push several objects on the stack (MT-safe) > > + * > > + * @param s > > + * A pointer to the stack structure. > > + * @param obj_table > > + * A pointer to a table of void * pointers (objects). > > + * @param n > > + * The number of objects to push on the stack from the obj_table. > > + * @return > > + * Actual number of objects pushed (either 0 or *n*). > > + */ >=20 > Minor: a dot is missing at the end of the title. There are few in this pa= tch, and > maybe in next ones. >=20 Will fix. > [...] >=20 > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * Return the number of used entries in a stack. > > + * > > + * @param s > > + * A pointer to the stack structure. > > + * @return > > + * The number of used entries in the stack. > > + */ > > +static __rte_always_inline unsigned int __rte_experimental > > +rte_stack_count(struct rte_stack *s) { > > + return (unsigned int)s->lifo.len; > > +} >=20 > The argument can be const. >=20 > > + > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * Return the number of free entries in a stack. > > + * > > + * @param s > > + * A pointer to the stack structure. > > + * @return > > + * The number of free entries in the stack. > > + */ > > +static __rte_always_inline unsigned int __rte_experimental > > +rte_stack_free_count(struct rte_stack *s) { > > + return s->capacity - rte_stack_count(s); } >=20 > Same here. Unfortunately the const keyword causes a discarded-qualifiers warning in th= e non-blocking implementation, due to the call to rte_atomic64_read(). Thanks, Gage