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 7DAD0460FF; Thu, 23 Jan 2025 17:31:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C650740E1F; Thu, 23 Jan 2025 17:30:36 +0100 (CET) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id C108740DD3 for ; Thu, 23 Jan 2025 17:30:27 +0100 (CET) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21a7ed0155cso19732105ad.3 for ; Thu, 23 Jan 2025 08:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737649827; x=1738254627; 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=eQMs11k1/XKqEqTvedObzI87EpNDEakqOXTMBSbf9ft328gkrQoGvJzFcAJ/okm6t1 FdmcslZJpxQDJFov6KFL59z1VR4f4c0n8LEyAaws3eNdKsfkCxBiGJ8/M01dijzgJ8j8 e9tetGtdae+kBGpPcewfgX9NynSUxJTTycI1HsJdrBWS2GglgZT0acbQgiULefGaJxn7 ezJmS6wAL72NyGfFuvAkHNVVzdCjDxSfZwk3XlqqwnIRQXeSFmiG2UQ8sH2F//9fwGaj OlGXVRmt3GIp/8aSEnoyo5+FWUFGdo761SYPsJ6vNrINUHd0QA1LZd6tt4h2v86iadkJ cCbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737649827; x=1738254627; 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=p9XciMXTWr7GJPESOM2nJrrSJ8FSQblF6jP4RunokgJsdg4lrIgcGFSXC4B1qUPDkm Amrn/WDBUpkjyKTped9GFFuWqI3VXEDM6N+bSGblwI4vOdVQzHZYwPpscFT3uwN883Jz fW9NZuXz9kQpZU1CL3myCCE+tOBs+5tEHB6Nl/NKhENueEif6JiVcHIfyYmzlGJqnKqt 18MljxshL7JgKLl8+RzUWhmJyNIui8kGvUoAoWBOLJaFRbfnE8qKbYVgMXHZdWSfYRTI XlLfSKl2uZdNy644+hvSTuBrYNYpIkHUZo4yW9iXMspXbWdF0Czs2URwoLEv9spsLgKC fMZA== X-Gm-Message-State: AOJu0YwO8uEyhj2rlGmYM8gA9l/SeHkRRV+2/m6h58SxWJLl9JhJnKI5 +FAuFw5TleQAjt2qwYlHlVmHjf1TQXHHCrBNCzbMEvzzKxyXeXEwsmFociCbEZqaUxgEto3pYpA t X-Gm-Gg: ASbGncunONjxj4xs4F8nf3cJZE+hHlrtpDrutaEwccxqHPgHH53lruKB7r45t+CJUtr qUNiCFYPV0b7PJuqUkmwIjfjZHUblx9tMKLTJKCJ3vMB0p3OErINik53thxYqIhWZAsBGWM+La1 3Mw9QV2BTsshsLk7TkI2xhhDfffol5mJxtHVocpC5yE0maqv1wjHv23jaYcrztoA1sOJzl+wT9e Bw169LSCvKYPb3dWnoJ+11af/Y3lgXg5CQYYizUvQ/AWt8xAiiUDiICOq11G7ksoiEAYN73q3RG lU8wHy9CvsVq0fu5ntr1ScZ6aLzAB5OQ3D1UwG1pkz4MdjwTW2VTACFQhA== X-Google-Smtp-Source: AGHT+IHjlsHXSZBmA2h2Tt8piyR2pcwPXhgRVB/GSwJTXs6VRKaYqHnuGiCjYvVheTc/vdZ5x5mfvw== X-Received: by 2002:a17:902:f644:b0:211:8404:a957 with SMTP id d9443c01a7336-21c355f6aa9mr460233165ad.41.1737649826984; Thu, 23 Jan 2025 08:30: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-ac4907f076dsm64601a12.37.2025.01.23.08.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 08:30:26 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [PATCH v3 11/15] ring: add allocation function attributes Date: Thu, 23 Jan 2025 08:28:11 -0800 Message-ID: <20250123163003.23394-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250123163003.23394-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250123163003.23394-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