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 B4E4D46104; Sat, 25 Jan 2025 03:14:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 523E44066A; Sat, 25 Jan 2025 03:13:39 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id C014F4060B for ; Sat, 25 Jan 2025 03:13:26 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2166022c5caso43753185ad.2 for ; Fri, 24 Jan 2025 18:13:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737771206; x=1738376006; 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=xwJ4+cusv1rtbqGcroXfakxMXZ7UrN+ktaEPpm6i4IY=; b=Nui5y6mESGqc+mMfiA0PIyxLknG0mjfT/o2YykzpMM1qYuzswjIVY4vczxqIuRtaFs EyBayaYTdceZ6xog9WkgCj4BYuCqYXANerZR7TKXMyw4WpmepACqNFKPGkXHfui3R55r AFLJg6VvCI8kCkFfrp5fqhqSWQuq0dQaU4U174PPnHRHya9exsd58lXRHJXpejObBoIS XeroLvt3bKSLbpCvMD/7ynUQ2yb6Sq+oa6scigFi9KZ6TyAGCQhlc3sniu0tpR+Srwgo w6H56Xvc9gj2DPX9bn50cYvXBPvSoiJ4bTOQ7UsHfFy16lmp6P+4JSInRhCUHIAvm7Ax MDeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737771206; x=1738376006; 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=xwJ4+cusv1rtbqGcroXfakxMXZ7UrN+ktaEPpm6i4IY=; b=oDL9oy064vQX8eHX2Wp165uZ/n6flhajJOag9wTsnlNFLVD6IMfrESu3iW5+NRfV2x VpLF6JeXMhceYj6iPjWJK7FtIvFYvjXtLAUejjDzAUFGLad5tKShkzyZIdorzLQK4vR2 gfmVXfd3TaTFC7hCvwDmjdrXCFWUb/C7GCcfEAgqkUWzwJTMy81mIWyYeP+V0xJO+XFV Tm9ZDrKNEz+xESSUHkAaWA4aQBSxO8eglwfKUUUCxCOsgxBP05XXV0v5NkYIqM0LAaUC 4OUek/lFegvHD3ckic9XtTT58Ql1/bC/9q/5QHXfvgrv+97MqKaNhiV1P72pt4UMlcnA s7tQ== X-Gm-Message-State: AOJu0Yy2nlt5IrZWXrWxREhFdHFTAH8hsBIXVNO/UKSNnKxXRu6H5TSE oxASZ3DGiwMCsnQplZ9PgmY/byAO61e5Qf0guSXkMvuFNwhxojCVgnjKzE8nHdVbgVqO5O2IFTc R X-Gm-Gg: ASbGnctOvtTAOrsIgHNikm963q8jLfy8GtCZdH1WuNi+ofnXI1eBa4pGb520Yg6Yv5z h5P1AAJnlaPxskBEgaEDRLdl5W30GQQN34dQzuINan6BOLcujR+69l4xGLvq3w4xQCu+YuGTEm0 4SAamM6syXVk1HUnpy09kgbstSPBysMOM/FhoEJdQh9j5Vghs/ZCZQMEM+sU5Ia27fsIavjN+mG q63r3kBm0vj8T4Bw+K9jXMu1I8ETBdvelJftmN44wVRzZlfb6B7kWOmBoMh7GBFXFRy0tub9i1U jgdIZQg0tnjVIO58jcpOfBO1RuNITfdS/NL9/fN/qJTvzr3sP69c46oGfg== X-Google-Smtp-Source: AGHT+IHG2rQ5BUsbpT+6XXmc4fWX7ZOBDiAE0kPcZHz4Kfe2ShM6rL2lzMb2bkSkZXmXR+Qq5t7t1Q== X-Received: by 2002:a05:6a00:4616:b0:72a:bb83:7804 with SMTP id d2e1a72fcca58-72dafb9d647mr36816703b3a.17.1737771206061; Fri, 24 Jan 2025 18:13:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 18:13:25 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v5 11/16] ring: add allocation function attributes Date: Fri, 24 Jan 2025 18:11:24 -0800 Message-ID: <20250125021305.76485-12-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-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 ring is allocated but not freed correctly. Signed-off-by: Stephen Hemminger Acked-by: Konstantin Ananyev --- lib/ring/rte_ring.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h index 63a71d5871..28bfbde1f1 100644 --- a/lib/ring/rte_ring.h +++ b/lib/ring/rte_ring.h @@ -34,6 +34,7 @@ * for more information. */ +#include #include #include @@ -119,6 +120,16 @@ ssize_t rte_ring_get_memsize(unsigned int count); int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, unsigned int flags); + +/** + * De-allocate all memory used by the ring. + * + * @param r + * Ring to free. + * If NULL then, the function does nothing. + */ +void rte_ring_free(struct rte_ring *r); + /** * Create a new ring named *name* in memory. * @@ -183,16 +194,8 @@ int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, * - ENOMEM - no appropriate memory area found in which to create memzone */ struct rte_ring *rte_ring_create(const char *name, unsigned int count, - int socket_id, unsigned int flags); - -/** - * De-allocate all memory used by the ring. - * - * @param r - * Ring to free. - * If NULL then, the function does nothing. - */ -void rte_ring_free(struct rte_ring *r); + int socket_id, unsigned int flags) + __rte_malloc __rte_dealloc(rte_ring_free, 1); /** * Dump the status of the ring to a file. -- 2.45.2