testpmd: unregister event callback

Message ID 20230915042633.151750-1-okaya@kernel.org (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series testpmd: unregister event callback |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Sinan Kaya Sept. 15, 2023, 4:26 a.m. UTC
  From: Sinan Kaya <okaya@kernel.org>

Cleanup event registry during shutdown to prevent memory
leaks.

Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
 app/test-pmd/testpmd.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
  

Comments

Singh, Aman Deep Sept. 26, 2023, 3:50 p.m. UTC | #1
On 9/15/2023 9:56 AM, okaya@kernel.org wrote:
> From: Sinan Kaya <okaya@kernel.org>

Header format doesn't requires to add "From: "
as author "Signed-off" is already present.

>
> Cleanup event registry during shutdown to prevent memory
> leaks.
>
> Signed-off-by: Sinan Kaya <okaya@kernel.org>

Acked-by: Aman Singh <aman.deep.singh@intel.com>

> ---
>   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,
  
Ferruh Yigit Sept. 27, 2023, 5:52 p.m. UTC | #2
On 9/26/2023 4:50 PM, Singh, Aman Deep wrote:
> 
> On 9/15/2023 9:56 AM, okaya@kernel.org wrote:
>> From: Sinan Kaya <okaya@kernel.org>
> 
> Header format doesn't requires to add "From: "
> as author "Signed-off" is already present.
> 
>>
>> Cleanup event registry during shutdown to prevent memory
>> leaks.
>>
>> Signed-off-by: Sinan Kaya <okaya@kernel.org>
> 
> Acked-by: Aman Singh <aman.deep.singh@intel.com>
> 

Applied to dpdk-next-net/main, thanks.


(patch title and .mailmap updated while merging)
  

Patch

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,