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 7D0C5460FF; Thu, 23 Jan 2025 17:31:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 618FD40E16; Thu, 23 Jan 2025 17:30:34 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id E1D6240DCB for ; Thu, 23 Jan 2025 17:30:25 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2165448243fso24723635ad.1 for ; Thu, 23 Jan 2025 08:30:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737649825; x=1738254625; 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=IoEXNMIMeyY5C0sXnsGKdijjQow9y2wTPL1b5msXZkA=; b=jAZKpdNVbDfNs4H+ibomUkzdkWeFfTymhfzhLvbeKDrQglu0H2lXKRIolDf81QlA9h Copt6PS9+CxGAn39Cyt+q/SQlQReNG0QNc7OaMVB0A4TvUfHHvdVOLtOXwuFNlwrxcpR sGoDubvU32YvEpKoATEPmIbVEr3ytzqawahQq/PqKcoH3Ibv9SbN/Ssfwk16olRe1tG8 dFcq4kRmKPv2EUJa6pZsq+ozvjAjuNVwm8HM3PZ4cjYc2BIhVItLw9RmbnpTslqD+oOj NVv9CiWlIg1vyY26xPjJRsFqdWXA9Iy2GesbWvso/kZla1i7T702WU10XIzs66n7nIBZ qkqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737649825; x=1738254625; 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=IoEXNMIMeyY5C0sXnsGKdijjQow9y2wTPL1b5msXZkA=; b=DT/Q4x8U7oiYcEzkWfKwJ1YJ89JPLa/1I5XH3UgOk0n/14zOhWLNqo7Y70hlZC/Qsk JBDroF1nWAMUKNipCOe7t5QnNLw/3UQ5Hx4HURxbTxJZ76AaYEb9jH6eX1Kkl8hZKbFw 6c8S7aKTo4dvGNa68r/3JRLhh008vvtICq9vdDMMYGypHND4tAkCSLlQmivxs7EF7HPt j9ojV93IlcRekywFCDOdcJvLbyrbe6f1EqnLTeKf50J//iB+6dx7tLzf8dUK24XZ95WB jC40VNaBRYdrdirp50aIw3RjaV8Nvo9+ejuUrqP70TyuKkLN7ZtE8aZnRTkQ4f7Qkbnc HrIw== X-Gm-Message-State: AOJu0Yytlva+wDnhc4TVJ9OZm4DkTU3aIuxyAqD+z/SaMgqRoD+ulm+d 9ICY97pi03fS6CSj5DEYRPqyH/YV36U2/tKsmqeo1+kvRe1PEe2u8awjJE99mX9f9d0ikVKKMPQ 3 X-Gm-Gg: ASbGncu40jIk4gMUr3qrYgMBfBvA4P0LpQzNpFB9vnYAITvnHflk/Hu8/1wP6KFlzR1 aG/TT3zmMYUuT69N1AWcYoCVC/GiiIN//l74tim7HFn1XFt2je5fzPLBbVQcQapktTihA1BOs6H wzwrSAE6QGux4p/UMysZ1ZdWJTTbnpg4DULDRXeebCNoHdR7hKDpHJhuoxf5O4sxbWfGJDdLxux 0q/WrVkh9lJlVbOMN/BUEyw39HaX0tKX+Jzt+AueYJqN+sh7aUImACvw/bKQWQRPP5/xBGXBap8 G53aXD9M3YIQxPX9bbo1GAQj2Wm+Qtz8NO2l07kiBy52AG3/tGi/D017aQ== X-Google-Smtp-Source: AGHT+IFJL2S7Fiv3ryMfeJnJJFAkS0GOIM7jtBLV5WDeJXFwM1p3LNJUlqEVBUXbjHLjmP3JKma+IA== X-Received: by 2002:a05:6a20:9143:b0:1e1:aba4:209c with SMTP id adf61e73a8af0-1eb2157fb99mr46782758637.29.1737649825103; Thu, 23 Jan 2025 08:30:25 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ac4907f076dsm64601a12.37.2025.01.23.08.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 08:30:24 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Andrew Rybchenko Subject: [PATCH v3 09/15] mempool: add allocation function attributes Date: Thu, 23 Jan 2025 08:28:09 -0800 Message-ID: <20250123163003.23394-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250123163003.23394-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250123163003.23394-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Reviewed-by: Morten Brørup --- 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