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 EE71E46104; Sat, 25 Jan 2025 03:14:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FF8640661; Sat, 25 Jan 2025 03:13:36 +0100 (CET) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 62E9A402EB for ; Sat, 25 Jan 2025 03:13:24 +0100 (CET) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21680814d42so45885445ad.2 for ; Fri, 24 Jan 2025 18:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737771204; x=1738376004; 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=l90Z3tiuDPIRq+9wqrhKzDxJ5ibBPt/ev22GitP+e2dUEUYO0lJ8NKW3r6rHdTTgYO 4ymPm6xBiZBcmAoA4JTx/P/AZx4bcz4Qs3UvIVYLa28692D8Yt3sgL0Dn7NQLp/RBwUM HRlGSCvCkO2sSd4ARuYayAiBpWtA9zPNvTygwPzCV9RtbyUXO6ba/etSV6acG2jUbPkZ Jtw7uTvu+xhAfTmR7h+tDXOzUud7eAXmcr1CHjB1c4L2vdYNLSaOp22y2HCQi1rOQJiv y9zwxWrqYUdn6tcKgBG1/pIMCrKLUvTn/uKiwWalHmTRzWCHHqdIW/rBL1nnsO8468AP fhLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737771204; x=1738376004; 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=anAcLMsCp2t5b5+DU9l93KlMpjrZHUu2wSyD2eYJ4iO44n/HNon4ap7jdRRamUQEYv lwlnFbrpYlaF4PD3hNTg3FwlH3UKd4Wkt/114To6q1kmPqrlFYQ9/BEDpHJVGXb0AszJ MS0SKD9fgxGUgeqy5cI8WTATO4QqHEbcgkZJW2WR+mxYFHO/MBXqfzFfJQcuc7yDnmYn TVpu1zYtEMtcYIaj4slQSkY93snpHUiIGW+HsujmRz5dlieBgn4WGhOEdNCjVXUxiDMI gC2TNon4ZPT33N/XYDNq5paq53ULIRTTEwCuFz2cSAxpicF9Uf2YNOQcJyRcr47UdS6h FLOQ== X-Gm-Message-State: AOJu0YxQF719O8XvhhtqCTiFDGoAAypBQliavGo0Db52SJjQtzDB3TzY DeMHJ7WrcmU1h2DUi02K1kCgs+NdbIlEExiv9Yz3n4JqLNrX9Cte2qMYF/mPTxX21SQIsDQMBsR 7 X-Gm-Gg: ASbGnctOCp0wWJ8wDxwcgUGu+RRAwykpt5AQt17fEXPYpQx62608SbDsfpsI3S+1vhX VP+MWClkPw6HOzXqtAw87Qbo43lmj1SKGhm885f8P24UEKaDdXkZJxsn1MuzC4PaxheNqvB+wX3 gRTw0Ra9TIMsK6pPzy6Hhe2Z4ikk2kZ0kOH+tBTQfsxamG6XCY7+GFx338vrXRdWhjfG/GjScrq WGLZSipce7FZJzyedEfxFbKNWQ2SjmxnQ/ROgYzviG3XzXJoerLybE20nG79ra4rRXdHUNtwOWI p4/mUrOG5rCwbQUsGUjuztDYJ/9tgXdvm16VFUpmcjKz0mF4Q7RaNGxXdQ== X-Google-Smtp-Source: AGHT+IG/ejxadGv/dwLg7Q8BipIXStsxm3503GQ3PyKJfTj8X27ACBAlQUcSDDrAAxWmrusC2LNQZA== X-Received: by 2002:a05:6a00:4c94:b0:724:e75b:22d1 with SMTP id d2e1a72fcca58-72dafa800c4mr46237868b3a.16.1737771203672; Fri, 24 Jan 2025 18:13:23 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ac48e84e199sm2345256a12.11.2025.01.24.18.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 18:13:23 -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 v5 09/16] mempool: add allocation function attributes Date: Fri, 24 Jan 2025 18:11:22 -0800 Message-ID: <20250125021305.76485-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125021305.76485-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.org> <20250125021305.76485-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