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 DF69546130; Fri, 24 Jan 2025 19:18:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A590742D97; Fri, 24 Jan 2025 19:17:30 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 0FBF3410E3 for ; Fri, 24 Jan 2025 19:17:24 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2ee50ffcf14so5765222a91.0 for ; Fri, 24 Jan 2025 10:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737742643; x=1738347443; 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=orFt/7F3KdjoXJM3CRz41cZGR5UK5aIJTDk66/PhiME=; b=Sg4KgXC+Krb8VkVEwaGOATyutvh7dTR0NweEH6xG/0/sb9iLQys/XsNlZuSJIPp7U0 lBtng2Sot8QROi67w8FqQVmWgiBCXzQ3j4HGPA9B4iox/KuelMbd7a/i284GLDqKSJ9M TnBOe+Eq8Z53Dai0X35jvHAerbbX/Y7chaA7xKnbk18RI5fbw5ePun3FWNVBQckBsYru h0jCNYDvHLmj3S4vj1p9Imb50D6F5uU4kv7EIR6TjAmcUPvQ05Z4DB8YSt59YyQo86j1 Du1l9x2oU6ojGeoUTpzvjU9GaNelAA0K2U/676214eQ+5SMNVtq6pMZnXS7VGqiUuHVD DzKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737742643; x=1738347443; 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=orFt/7F3KdjoXJM3CRz41cZGR5UK5aIJTDk66/PhiME=; b=H5RDy12k+WdMzvsBZlHwI96b1mqa6vDvCsUY6SxUP26Wxzt1sJNJC8pJJziFlXVqAm MbtHkaInlBf7vwF2iO2GeynpED4gXSESs5OoXGMOtUW4sAn4JD1Qhy8ph93BJCYnJ7LW ADs48RMRBfSkZWfEtrgzHkTE70eZMmMv1Cxw+6ZOEza+psMfnOxgxOM3/kcFwxwylAQC ZN6IDVVROjZfdw8dPijdZHjQ0d7+ZoMsu5/uOAmScsQ2yHoIrN3wlKsWvkPEfh41+6FK Ttr0NPK0KNOhSgii/41/y8HDNQblLDXvkDfp8aZjRabg9fq2IaECCl9ykpL7Ed4pvLG0 jztA== X-Gm-Message-State: AOJu0Yw7RHRW4CQgMv5FiI+pZTW/GUcexyye42xer8wqiNcPS9llDUMH B/vGmxCGv9PhsZYpt8WGVXu2iJz2jRD+0zBwXf2fcafW7Lrz5OXmpbbYiRzNwu7NRwfBaIbhD30 Q X-Gm-Gg: ASbGncvxH1jJPqBLwX+sTB+loxEEhbO9QRd80EitKRB63BF3huvoe5IXTAkISmMLWat Gu/dhmJqCnSf/h24MmBtLramVdN806Ihrs32ll5fGpYIlE22fvMQRnRowGzIALtAl/AcYpDI6dE Rj34R8AiC8JYVBqDhRFYxz2x3iIydjvj77SuN901OI0ztRy9y7Y7M1AxIC1Xg7x+6IsNNgTArTC f1SUVFI4EfRCT5JgsHnUQHG+htM3ztGbMPvEFJe5Ltpw7/UY8ZtsiX+Y0chx+eGBFDY0vWueLPo XRiBLKItDeVFi5ub0ZjeQU5Ed0ATar/nru40GnD24k5nUgteYgWQKtO6fw== X-Google-Smtp-Source: AGHT+IHReDaZ27HG7nBD4hKvc6Oeq2iEuzZRZQLk1/WgyQ/u5whDXdd3eD4yPFC0pigPsgHEnmX5fA== X-Received: by 2002:a05:6a00:894:b0:725:cd8b:d798 with SMTP id d2e1a72fcca58-72f8b3c81afmr8629871b3a.9.1737742643278; Fri, 24 Jan 2025 10:17:23 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a6b2ed8sm2184477b3a.41.2025.01.24.10.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 10:17:22 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Konstantin Ananyev , Andrew Rybchenko Subject: [PATCH v4 09/16] mempool: add allocation function attributes Date: Fri, 24 Jan 2025 10:15:00 -0800 Message-ID: <20250124181704.86567-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250124181704.86567-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250124181704.86567-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 Acked-by: Konstantin Ananyev --- 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