net/mlx5: fix flow workspace destruction
PATCH 1/1 net/mlx5: fix flow workspace destruction
From: Gregory Etelson <[email protected]>
PMD uses pthread key to allocate and access per thread flow workspace memory buffers.
PMD registered a key destructor function to clean up flow workspace buffers. However, the key destructor was not called by the pthread library.
The patch keeps track of per-thread flow workspaces in PMD. Flow workspaces memory release is activated from PMD destructor.
In the meanwhile, workspace buffer and RSS queues array are allocated in a single memory chunk with this patch. The maximal number of queues RTE_ETH_RSS_RETA_SIZE_512 is chosen. Then the workspace adjustment can be removed to reduce the software hiccup:
1. realloc and content copy
2. spinlock aquire and release
--- drivers/net/mlx5/linux/mlx5_flow_os.c | 2 +- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5_flow.c | 76 +++++++++++---------------- drivers/net/mlx5/mlx5_flow.h | 4 +- 4 files changed, 36 insertions(+), 47 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.c +1 -1
@@ -51,7 +51,7 @@ mlx5_flow_os_validate_item_esp(const struct rte_flow_item *item,int mlx5_flow_os_init_workspace_once (void ) { -if (rte_thread_key_create (&key_workspace, flow_release_workspace)) { +if (rte_thread_key_create (&key_workspace,NULL )) {DRV_LOG (ERR ,"Can't create flow workspace data thread key." ); rte_errno =ENOMEM ;return -rte_errno;
drivers/net/mlx5/mlx5.c +1 -0
@@ -1838,6 +1838,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)if (LIST_EMPTY (&mlx5_dev_ctx_list)) {mlx5_os_net_cleanup ();mlx5_flow_os_release_workspace (); +mlx5_flow_workspace_gc_release (); }pthread_mutex_unlock (&mlx5_dev_ctx_list_mutex);if (sh->flex_parsers_dv) {
drivers/net/mlx5/mlx5_flow.c +31 -45
116 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -1496,10 +1496,10 @@ struct mlx5_flow_workspace {/* If creating another flow in same thread, push new as stack. */ struct mlx5_flow_workspace *prev;struct mlx5_flow_workspace *next; +struct mlx5_flow_workspace *gc;uint32_t inuse;/* can't create new flow with current. */ struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS ];struct mlx5_flow_rss_desc rss_desc; -uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ struct mlx5_flow_meter_info *fm;/* Pointer to the meter in flow. */ struct mlx5_flow_meter_policy *policy;
@@ -2022,6 +2022,8 @@ struct mlx5_flow_driver_ops {struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace (void );void mlx5_flow_pop_thread_workspace (void );struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace (void ); +void mlx5_flow_workspace_gc_release (void ); + __extension__ struct flow_grp_info { uint64_t external:1;
Signature · 1 line
2.34.1
PATCH v2 1/1 net/mlx5: fix flow workspace destruction
From: Gregory Etelson <[email protected]>
PMD uses pthread key to allocate and access per thread flow workspace memory buffers.
PMD registered a key destructor function to clean up flow workspace buffers. However, the key destructor was not called by the pthread library.
The patch keeps track of per-thread flow workspaces in PMD. Flow workspaces memory release is activated from PMD destructor.
In the meanwhile, workspace buffer and RSS queues array are allocated in a single memory chunk with this patch. The maximal number of queues RTE_ETH_RSS_RETA_SIZE_512 is chosen. Then the workspace adjustment can be removed to reduce the software hiccup:
1. realloc and content copy
2. spinlock acquire and release
---
v2: fix typo in the commit message and remove the needless NULL
pointer initialization for static variable.
--- drivers/net/mlx5/linux/mlx5_flow_os.c | 2 +- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5_flow.c | 76 +++++++++++---------------- drivers/net/mlx5/mlx5_flow.h | 4 +- 4 files changed, 36 insertions(+), 47 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.c +1 -1
@@ -51,7 +51,7 @@ mlx5_flow_os_validate_item_esp(const struct rte_flow_item *item,int mlx5_flow_os_init_workspace_once (void ) { -if (rte_thread_key_create (&key_workspace, flow_release_workspace)) { +if (rte_thread_key_create (&key_workspace,NULL )) {DRV_LOG (ERR ,"Can't create flow workspace data thread key." ); rte_errno =ENOMEM ;return -rte_errno;
drivers/net/mlx5/mlx5.c +1 -0
@@ -1838,6 +1838,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)if (LIST_EMPTY (&mlx5_dev_ctx_list)) {mlx5_os_net_cleanup ();mlx5_flow_os_release_workspace (); +mlx5_flow_workspace_gc_release (); }pthread_mutex_unlock (&mlx5_dev_ctx_list_mutex);if (sh->flex_parsers_dv) {
drivers/net/mlx5/mlx5_flow.c +31 -45
116 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -1496,10 +1496,10 @@ struct mlx5_flow_workspace {/* If creating another flow in same thread, push new as stack. */ struct mlx5_flow_workspace *prev;struct mlx5_flow_workspace *next; +struct mlx5_flow_workspace *gc;uint32_t inuse;/* can't create new flow with current. */ struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS ];struct mlx5_flow_rss_desc rss_desc; -uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ struct mlx5_flow_meter_info *fm;/* Pointer to the meter in flow. */ struct mlx5_flow_meter_policy *policy;
@@ -2022,6 +2022,8 @@ struct mlx5_flow_driver_ops {struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace (void );void mlx5_flow_pop_thread_workspace (void );struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace (void ); +void mlx5_flow_workspace_gc_release (void ); + __extension__ struct flow_grp_info { uint64_t external:1;
Signature · 1 line
2.34.1
From: Bing Zhao <[email protected]>
Quoted 16 lines
PMD uses pthread key to allocate and access per thread flow workspace memory buffers.
PMD registered a key destructor function to clean up flow workspace buffers. However, the key destructor was not called by the pthread library.
The patch keeps track of per-thread flow workspaces in PMD. Flow workspaces memory release is activated from PMD destructor.
In the meanwhile, workspace buffer and RSS queues array are allocated in a single memory chunk with this patch. The maximal number of queues
RTE_ETH_RSS_RETA_SIZE_512is chosen. Then the workspace adjustment can be removed to reduce the software hiccup:
1. realloc and content copy
2. spinlock acquire and release
Quoted 5 lines
Fixes 5d55a494f4e6 ("net/mlx5: split multi-thread flow handling per OS")Signed-off-by Gregory Etelson <[email protected]>Signed-off-by Bing Zhao <[email protected]>
PATCH v3 1/1 net/mlx5: fix flow workspace destruction
In reply to Bing ZhaoFrom: Gregory Etelson <[email protected]>
PMD uses pthread key to allocate and access per thread flow workspace memory buffers.
PMD registered a key destructor function to clean up flow workspace buffers. However, the key destructor was not called by the pthread library.
The patch keeps track of per-thread flow workspaces in PMD. Flow workspaces memory release is activated from PMD destructor.
In the meanwhile, workspace buffer and RSS queues array are allocated in a single memory chunk with this patch. The maximal number of queues RTE_ETH_RSS_RETA_SIZE_512 is chosen. Then the workspace adjustment can be removed to reduce the software hiccup:
1. realloc and content copy
2. spinlock acquire and release
Bugzilla ID: 1255
---
v2: fix typo and code style
v3: add bugzilla information
--- drivers/net/mlx5/linux/mlx5_flow_os.c | 2 +- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5_flow.c | 76 +++++++++++---------------- drivers/net/mlx5/mlx5_flow.h | 4 +- 4 files changed, 36 insertions(+), 47 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.c +1 -1
@@ -51,7 +51,7 @@ mlx5_flow_os_validate_item_esp(const struct rte_flow_item *item,int mlx5_flow_os_init_workspace_once (void ) { -if (rte_thread_key_create (&key_workspace, flow_release_workspace)) { +if (rte_thread_key_create (&key_workspace,NULL )) {DRV_LOG (ERR ,"Can't create flow workspace data thread key." ); rte_errno =ENOMEM ;return -rte_errno;
drivers/net/mlx5/mlx5.c +1 -0
@@ -1838,6 +1838,7 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)if (LIST_EMPTY (&mlx5_dev_ctx_list)) {mlx5_os_net_cleanup ();mlx5_flow_os_release_workspace (); +mlx5_flow_workspace_gc_release (); }pthread_mutex_unlock (&mlx5_dev_ctx_list_mutex);if (sh->flex_parsers_dv) {
drivers/net/mlx5/mlx5_flow.c +31 -45
116 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -1496,10 +1496,10 @@ struct mlx5_flow_workspace {/* If creating another flow in same thread, push new as stack. */ struct mlx5_flow_workspace *prev;struct mlx5_flow_workspace *next; +struct mlx5_flow_workspace *gc;uint32_t inuse;/* can't create new flow with current. */ struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS ];struct mlx5_flow_rss_desc rss_desc; -uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ struct mlx5_flow_meter_info *fm;/* Pointer to the meter in flow. */ struct mlx5_flow_meter_policy *policy;
@@ -2022,6 +2022,8 @@ struct mlx5_flow_driver_ops {struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace (void );void mlx5_flow_pop_thread_workspace (void );struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace (void ); +void mlx5_flow_workspace_gc_release (void ); + __extension__ struct flow_grp_info { uint64_t external:1;
Signature · 1 line
2.34.1
Hi,
Quoted 33 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Monday, July 3, 2023 12:51 PM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Raslan Darawsheh <[email protected]>
Cc: [email protected]; Gregory Etelson <[email protected]>; [email protected]; David Marchand <[email protected]>
Subject: [PATCH v3] net/mlx5: fix flow workspace destructionFrom: Gregory Etelson <[email protected]>
PMD uses pthread key to allocate and access per thread flow workspace memory buffers.
PMD registered a key destructor function to clean up flow workspace buffers. However, the key destructor was not called by the pthread library.
The patch keeps track of per-thread flow workspaces in PMD. Flow workspaces memory release is activated from PMD destructor.
In the meanwhile, workspace buffer and RSS queues array are allocated in a single memory chunk with this patch. The maximal number of queues
RTE_ETH_RSS_RETA_SIZE_512is chosen. Then the workspace adjustment can be removed to reduce the software hiccup:
1. realloc and content copy
2. spinlock acquire and releaseBugzilla ID: 1255
Fixes 5d55a494f4e6 ("net/mlx5: split multi-thread flow handling per OS")
Quoted 7 lines
Reported-by David Marchand <[email protected]>Signed-off-by Gregory Etelson <[email protected]>Signed-off-by Bing Zhao <[email protected]>Acked-by Matan Azrad <[email protected]>---
v2: fix typo and code style
v3: add bugzilla information
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh