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 7E919460E8; Wed, 22 Jan 2025 18:37:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AA94406B4; Wed, 22 Jan 2025 18:36:09 +0100 (CET) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id E9BDB40661 for ; Wed, 22 Jan 2025 18:35:59 +0100 (CET) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-21c2f1b610dso127679365ad.0 for ; Wed, 22 Jan 2025 09:35:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737567359; x=1738172159; 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=+3umZXjLzM+bJmhv36LYBTXy+5dxDZTh3TYkhb2jhwE=; b=AjD4shj7azMzi9K0xcWDd2SH4VfBDn5y4gpFUgPa8g2HToRPyQGSy/6FY4O4IvUbbF D0r7pYal6jcJk6Xz9owKvwHSqiNQqsUrhDd57imqrYhcPbzgSer5NVtzBPOQy25LSOwg X4Ux9Dzmu1JrMsbFy3cbRWf+ZBdIl7r/b4wwSRB5cixa5EgByZUMrf3+Tstf4hwbabCM PvGEUCjdqNzGb+yfnH3OrUUq0jH0YILjKAG29xSmvRzEpy67eNLPLnXb7/1YCe1eHyyQ 2D1KVe2K2yZkaFaXjZ4quORHqRH/hIeHBbY0iOZf0HjZzTw4K3/DSA3LOFw4Xso048iG kDLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737567359; x=1738172159; 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=+3umZXjLzM+bJmhv36LYBTXy+5dxDZTh3TYkhb2jhwE=; b=ttDRAHdGJazFrei2SgKB8s281czH7pIJH9JpuSJ2k5r6U0m538xRuG4dEq2lWVOtM8 nAnPKqrH/mVPKdzCBYnALKHtJM5F61jOxsC+A+TBgzG+6jTM1UH8+ykUEf49kWxCozqz Vu95SiqOOAXOfwcb8cjljcE1RQiYzPomDxb7Tb/SNoYxeAaHvPt6lfmKJXTS4xmkBryn A9rMDe1hC7nQJz+u7EP+JC5Cja/+EVhjpmP+5jnHv/DnKIpERzCDmqSSUPJdgmsxsmDM vakuvV4IqH8Mr3aIdYwIsqbEXuF7FToyCUzphdKWXjVgIiJkvJvNZ7Bhz86QfZoJzOPS 9asg== X-Gm-Message-State: AOJu0Yyc4vdIF4fjSyh8gpx10d9W2PltYYsaCA2jr7yq9++oTydJZXU4 ynrIpKuU1SSCeoGdH3OTcVGyM5x0KjhG4AVFjrhz0kWaFAHPP353OVQMPbqzbgYOt7AYfxkUFAo d X-Gm-Gg: ASbGncv+skPHAI5dMyltmpewocrQ9ATlNuW3SgO6FBe2YpOk/jLOI9sa6BdsOlIFCd6 hv4ugahE9RFSb9pcd9MqdccOdWHph4V0V+dmArQCV4HqYKiDLSqtQHbTlH2aO3z7qELZwuwbU5C tTvHD/qYREnViYi0CtbTdudUodn1WVA7P6dA5t3iV1FH7tBkeZiTDr3sGVw4doD1xo6Qy0WAJ56 zAV8Czvuyd7YJp+UqUY9iGPHQnc1jpzXH7K8nN2+QPY1lEZ4SOF+KJC0w31RT6m4UkGYaE4iXji JADy7B5VYDKT2KmexTAAKSDzuglbl0+dF3BGsoMu3cKtBKs= X-Google-Smtp-Source: AGHT+IFxPkRHJ0tj5RTbttujIb5EEFFsgCBU/5QD+BMNXKrbqb9yH0molDRBn6XQ7Hs/IAkgavkxzw== X-Received: by 2002:a17:902:d48a:b0:216:3083:d03d with SMTP id d9443c01a7336-21c355f23e7mr387046305ad.44.1737567359085; Wed, 22 Jan 2025 09:35:59 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3bc64dsm97469285ad.122.2025.01.22.09.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 09:35:58 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v2 11/15] ring: add allocation function attributes Date: Wed, 22 Jan 2025 09:32:55 -0800 Message-ID: <20250122173521.305108-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250122173521.305108-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250122173521.305108-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 --- lib/ring/rte_ring.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h index 63a71d5871..15340a1981 100644 --- a/lib/ring/rte_ring.h +++ b/lib/ring/rte_ring.h @@ -119,6 +119,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 +193,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