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 27279A04A3; Mon, 3 Jan 2022 15:31:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE32440042; Mon, 3 Jan 2022 15:31:23 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id D507840DDA for ; Thu, 23 Dec 2021 11:08:20 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id rj2-20020a17090b3e8200b001b1944bad25so5197372pjb.5 for ; Thu, 23 Dec 2021 02:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VpdOoId11OHwprolO3yIi9c8U1/x2B7wfDsfQ0jXwD0=; b=K9U5mrh+i2khvsAe3WrA7oJhewP9qCdIUtw7WoIyoTdobTDO60wDYvlvkeWzltEF3z ERq926WsgopgQg6rJBapyAW311th32JlP65hZsAPjOTDP8eRKdbbeBA/dYEybFU8ty2g yHST1f91yKRJXQzCQH4xqM5s4Mb9gAwc7KJgekIQkdql4m5Qw9iA2AX1yK3RTN+t1hXe D48t2tZFLGx/0jA1SpKF1Xit5dfugEvgYMsH5o6UECetIK4Pvxhcxllor3V93xdjUiKc V3nOM86QTmoHVw2kC1GNyoZUeHDvoERuN+ohsiOFiKZqOCyJOHQyseTiyX+e0qrW7FUK m7Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VpdOoId11OHwprolO3yIi9c8U1/x2B7wfDsfQ0jXwD0=; b=qP+nc1qDRzTRt1SW13tRUtFeYSuYtyZfV7fuo2Pfhej6erY7qaodk5/GNsGrDU0Ir/ Ezlss1I3Wh1xenO5roEArEm8x5P4UxUQpsVrVVyDDks+3qR3F1gyHjvki99biUWHAA5X H3JGFYvT1crMFty06IaCYfQD0jahVywUZTzfyjpygUlXn5bvCpMA/JtT1RXnDRSjDVmw jvgDTy8qcjkY3NrpBTNdkHXKB7RKZ6rGGls152dhMSdAwMftNfeADixtG8JTZHlvn152 g/WWKnvembqACJ2C9k5p4ei4l9nS/V/C5duZr8vP4QcqDrCmkObS/FcoEBnEllCduvSU 8zhw== X-Gm-Message-State: AOAM532VlelS5LJN95AYQnwx+Un86KHjzbwKD4acYqExJLMiDXijhcgs Ff9+Gy3fnmI2FZpm9VIAeyA= X-Google-Smtp-Source: ABdhPJzaEKqGWfgG9GvoGcVUsVJ15ucpNsBRCh+amkDfzDp53PulxKaKT9HBVwkoDyfpafvVThgPLQ== X-Received: by 2002:a17:903:244e:b0:149:21a5:6033 with SMTP id l14-20020a170903244e00b0014921a56033mr1703349pls.37.1640254099914; Thu, 23 Dec 2021 02:08:19 -0800 (PST) Received: from localhost.localdomain ([223.223.179.210]) by smtp.gmail.com with ESMTPSA id h5sm5339011pfi.46.2021.12.23.02.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 02:08:19 -0800 (PST) From: Zhiheng Chen To: Olivier Matz , Andrew Rybchenko Cc: dev@dpdk.org, Zhiheng Chen Subject: [PATCH v3] mempool: fix the description of some function return values Date: Thu, 23 Dec 2021 10:07:41 +0000 Message-Id: <20211223100741.21292-1-chenzhiheng0227@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211222082550.436-1-chenzhiheng0227@gmail.com> References: <20211222082550.436-1-chenzhiheng0227@gmail.com> X-Mailman-Approved-At: Mon, 03 Jan 2022 15:31:22 +0100 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 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. v2: * Update the descriptions of underlying functions. v3: * Correct the description that the return value cannot be greater than 0 * Update the description of the dequeue function prototype Signed-off-by: Zhiheng Chen --- lib/mempool/rte_mempool.h | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 1e7a3c1527..cae81d8a32 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -447,6 +447,16 @@ typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp, /** * Dequeue an object from the external pool. + * + * @param mp + * Pointer to the memory pool. + * @param obj_table + * Pointer to a table of void * pointers (objects). + * @param n + * Number of objects to get. + * @return + * - 0: Success; got n objects. + * - -ENOBUFS: Not enough entries in the mempool; no object is retrieved. */ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, void **obj_table, unsigned int n); @@ -738,7 +748,7 @@ rte_mempool_ops_alloc(struct rte_mempool *mp); * Number of objects to get. * @return * - 0: Success; got n objects. - * - <0: Error; code of dequeue function. + * - -ENOBUFS: Not enough entries in the mempool; no object is retrieved. */ static inline int rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp, @@ -1452,8 +1462,8 @@ rte_mempool_put(struct rte_mempool *mp, void *obj) * @param cache * A pointer to a mempool cache structure. May be NULL if not needed. * @return - * - >=0: Success; number of objects supplied. - * - <0: Error; code of ring dequeue function. + * - 0: Success; got n objects. + * - -ENOBUFS: Not enough entries in the mempool; no object is retrieved. */ static __rte_always_inline int rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table, @@ -1521,7 +1531,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. * @@ -1534,8 +1544,8 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table, * @param cache * 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. + * - 0: Success; got n objects. + * - -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 +1567,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. * @@ -1568,8 +1578,8 @@ rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, * @param n * 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. + * - 0: Success; got n objects. + * - -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 +1598,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. * @@ -1597,8 +1607,8 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n) * @param obj_p * 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. + * - 0: Success; got n objects. + * - -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) -- 2.32.0