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 4EB0646114; Sat, 25 Jan 2025 19:41:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6BA44065F; Sat, 25 Jan 2025 19:40:35 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 515944060F for ; Sat, 25 Jan 2025 19:40:28 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2ee50ffcf14so6731318a91.0 for ; Sat, 25 Jan 2025 10:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830427; x=1738435227; 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=NwR4kU1aHStLLwHDboIbFghCG/ZEZxODVtRkRVxXLGaNzJFufZGekvDgisfBy1dli4 PwhEis6WPzbVDcYjrp0aGVd2VYYlQYAPhJauJxhOpv3vkuwP0jVgQWafhhSQtXewgLfP e3cNN2Uk3Ztnmo/alFNBXELXD0g4Mc/wZF4ofCHwX9XwtG8NY9rBllzLGSY+1pSAFWqx IHq58oWy0Tegfh79jV1/AahY/d/oe6gMf+AugzoPMrzkYV6pS0Zi56VeTDt4IPLZ+iUd 96fq+MJ55WbXd3f5c1LojiPce4WhMgKd/+py+mA7noSeQ3qGr6DiJ4R6TMhBvn8Ghy9G F/yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737830427; x=1738435227; 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=n2r5nBDqN/j22lr6mwMVvHRG+FUXNH8wlXpMZUR4B9+ae6EpyyRoeP67INMwso7tOG /qUZ9XABI7D0vcpzFX2Hvu+sGBq3XO3SmoCER7TnDDm6tfebddLMVctc6gVaNrxzYhJW KIi3MAIpq5n7vIztAXgWmxCpftQGfY4jTzouXl/CmBDtD4xuQf1vs05HRHdugVErcl2C PWI6ofT97FQFYl32SPYiFzWBXXDC+uCuv0NACkto809WNs6rn3zV08sukWl/p0JVHeSM JU3l0M+xSRsf8/pBToSL5ofeEQpEHLq5hRVpVelvbpW8G0zbPHBV0+8vOlIBjci2kjos VuDA== X-Gm-Message-State: AOJu0YyFw0PEKBmJWJPOUVXwjsN8tjbJXV/jsPwr0VcYkqndEe/BH7qg uyk+pkoalSXy8vgaZxtLbxfCkqj4Krxgle3snU4jB0bkx/QO8RYx9B4ARGCyJq1lTExzVWLOyyl r X-Gm-Gg: ASbGncs6aftyD4tYREBtiPuQCbJbOnhFMNCHDE60IvMc9gt+Plua4BpN50hjWxXRAW5 F/5L/f7qi0X/oBpr7vLDzWWbx4WlkH5AOyvcoPMXpZ2HmuXhsn68YKvSGREHkjSI1MoX5AQ7dOv boy8i7GbVIWAgf5QXrGSQy/wBogvylGqdDHEbw7y4rEtEh+MEvS1ozKzecXCC7wBdgsrrGNUw1O +B52eG+vKLdL2w/hfkzo8reWSek0TVz/8y1yoFbxX0EonXzhHUDnd0DF/qnTEbXqycbjfJG+nsQ 5/q9Oew/f3OXVUoFBh4HpG77vYMRySy1yuDBb26eA/a/6la0YmS4XDqcNA== X-Google-Smtp-Source: AGHT+IG1DPH2kBl/33P0zz7XPbQNRTxJSpemkYtOhlW4G71lqfDD5AkTRWOErxVHl0oHncWhMEV8NQ== X-Received: by 2002:a05:6a00:2719:b0:72a:83ec:b1cb with SMTP id d2e1a72fcca58-72f8adf4091mr10978968b3a.0.1737830427554; Sat, 25 Jan 2025 10:40:27 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a7614f4sm4100547b3a.97.2025.01.25.10.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 10:40:27 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Konstantin Ananyev Subject: [PATCH v6 08/15] mempool: add allocation function attributes Date: Sat, 25 Jan 2025 10:36:42 -0800 Message-ID: <20250125184010.782330-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125184010.782330-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250125184010.782330-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