DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] testpmd: unregister event callback
@ 2023-09-15  4:26 okaya
  2023-09-26 15:50 ` Singh, Aman Deep
  0 siblings, 1 reply; 3+ messages in thread
From: okaya @ 2023-09-15  4:26 UTC (permalink / raw)
  To: Aman Singh, Yuying Zhang; +Cc: dev, Sinan Kaya

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(+)

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,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] testpmd: unregister event callback
  2023-09-15  4:26 [PATCH] testpmd: unregister event callback okaya
@ 2023-09-26 15:50 ` Singh, Aman Deep
  2023-09-27 17:52   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Singh, Aman Deep @ 2023-09-26 15:50 UTC (permalink / raw)
  To: okaya, Yuying Zhang; +Cc: dev


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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] testpmd: unregister event callback
  2023-09-26 15:50 ` Singh, Aman Deep
@ 2023-09-27 17:52   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2023-09-27 17:52 UTC (permalink / raw)
  To: Singh, Aman Deep, okaya, Yuying Zhang; +Cc: dev

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-27 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15  4:26 [PATCH] testpmd: unregister event callback okaya
2023-09-26 15:50 ` Singh, Aman Deep
2023-09-27 17:52   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).