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 EB4744601A; Mon, 20 Jan 2025 19:07:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC8A5427A1; Mon, 20 Jan 2025 19:06:11 +0100 (CET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 5055E42796 for ; Mon, 20 Jan 2025 19:06:07 +0100 (CET) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2164b662090so85555215ad.1 for ; Mon, 20 Jan 2025 10:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737396366; x=1738001166; 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=z+a8LLpLgWCdtS8E3QPeqhCNl8lR7UMUeXUvJnoVKFcaK/X95nK1M2Kr7CKOaqzZrJ 3BGzPZQhc93381Rrzk+OFjdBR+Fa2cKDeObop4ioFzSYz4W5MVCh03nh/n4xXg7xG+Nv km1FqRqgZo+HnTPv3Hi6E/88VzGJF0fj+CqKbLP2QEq99pBoMD9bqg6tfINRXFBnuM6F 0sm7ACIBQ7CFD+ns02ORNbPyjB3lM/rVyGCSXZ6sksd2Y3kFghPsj8gAKG1LJKoJdztq XewLFHfG8Si49hRe/f3D7DZ9ckrbVjl0313wcgJGQlC6IzK9oFeHCggjHk2FA1qdmyvu Cdlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737396366; x=1738001166; 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=tGahGiiedBSuUcEKi6SBfDL5nVpcZ3GupJmEv44W3AbvXWoiC7G10in8ev6uOPc98N CMbswGvp57QqRiWy+SAhxeFrEV0T4LqQ4cY6Q0HbFa8ZlyO9kwDXVweT86aHzaJOl7w2 mqPmnBzgBCjk6hD6i9MCHdM7cFvw2UPEzS/aOAJcTSDMyE0FiPiVUFJOianx4yNMuKr8 oXyy3M9d06IJ4tDxfEl9ha5Y2QC4pOdPMyYqsRySk964oq0nhoyNBwPv5Prf5cuCdSvk 6HpJErqayFwMmp23YBsMHlUoJ+S4JDi7sqYqCjYv/pRi4VyOZlf/yRVLHDD5eAL0ZBwn SuEQ== X-Gm-Message-State: AOJu0YxqVUDco5OZvSYarY5lDInFWZZf6EpUCUWyJC4RqC7jQkTrRXgG zgKyRLYjdYXATVYDmA5b/leiGdeA24H5XfyWQeJ7yEe/wTxomk4J73dr6hT0obw87UawTApYL7m O X-Gm-Gg: ASbGnctFFoca7GJr/WXs+b4CvgRY5gk9VFk7M8ZhOsyylXmEbgD7eTimN2xV9Rdjnts KEeQbMx+B63vz4OWUYssjvQ6yK/hItTTiClxpM4ZpOs8ug6VlQ5UTuUoZsc1uoDZTCKJQWz2bHn KTc3lSF+1T+5sxnAdLqfEoYcBCOrOxAv42tJ1tiI96slA/wsIifXFbpA9E69PkK8QiZfpWhFGDi D7r/DIv8E/P1lPJLIpFOu4UHXRi3Mi8P0mvVNx5PBza7775jBKJ9tHj/kEKUi5cXelCtyR1jyel /TG08ealmIni9Tg/2D1MPKHkOJ0nm/B/hbWcISODNANCcVI= X-Google-Smtp-Source: AGHT+IF+0kwQQolEWp6yDxtay9zRpSiLOTtgP9OiKKM6fzmtVs9/Ynw24inRVSpS8ljXjxVcrNImmg== X-Received: by 2002:a05:6a20:6a10:b0:1e1:ba54:ffee with SMTP id adf61e73a8af0-1eb214abdcemr22261538637.21.1737396366565; Mon, 20 Jan 2025 10:06:06 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dab848b08sm7393982b3a.71.2025.01.20.10.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:06:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH 09/15] mempool: add allocation function attributes Date: Mon, 20 Jan 2025 10:03:27 -0800 Message-ID: <20250120180550.198121-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250120180550.198121-1-stephen@networkplumber.org> References: <20250120180550.198121-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