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 481D046114; Sat, 25 Jan 2025 19:41:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DC094067D; Sat, 25 Jan 2025 19:40:42 +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 DC59340658 for ; Sat, 25 Jan 2025 19:40:31 +0100 (CET) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2166360285dso54290555ad.1 for ; Sat, 25 Jan 2025 10:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830431; x=1738435231; 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=e0NpprbaoGaJ5SwG/Mm1HFq1e1h+7Jb172O5KLQoKGI=; b=RTIzjCqWggtzxX3+jAlD6rW1YAV8fKXe740OMtBm545ykkJ0vyQZwqsmt95CW0zbDp TAaOeN+fF7cbUz/lVnJ5SetYRmpFOLoGZahv8VeRDry8/i/OilZPHVgHihV3+eYdYNNp jgjAgSmVRmmwYCVOdJR+G/K5vsKbCs7ZouEwGHrWLXcMPTP1PpTvwu5pZaxSq25ZSwHY CebwAz/R7RXaJTUHs7KdF0yvzXcEw7poxKaynyMPWyyv/i7lp5bq/dTdKwDG4kOyuWa1 81qnrG/z5U5log5NmCosWKQWajdPUNQ2GWg7yTs2g9WdpOjYeUgROhAaeHEJVC9FSXe3 +9pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737830431; x=1738435231; 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=e0NpprbaoGaJ5SwG/Mm1HFq1e1h+7Jb172O5KLQoKGI=; b=tALtIZDeOUA8R7i12N8ck6qz2CXh8dUrzmvVqsk1VsbhViam23iEjGq/Ka2Wzt7z2b mrW1SxWk2Pb3bRkesXPRl9gfXmzZCUWi2quYxUDchnwSWwwatimhEpdsjfBUc+vDLR/L T7mBUXmr1vqKKLipjs1KZ+7+bwzZn+WgyLePNi9GlAfmXNcjAgYqlrgnF4PD7VOUTF1W o6dJf0t7+HggtWfzqPIf1RbnzE+s7xdqRlsy6buKvsQ29m8igC+IvJeowcUDUFAYjT0e S/V/8FzNcY3RodFU3IlXT3I5Y69z3MjngRxkkuSYVi3qJR3CsSMQ3ncgCQLcZivMp7tg H+uw== X-Gm-Message-State: AOJu0YxisxKoWMrYmclhsBGkG80uLcF1QFvHvOS5pptzjaVA2n53BTg3 7PfBEmAgOjTEzW9WowCbf7IJlj1d4hAQ6b57SVyHU4YrHGU+18Z1klrjraq/KPEHrNqtMP8FFeT T X-Gm-Gg: ASbGncskIHHFOaCtKM6U1rpunCXCa7F8YHH2YOu2D26QGBYvDJbzfjNSyvkrWCooxKJ nR+QQQo/5S+lUFJXyFtJLvs9lDsWLj/SvVQURbgE4AutVLYPtyPJO5wdvlJ6RJbGKT5HSX3QUsd 2KFRGufUmn6c0K2kdn0Kdl3oK9w5OaPQ73eDgJexAAv2JKh0Pp/ifQYtlm/0W/ffdp3KjAV7Gr9 iEaUdq93+CZqnZwYL0SsDWAUeVbYh16CBvK4ZVqPHORNuRNlw3fmB2Ly/nuQxcOOA8Q9KA1JqCH utW1kZ08pnV+Hu+uwA3KGGO2BIaaBe0v4kXjjlomsUvPajL2dLLb2wPODw== X-Google-Smtp-Source: AGHT+IGt9ADU0i8yaBLsXRYW1cBBvanCQF8tVCKyk8RCO1K3h1B4gSUvTZN59JsTA8R4K8zxMzSvKQ== X-Received: by 2002:a05:6a20:7f93:b0:1ea:eca7:10ee with SMTP id adf61e73a8af0-1eb21465192mr48976018637.6.1737830431070; Sat, 25 Jan 2025 10:40:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 10:40:30 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 12/15] compressdev: add allocation function attributes Date: Sat, 25 Jan 2025 10:36:46 -0800 Message-ID: <20250125184010.782330-13-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use function attributes to catch cases where compressdev is allocated but not freed correctly. Signed-off-by: Stephen Hemminger --- lib/compressdev/rte_comp.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h index d66a4b1cb9..827e3d25ed 100644 --- a/lib/compressdev/rte_comp.h +++ b/lib/compressdev/rte_comp.h @@ -11,6 +11,7 @@ * RTE definitions for Data Compression Service */ +#include #include #ifdef __cplusplus @@ -480,6 +481,19 @@ struct __rte_cache_aligned rte_comp_op { */ }; + +/** + * Free operation structure + * If operation has been allocate from a rte_mempool, then the operation will + * be returned to the mempool. + * + * @param op + * Compress operation pointer allocated from rte_comp_op_alloc() + * If op is NULL, no operation is performed. + */ +void +rte_comp_op_free(struct rte_comp_op *op); + /** * Creates an operation pool * @@ -501,7 +515,8 @@ struct __rte_cache_aligned rte_comp_op { struct rte_mempool * rte_comp_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache_size, - uint16_t user_size, int socket_id); + uint16_t user_size, int socket_id) + __rte_malloc __rte_dealloc(rte_comp_op_free, 1); /** * Allocate an operation from a mempool with default parameters set @@ -533,18 +548,6 @@ int rte_comp_op_bulk_alloc(struct rte_mempool *mempool, struct rte_comp_op **ops, uint16_t nb_ops); -/** - * Free operation structure - * If operation has been allocate from a rte_mempool, then the operation will - * be returned to the mempool. - * - * @param op - * Compress operation pointer allocated from rte_comp_op_alloc() - * If op is NULL, no operation is performed. - */ -void -rte_comp_op_free(struct rte_comp_op *op); - /** * Bulk free operation structures * If operations have been allocated from an rte_mempool, then the operations -- 2.45.2