From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 18043A034E; Tue, 21 Dec 2021 11:16:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0342240141; Tue, 21 Dec 2021 11:16:24 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 9DA0640040 for ; Tue, 21 Dec 2021 11:16:22 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] mempool: fix the description of some function return values Date: Tue, 21 Dec 2021 11:16:18 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86D8C@smartserver.smartshare.dk> In-Reply-To: <20211218171421.8082-1-chenzhiheng0227@gmail.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] mempool: fix the description of some function return values Thread-Index: Adf2Ses7bsdbsotbS4GfnJmSJAI+2QAB3MUA References: <20211218171421.8082-1-chenzhiheng0227@gmail.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Zhiheng Chen" , "Olivier Matz" , "Andrew Rybchenko" Cc: X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Zhiheng Chen [mailto:chenzhiheng0227@gmail.com] > Sent: Saturday, 18 December 2021 18.14 >=20 > In rte_mempool_ring.c, the committer uses the symbol ENOBUFS to > describe the return value of function common_ring_sc_dequeue, but in > rte_mempool.h, the symbol ENOENT is used to describe the return value > of function rte_mempool_get. If the user of dpdk uses the symbol = ENOENT > as the judgment condition of the return value, it may cause some > abnormal phenomena in their own programs, such as when the mempool > space is exhausted. >=20 > Fixes: ea5dd2744b90 ("mempool: cache optimisations") >=20 > Signed-off-by: Zhiheng Chen > --- > lib/mempool/rte_mempool.h | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) >=20 > diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h > index 1e7a3c1527..2a7d3455ef 100644 > --- a/lib/mempool/rte_mempool.h > +++ b/lib/mempool/rte_mempool.h > @@ -1521,7 +1521,7 @@ rte_mempool_do_generic_get(struct rte_mempool > *mp, void **obj_table, > * Get several objects from the mempool. > * > * If cache is enabled, objects will be retrieved first from cache, > - * subsequently from the common pool. Note that it can return -ENOENT > when > + * subsequently from the common pool. Note that it can return = -ENOBUFS > when > * the local cache and common pool are empty, even if cache from = other > * lcores are full. > * > @@ -1535,7 +1535,7 @@ rte_mempool_do_generic_get(struct rte_mempool > *mp, void **obj_table, > * A pointer to a mempool cache structure. May be NULL if not > needed. > * @return > * - 0: Success; objects taken. > - * - -ENOENT: Not enough entries in the mempool; no object is > retrieved. > + * - -ENOBUFS: Not enough entries in the mempool; no object is > retrieved. > */ > static __rte_always_inline int > rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, > @@ -1557,7 +1557,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, > void **obj_table, > * mempool creation time (see flags). > * > * If cache is enabled, objects will be retrieved first from cache, > - * subsequently from the common pool. Note that it can return -ENOENT > when > + * subsequently from the common pool. Note that it can return = -ENOBUFS > when > * the local cache and common pool are empty, even if cache from = other > * lcores are full. > * > @@ -1569,7 +1569,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, > void **obj_table, > * The number of objects to get from the mempool to obj_table. > * @return > * - 0: Success; objects taken > - * - -ENOENT: Not enough entries in the mempool; no object is > retrieved. > + * - -ENOBUFS: Not enough entries in the mempool; no object is > retrieved. > */ > static __rte_always_inline int > rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, > unsigned int n) > @@ -1588,7 +1588,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, = void > **obj_table, unsigned int n) > * mempool creation (see flags). > * > * If cache is enabled, objects will be retrieved first from cache, > - * subsequently from the common pool. Note that it can return -ENOENT > when > + * subsequently from the common pool. Note that it can return = -ENOBUFS > when > * the local cache and common pool are empty, even if cache from = other > * lcores are full. > * > @@ -1598,7 +1598,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, = void > **obj_table, unsigned int n) > * A pointer to a void * pointer (object) that will be filled. > * @return > * - 0: Success; objects taken. > - * - -ENOENT: Not enough entries in the mempool; no object is > retrieved. > + * - -ENOBUFS: Not enough entries in the mempool; no object is > retrieved. > */ > static __rte_always_inline int > rte_mempool_get(struct rte_mempool *mp, void **obj_p) Good catch! These functions call some underlying functions, and the = descriptions of those functions don't mention -ENOENT or -ENOBUFS; they = only say <0 to indicate error. Please consider updating the underlying = functions too, so the chain of descriptions is complete. The description = of this function should not be based on code inspection of its = underlying public functions, it should be based on the descriptions of = its underlying functions. Alternatively, describe the return value like = the underlying functions: <0 means error returned from dequeue function. > @@ -1777,7 +1777,7 @@ void rte_mempool_list_dump(FILE *f); > * The pointer to the mempool matching the name, or NULL if not > found. > * NULL on error > * with rte_errno set appropriately. Possible rte_errno values > include: > - * - ENOENT - required entry not available to return. > + * - ENOBUFS - required entry not available to return. > * > */ > struct rte_mempool *rte_mempool_lookup(const char *name); This one is using ENOENT, so don't change the description. Ref: http://code.dpdk.org/dpdk/latest/source/lib/mempool/rte_mempool.c#L1356