From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A57F046114;
	Sat, 25 Jan 2025 19:41:23 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 536004066A;
	Sat, 25 Jan 2025 19:40:38 +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 1EB6640648
 for <dev@dpdk.org>; Sat, 25 Jan 2025 19:40:30 +0100 (CET)
Received: by mail-pl1-f169.google.com with SMTP id
 d9443c01a7336-21661be2c2dso54152585ad.1
 for <dev@dpdk.org>; Sat, 25 Jan 2025 10:40:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830429;
 x=1738435229; 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=EAK5f7nRVdtUxX1tSDc9o0O4lit9IF9lBu6bK+x3SYAIoXVD8tkvQm/CtAcVEhWSTv
 Gf0r3T3+5vXsQzTJFNw3yRrLqNzyg0hK1/xdeoR/cyLzskoJeeU81eVDUW2brbxBPDkl
 oWke6DpTqG2L/uXxtOvwwG9gK7skLmLWPYcXPEZrFJ4Ia3gdnAG9GC6147hmUjaqtDD+
 QGm2NA6tbDvtE37M8sBW0wNq1DYRBvFN22r7FIf/eAqgG+g/cyQLaOe2rCy7Z+Xj6PEh
 rzHDoVYq1yXfJFKFFstJ3d/3ffGDoW+iof8QFih2h909zOByvZ0lbRvlanWAywaG9UAS
 YgZw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737830429; x=1738435229;
 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=EnuhnZM+iudNS72yOISH1pGjHsMhBITkMED5ea8qpTm/Y3jLqhxIVi4nFZwhh25sBQ
 8aOX+xBOtww7FhZXVCHQdvJMcTSU7vJn6uVv7z7pp6x+Kk2gV42CTZ0Gj9CwyIpEUsFE
 G1Ukvk0JwzyuXNfJXpMaHyrvd6EjQGpkJQxPnty9sW2ukGwq98/kdtPu5r1XV44jHIm+
 iNhaGHeIbvw7xHteDKpheVElBVFcThDoqiFCps4T+HC9F22sbyW/ZlMFCUFXq6LGEvsV
 fkaymHuJqIRBlwFA8fTaw8TlC6dsFy+YAYE+icmbMaHn3keIKi0eYYBRExCvOAt1OH36
 AWfw==
X-Gm-Message-State: AOJu0YyWl/3Jlg1v/jBrPWpa9HOt99g/BIEAaFAW56+Lna1enl63bFIz
 tncsePz9NgWR/tKhGo3J94V6/nCx4ZwV/hfm8pIEY8WHnn28iLe2XkAJHlkq0u0KN5jTeHkQCUS
 +
X-Gm-Gg: ASbGnctyWsLZvqZr+p8HPY6pX8GNF+kw2mjILK7vRqOt8tPSApLwNeEf8aXt7ub5ySw
 YeSbn7fJeBRMCkyPR6Hc46p+ovofW6auJhSn/Q2jG8ahl9zCiB4JMEi86Hqt7pyX16MWRh6Mj+B
 9FX0XF9Mbhg7z7REica+uVKKauKE0sapjeGxbgmPGYgMKlx+WAnMmgAwmRtKWEusvdKu++cd5ds
 Xezc/067VmPFMXsW9oViEGjPrCRhsjfpB/IKeQsFfXCZ8vX2laYaYHfN6Bh+kThGOBteNxaHv+W
 JxXwdiRUfeRoqhEfokdhanApQDvnek2Afr4cgCTaBT3rT4GnHbha3izXFA==
X-Google-Smtp-Source: AGHT+IHv6HbIg3NTaNLbPo8rhTKUNNUOSAEVkQgkImp78oyEtHVdXYP8wCcOtUEkRIIcxIfY/stOsQ==
X-Received: by 2002:a05:6a20:b72f:b0:1e6:b2d7:4cf0 with SMTP id
 adf61e73a8af0-1eb215fb5d5mr42105074637.41.1737830429312; 
 Sat, 25 Jan 2025 10:40:29 -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.28
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 25 Jan 2025 10:40:28 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Konstantin Ananyev <konstantin.ananyev@huawei.com>
Subject: [PATCH v6 10/15] ring: add allocation function attributes
Date: Sat, 25 Jan 2025 10:36:44 -0800
Message-ID: <20250125184010.782330-11-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-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=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 <stephen@networkplumber.org>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
---
 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 <rte_common.h>
 #include <rte_ring_core.h>
 #include <rte_ring_elem.h>
 
@@ -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