From patchwork Fri Sep 15 04:26:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 131454 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A964A4259F; Fri, 15 Sep 2023 06:26:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38F844029E; Fri, 15 Sep 2023 06:26:42 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id B010E40041 for ; Fri, 15 Sep 2023 06:26:40 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 660C7B82933; Fri, 15 Sep 2023 04:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA652C433C7; Fri, 15 Sep 2023 04:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694751999; bh=JRh+YpEzYQLaUi7B0Bq8vOjrktbDFfy0T+wXzeliI3Y=; h=From:To:Cc:Subject:Date:From; b=Z+etBRbR0ydAigBbwaspeCydPwP3A53BzEqTHp/IAdhyo0RTAqaH5qxGyGxMRz6LE kMMpOKBkep917lcP+2EsH08xjnJLOy0ofO5brOQS0nHvO4IPCC3d/r1E61Sr+UNo7F E8Ow/k61g2AW+uSWqlNk5g+YRpNiNuzcARgxuo3/ul5jUEtW99VvmlkX8LV5WYoNjK DLyENrVrGd+ri/CyHkOM++mwwD3syBIgtKkGUfTbzFYmTFzCZcj3LTK76ZI3TdjL+m tW4HvU271gr91LhPoPluu+ATttKGmAv8/BGotxB5LcCORh2BgjWqg7VYTTuNobV4LH rWUCmnej/Zm5A== From: okaya@kernel.org To: Aman Singh , Yuying Zhang Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH] testpmd: unregister event callback Date: Fri, 15 Sep 2023 00:26:33 -0400 Message-Id: <20230915042633.151750-1-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 From: Sinan Kaya Cleanup event registry during shutdown to prevent memory leaks. Signed-off-by: Sinan Kaya Acked-by: Aman Singh --- app/test-pmd/testpmd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index c6ad9b18bf..1de7b7cd51 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -4009,6 +4009,28 @@ register_eth_event_callback(void) return 0; } +static int +unregister_eth_event_callback(void) +{ + int ret; + enum rte_eth_event_type event; + + for (event = RTE_ETH_EVENT_UNKNOWN; + event < RTE_ETH_EVENT_MAX; event++) { + ret = rte_eth_dev_callback_unregister(RTE_ETH_ALL, + event, + eth_event_callback, + NULL); + if (ret != 0) { + TESTPMD_LOG(ERR, "Failed to unregister callback for " + "%s event\n", eth_event_desc[event]); + return -1; + } + } + + return 0; +} + /* This function is used by the interrupt thread */ static void dev_event_callback(const char *device_name, enum rte_dev_event_type type, @@ -4737,6 +4759,11 @@ main(int argc, char** argv) rte_latencystats_uninit(); #endif + ret = unregister_eth_event_callback(); + if (ret != 0) + rte_exit(EXIT_FAILURE, "Cannot unregister for ethdev events"); + + ret = rte_eal_cleanup(); if (ret != 0) rte_exit(EXIT_FAILURE,