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 43BD546114;
	Sat, 25 Jan 2025 19:41:17 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 4BD6840665;
	Sat, 25 Jan 2025 19:40:37 +0100 (CET)
Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com
 [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 4E1B440648
 for <dev@dpdk.org>; Sat, 25 Jan 2025 19:40:29 +0100 (CET)
Received: by mail-pj1-f41.google.com with SMTP id
 98e67ed59e1d1-2eed82ca5b4so5468007a91.2
 for <dev@dpdk.org>; Sat, 25 Jan 2025 10:40:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830428;
 x=1738435228; 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=F3bIn/d1N16rdlLN2NLsU1uSkVbqKA+eN9u/q92Mt5Y=;
 b=nNgQeGOmLXYqolBa07d7JsTRgSryssn9QRToKwRTrTYMLcuKx30aYDhQohOLykOxc8
 S6V1Lmj40jE/cXbv0vwao5tQXuta9/LYpf3ScnLIS0o0YDWKK5DN+0GrAc9JAU0txIg9
 YNKylbUXBXQXQ/HE6eVckZfPql9nmZq9aJe9YySpHWa1Mm4VDICLaYZAOkLYJZcdKi6V
 owcWNFfzrpkVkwafDdbxvPGCDVl0C2WDGsYA0qRkD9XadOt6KvzVej86wES4qOrXzIwJ
 iXUhSaXhQWB76IPBRtjWHjmBg1GY8kMwU4IiypCJBulVOkt+seoH3t34EEpR3NxHR7SV
 aKnQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737830428; x=1738435228;
 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=F3bIn/d1N16rdlLN2NLsU1uSkVbqKA+eN9u/q92Mt5Y=;
 b=hXVs8UDcKUdQ9JL9+nqHvRd7A1JpjfkJIfdLr5PC4d8uIgbPN6+qJSz1/6RB/OZzdV
 ZUvpPoiS88SJZhU7WfTqPg4AYynU9CIroH1twJSeCvJlNdfjVXSFY6Xw6ydoEPxEuHuP
 5dVeNGqRVPY+zujo7ihlIHnXJblhlNWbdVMqzfIairkANa6AP9u3nAcHlL6u4xhstUS6
 el6OGwP3wsgX49QJJr9pgD66v+Z3Ti3BgPwi9EiOiSVjVwc0LEhm/vpdV3G0Xi/kxjol
 hNRLeRWOs5uwgzPsGdAk9Dfre6X88WCnHu9U6nUyhVEnNZJzhNIc2cwW3ZM31UYun9JT
 3DSQ==
X-Gm-Message-State: AOJu0YwaspqgzV46sXU4e575KaYLHOUj0JsT+A0HEV0uVTlm4uqS9juf
 OZm9wQ1vdsLlkqny5GXzN8h9tsKAXv4+ogDweeHs2HdtJ676vvylFN9568ihuukfu7NrBuZmGKo
 s
X-Gm-Gg: ASbGncubiM2e6QAeR1sxESn/QomdTTEqexc/qXlTMQ6jj3HkHoShsbBuER3rIP0dz7k
 jRZvPxJIjj/v8V6Z6p1NBSByLeg5f4DjpfKR/SheL75RmIWTVyKxcTReyDGSMdh/vtL++y4JS07
 6Slii6cRUS4z6ftBsYuyQ2l0VYq2Ra/XOv/Nl7iuycr1vlM9EA2HH6l9vsTBa1fNGfzQaZg6pmn
 qHY1inysYY9I0URSJOvUZ7WpmDeWnnsWYyMcy1L2IEOTu+SASEY8VQ9aJzKnT4uMVs2T+GT8p5e
 D3gZN02XbTGdQ+KfQQ443uxssEc71rzIBzT6PRY/av0SaUH/QzQaYiHJLg==
X-Google-Smtp-Source: AGHT+IEtb+45GxDMixmBLuSxpHLkbSu2HiyZMaBc2saqItOmJRJIHy36TbdlA6yu3xAjWNrnm87oNA==
X-Received: by 2002:a05:6a00:2443:b0:726:c23f:4e5c with SMTP id
 d2e1a72fcca58-72daf9be6a8mr43474194b3a.1.1737830428526; 
 Sat, 25 Jan 2025 10:40:28 -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.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 25 Jan 2025 10:40:27 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v6 09/15] eventdev: add allocation function attributes
Date: Sat, 25 Jan 2025 10:36:43 -0800
Message-ID: <20250125184010.782330-10-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 eventdev is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eventdev/rte_event_ring.h | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h
index 5769da269e..a8f308e4d6 100644
--- a/lib/eventdev/rte_event_ring.h
+++ b/lib/eventdev/rte_event_ring.h
@@ -247,7 +247,18 @@ int
 rte_event_ring_init(struct rte_event_ring *r, const char *name,
 	unsigned int count, unsigned int flags);
 
-/*
+
+/**
+ * De-allocate all memory used by the ring.
+ *
+ * @param r
+ *   Pointer to ring to created with rte_event_ring_create().
+ *   If r is NULL, no operation is performed.
+ */
+void
+rte_event_ring_free(struct rte_event_ring *r);
+
+/**
  * Create an event ring structure
  *
  * This function allocates memory and initializes an event ring inside that
@@ -288,8 +299,8 @@ rte_event_ring_init(struct rte_event_ring *r, const char *name,
  *    - ENOMEM - no appropriate memory area found in which to create memzone
  */
 struct rte_event_ring *
-rte_event_ring_create(const char *name, unsigned int count, int socket_id,
-		unsigned int flags);
+rte_event_ring_create(const char *name, unsigned int count, int socket_id, unsigned int flags)
+	__rte_malloc __rte_dealloc(rte_event_ring_free, 1);
 
 /**
  * Search for an event ring based on its name
@@ -304,16 +315,6 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 struct rte_event_ring *
 rte_event_ring_lookup(const char *name);
 
-/**
- * De-allocate all memory used by the ring.
- *
- * @param r
- *   Pointer to ring to created with rte_event_ring_create().
- *   If r is NULL, no operation is performed.
- */
-void
-rte_event_ring_free(struct rte_event_ring *r);
-
 /**
  * Return the size of the event ring.
  *
-- 
2.45.2