app/testpmd: fix releasing action handle flush memory
PATCH 1/1 app/testpmd: fix releasing action handle flush memory
The memory of the indirect action handles should be freed after being destroyed in the flush. The behavior needs to be consistent with the single handle destroy.
Or else, there will be some unexpected error when the action handle is destroyed for the 2nd time, for example, the port needs to be closed again.
--- app/test-pmd/config.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
app/test-pmd/config.c +3 -6
@@ -1918,8 +1918,7 @@ port_action_handle_flush(portid_t port_id)/* Poisoning to make sure PMDs update it in case of error. */ memset (&error,0x44 ,sizeof (error));if (pia->handle !=NULL ) { - ret = pia->type == -RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ? + ret = pia->type ==RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?rte_flow_action_list_handle_destroy (port_id, pia->list_handle, &error) : rte_flow_action_handle_destroy
@@ -1929,11 +1928,9 @@ port_action_handle_flush(portid_t port_id) pia->id); ret =port_flow_complain (&error); } - tmp = &pia->next; - }else { - *tmp = pia->next; -free (pia); } + *tmp = pia->next; +free (pia); }return ret; }
Signature · 1 line
2.34.1
Quoted 8 lines · Bing Zhao
The memory of the indirect action handles should be freed after being destroyed in the flush. The behavior needs to be consistent with the single handle destroy.
Or else, there will be some unexpected error when the action handle is destroyed for the 2nd time, for example, the port needs to be closed again.
Ports can be closed only once, so above reasoning is not valid, but I assume the purpose of this patch is to prevent memory leak, can you please clarify the problem and impact of the patch in commit log?
Also what is "single handle destroy" mentioned above?
The fixed commit is from a few release ago, so this is not something introduced in this release, do you think can this wait next release instead of merging for -rc4 which is more risky?
Quoted 38 lines
Fixes f7352c176bbf ("app/testpmd: fix use of indirect action after port close")Signed-off-by Bing Zhao <[email protected]>Reviewed-by Dariusz Sosnowski <[email protected]>--- app/test-pmd/config.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)app/test-pmd/config.c +3
-6@@ -1918,8 +1918,7 @@ port_action_handle_flush(portid_t port_id)/* Poisoning to make sure PMDs update it in case of error. */ memset (&error,0x44 ,sizeof (error));if (pia->handle !=NULL ) { - ret = pia->type == -RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ? + ret = pia->type ==RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?rte_flow_action_list_handle_destroy (port_id, pia->list_handle, &error) : rte_flow_action_handle_destroy@@ -1929,11 +1928,9 @@ port_action_handle_flush(portid_t port_id) pia->id); ret =port_flow_complain (&error); } - tmp = &pia->next; - }else { - *tmp = pia->next; -free (pia); } + *tmp = pia->next; +free (pia); }return ret; }
Hi Ferruh,
Quoted 18 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, March 19, 2024 10:21 PM
To: Bing Zhao <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Matan Azrad <[email protected]>; [email protected]; Dariusz Sosnowski <[email protected]>
Subject: Re: [PATCH] app/testpmd: fix releasing action handle flush memoryExternal email: Use caution opening links or attachments
Quoted 4 lines · Bing Zhao
The memory of the indirect action handles should be freed after being destroyed in the flush. The behavior needs to be consistent with the single handle destroy.
Quoted 8 lines
Quoted 4 lines
Or else, there will be some unexpected error when the action handle is destroyed for the 2nd time, for example, the port needs to be closed again.
Ports can be closed only once, so above reasoning is not valid, but I assume the purpose of this patch is to prevent memory leak, can you please clarify the problem and impact of the patch in commit log?
To close the port twice is something I am testing internally of "errno EBUSY", I didn't describe it clearly. At the same time, YES, there is some memory leak should be fixed.
Quoted 3 lines
Also what is "single handle destroy" mentioned above?
I mean the function call port_action_handle_destroy().
Quoted 4 lines
The fixed commit is from a few release ago, so this is not something introduced in this release, do you think can this wait next release instead of merging for -rc4 which is more risky?
Yes, it is not something that blocking the release. The memory should be recycled by the system once the application quits completely.
I will polish the commit message and send v2.
Quoted 33 lines
Quoted 33 lines
Fixes f7352c176bbf ("app/testpmd: fix use of indirect action afterport close")
Cc: [email protected]
Cc: [email protected]Signed-off-by Bing Zhao <[email protected]>Reviewed-by Dariusz Sosnowski <[email protected]>--- app/test-pmd/config.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)app/test-pmd/config.c index renamed from app/test-pmd/config.c +0
-0
ba1007ace6..f62ba90c87100644app/test-pmd/config.c +2
-4@@ -1918,8 +1918,7 @@ port_action_handle_flush(portid_t port_id)/* Poisoning to make sure PMDs update it in case of error. */ memset (&error,0x44 ,sizeof (error));if (pia->handle !=NULL ) { - ret = pia->type == -RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ? + ret = pia->type ==RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?rte_flow_action_list_handle_destroy (port_id, pia->list_handle, &error) : rte_flow_action_handle_destroy @@ -1929,11 +1928,9 @@ port_action_handle_flush(portid_t port_id) pia->id); ret =port_flow_complain (&error); } - tmp = &pia->next; - }else {
Quoted 8 lines
app/test-pmd/config.c port_action_handle_flush(portid_t port_id) · line 1936
Quoted 8 lines
app/test-pmd/config.c +2
-2- *tmp = pia->next; -free (pia); } + *tmp = pia->next; +free (pia); }return ret; }
Thanks
BR. Bing
PATCH v2 1/1 app/testpmd: fix releasing action handle flush memory
In reply to Bing ZhaoThe memory of the indirect action handles should be freed after being destroyed in the flush. The behavior needs to be consistent with the single handle destroy port_action_handle_destroy().
Or else, there would be some memory leak when closing / detaching a port without quitting the application. In the meanwhile, since the action handles are already destroyed, it makes no sense to hold the indirect action software resources anymore.
---
v2: update the description
--- app/test-pmd/config.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
app/test-pmd/config.c +3 -6
@@ -1918,8 +1918,7 @@ port_action_handle_flush(portid_t port_id)/* Poisoning to make sure PMDs update it in case of error. */ memset (&error,0x44 ,sizeof (error));if (pia->handle !=NULL ) { - ret = pia->type == -RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ? + ret = pia->type ==RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?rte_flow_action_list_handle_destroy (port_id, pia->list_handle, &error) : rte_flow_action_handle_destroy
@@ -1929,11 +1928,9 @@ port_action_handle_flush(portid_t port_id) pia->id); ret =port_flow_complain (&error); } - tmp = &pia->next; - }else { - *tmp = pia->next; -free (pia); } + *tmp = pia->next; +free (pia); }return ret; }
Signature · 1 line
2.34.1
Quoted 9 lines · Bing Zhao
The memory of the indirect action handles should be freed after being destroyed in the flush. The behavior needs to be consistent with the single handle destroy
port_action_handle_destroy().Or else, there would be some memory leak when closing / detaching a port without quitting the application. In the meanwhile, since the action handles are already destroyed, it makes no sense to hold the indirect action software resources anymore.
Quoted 7 lines
Fixes f7352c176bbf ("app/testpmd: fix use of indirect action after port close")Signed-off-by Bing Zhao <[email protected]>Reviewed-by Dariusz Sosnowski <[email protected]>
Applied to dpdk-next-net/main, thanks.