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 1B327460E8; Wed, 22 Jan 2025 18:36:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6331240689; Wed, 22 Jan 2025 18:36:06 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 2193D4065A for ; Wed, 22 Jan 2025 18:35:58 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21675fd60feso153918585ad.2 for ; Wed, 22 Jan 2025 09:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737567357; x=1738172157; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AR3wCQMp4qY4zr/HqKS3b7QVupEj4lO5bUHcAs7eInY=; b=ygmDneG1cgeQQbRHafGymVGvbId/8TQCifMATBHNOWN1PDidXPrVQe4dlhlVYmjthV N+qeXw56fL0a8yaI8Ys2NOgp37v9ckbxKP8C1H22AxuUJY/TAH6c77E1EHT99onleWKx qwNUXHr+lBYYSiBS28wHeNVARgyMQI39Irmk13rIoQ0tMyehdUwaHsit+FojfZ3Dbi1w zq9u31gsM49aeevLYQU+QSfDOeDTm7OE5Y0640CIyaXHy6Ty6iIsOaWmMXrDT1Ym3vlI c3SsWiOGV81z3sMeUpraGgPNmMRPVmQfdBpX5H9fR4Lv+wsgScr9CndFqyEeLcJu1D8p TUkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737567357; x=1738172157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AR3wCQMp4qY4zr/HqKS3b7QVupEj4lO5bUHcAs7eInY=; b=ErB7AUZtxUN3ZFqeGCItozcX04tqujGKRjKkHeubYDvz5a8sdHiKV2GGkKd9B2XCN3 Fun30Q/0b46ZX3/7Jxbfq2ApZowJGDLQBirVzxBhteMfLJu9TlS1B4jOTOvwe7ylsPfL 8xvndVgjCF2T6T8rMfSW1KW0W6yqiST9b8kEbgmgBF7hmabn2jaHt+0Qv7L0qdkmm9t3 Wi18m1NR8WL3QgM0zTYlYqyY/UlP8V7r9ugLPID93pZ2nCSHCziC3tYTBP/znX8bMitL gxt9KBl+EjvXM4lgAwQBnwXCI3cpObFdbQqs/7ekTFPvK5aaDQyhG41KWWtEfrzI6m0M juRQ== X-Gm-Message-State: AOJu0YwFZchlBH36iY0uQrPv2MtETnzF+NUr5AZVCjYx9nbFO2ml1bJc /oKep4LUeetNAV98nSoalCQ0wo5DBdGvuIN9iPjXjes+hvRQYvChX0nJMjgz74ak28AdN5W04E2 F X-Gm-Gg: ASbGncsWHN0iWvlgvGKqEy5qrmD9d25iCn9l1zqqFOTyrAUiQZiEcw/T6Lp5saHbSAF YVrgi5KYNC1XsMsl1PgHiEDGppy4F/ADaHTvtC94AIWl+MEAfG0iMTPAyQwhZLtdR7kFAgHAJDZ QvECuYSRzrEo6iB1og4nRbAnJIQ+NIAWkdsXREgat47/z6H/Q8m3+uRPmhrim9gMy5FKtvE3Im+ PN7amfNdajfCNZ3oHABdtQNnRVp8VLjdCVex9a/rQYupXinZbHy+0Ng7lHlIbP1S3/km/rhSgWg SsUZ2CH7AyfqW5o4dpErXqdLzs6cYFqckS+/85hWqtcJHyo= X-Google-Smtp-Source: AGHT+IEJdfEZi+UlsLoKcD8l91VOJn6GxWK+tei9uA27tHk8EkaYM+9Evyq3FR6lDrOJMcygSlNpoA== X-Received: by 2002:a17:903:1205:b0:216:6be9:fd57 with SMTP id d9443c01a7336-21c35551b81mr371068425ad.21.1737567357266; Wed, 22 Jan 2025 09:35:57 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3bc64dsm97469285ad.122.2025.01.22.09.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 09:35:56 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v2 09/15] mempool: add allocation function attributes Date: Wed, 22 Jan 2025 09:32:53 -0800 Message-ID: <20250122173521.305108-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250122173521.305108-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250122173521.305108-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Use function attributes to catch cases where mempool is allocated but not freed correctly. Signed-off-by: Stephen Hemminger --- lib/mempool/rte_mempool.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 7bdc92b812..c495cc012f 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -1012,6 +1012,20 @@ typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp, */ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *); +/** + * Free a mempool + * + * Unlink the mempool from global list, free the memory chunks, and all + * memory referenced by the mempool. The objects must not be used by + * other cores as they will be freed. + * + * @param mp + * A pointer to the mempool structure. + * If NULL then, the function does nothing. + */ +void +rte_mempool_free(struct rte_mempool *mp); + /** * Create a new mempool named *name* in memory. * @@ -1095,7 +1109,8 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, unsigned cache_size, unsigned private_data_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg, rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, - int socket_id, unsigned flags); + int socket_id, unsigned int flags) + __rte_malloc __rte_dealloc(rte_mempool_free, 1); /** * Create an empty mempool @@ -1132,22 +1147,10 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, * with rte_errno set appropriately. See rte_mempool_create() for details. */ struct rte_mempool * -rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, - unsigned cache_size, unsigned private_data_size, - int socket_id, unsigned flags); -/** - * Free a mempool - * - * Unlink the mempool from global list, free the memory chunks, and all - * memory referenced by the mempool. The objects must not be used by - * other cores as they will be freed. - * - * @param mp - * A pointer to the mempool structure. - * If NULL then, the function does nothing. - */ -void -rte_mempool_free(struct rte_mempool *mp); +rte_mempool_create_empty(const char *name, unsigned int n, unsigned int elt_size, + unsigned int cache_size, unsigned int private_data_size, + int socket_id, unsigned int flags) + __rte_malloc __rte_dealloc(rte_mempool_free, 1); /** * Add physically contiguous memory for objects in the pool at init -- 2.45.2