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 973D34601A; Mon, 20 Jan 2025 19:07:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07FDE427B8; Mon, 20 Jan 2025 19:06:14 +0100 (CET) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id 13FCC4279F for ; Mon, 20 Jan 2025 19:06:09 +0100 (CET) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2163b0c09afso85819415ad.0 for ; Mon, 20 Jan 2025 10:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737396368; x=1738001168; 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=U+cSnHjmTixYmr1jkEsjDNxTKGA7/KQtE8VavMDR9VB8zevfUvgQjPN3c8f2IGAzxr zu5r024YO1i5giu2J/2oKTmuRmFZNz5lvliu3SzJUBrAFxVL1n5M3bdk8K6F9Kes2eZ6 BpXyjfVcorjvt+ouevg/MWIoQcjlKLmIG3noUs0+Xm/HcsulHgsTnkLXOhDFKUHmCikE oPH1A8ynrLoKdB9Ls6E4h/9BGMIAXDdJa4nFPT3hAJE4XpQTSC9uKhANpeQwTCL5I51Z I/+GUflWqRYGrOqfOK7e9ydhhhlDoS2jwolU2FEASbQ6T2wc0ebOpbFyneDKckuaYgDN bcxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737396368; x=1738001168; 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=W5WepfRFxOR+jkwhWYdiWqD96iMfgqUhd3CuBO0hI0whgzx21Dq3RE/uDxSuOEgFHm Cj1Cebj8Vu63OQCATtD9KaUSgrhjhs/4/irsEqS3/7At2JDdYs0uX5oWzZaCsjgdRhSQ vUqEwWntHFjGhoQED5wsj3IJmHJjktnMWA75Zx+A+82DUw1aNKz93TIsYCAwfeYCq8qy gV93cQJImVAzVmAN3TA4474N6enn42ojwuvg+cY7R4D5NMbL6kS8NdnJJU43mex5cRmR 2CGnoeQfkkpktfgmgzOx6gqaXZB/ViPS+GmGD4idtzXzMmNsdreL/3G8FEIWtIrVxBT1 iT/w== X-Gm-Message-State: AOJu0YwMYFchbRX8wwlWlqodxrbItGk+DYonpxsAcCGr3C5vIJaF4WYK OHd1g5NWmA3EIHC9McMXue2w7ys8zXJDmwQDcjkApODm/jMYN7HVai03wTwECuudbJ9m/PvBbCZ n X-Gm-Gg: ASbGncsTXtZztrF7YtEF9ZNUvFcWvLuqOBH1sboWYheJHEd2dGu1ttj+Fw3kB3Y4CN+ 3yWmL6i0dEig9Gc29WbM7kzRlJlvxe0hf0CodmUqXBDipmpYo48KM/aVm73nQbQS8nqyWIERf/z sgLK09L5Aao64XSUMmpY1AOeVW7ENNGJz0N3KeNtYGrkCOaLFJ/+ooXkqrjh0BiakpqF6552Den LN44AV75Gx001T7jBL/3cud0sJBN5I0siWQJZYjkzJJPSwDjZHfS0DSs5k2lPjKkDu4O3wm9P2l E1dhZb+P+M3Jyamq5aUbIcgMOsWCsQC4oIcbsJM6At4BhV4= X-Google-Smtp-Source: AGHT+IE+P2EtpEchUx8atMhEnCzEvy4KN5aISM3nWReDDdPkXBejZY9estgM2ag9IP9IfM0Czb4JAw== X-Received: by 2002:aa7:8884:0:b0:72a:bc6a:3a88 with SMTP id d2e1a72fcca58-72dafaaf2f2mr19338604b3a.22.1737396368227; Mon, 20 Jan 2025 10:06:08 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dab848b08sm7393982b3a.71.2025.01.20.10.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:06:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH 11/15] ring: add allocation function attributes Date: Mon, 20 Jan 2025 10:03:29 -0800 Message-ID: <20250120180550.198121-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250120180550.198121-1-stephen@networkplumber.org> References: <20250120180550.198121-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