vdpa/mlx5: improve interrupt management
Subsystems (2)
PATCH 1/1 vdpa/mlx5: improve interrupt management
The driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by event_mode device argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.
Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 308 +++++++++++++++--------------------- 4 files changed, 134 insertions(+), 198 deletions(-)
doc/guides/vdpadevs/mlx5.rst +4 -4
@@ -129,10 +129,10 @@ Driver options - ``no_traffic_time`` parameter [int] - A nonzero value defines the traffic off time, in seconds, that moves the - driver to no-traffic mode. In this mode the timer events are stopped and - interrupts are configured to the device in order to notify traffic for the - driver. Default value is 2s. + A nonzero value defines the traffic off time, in polling cycle time units, + that moves the driver to no-traffic mode. In this mode the polling is stopped + and interrupts are configured to the device in order to notify traffic for the + driver. Default value is 16. - ``event_core`` parameter [int]
drivers/vdpa/mlx5/mlx5_vdpa.c +4 -4
@@ -44,7 +44,7 @@#define MLX5_VDPA_MAX_RETRIES 20#define MLX5_VDPA_USEC 1000 -#define MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S 2LLU +#define MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX 16LLU TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =TAILQ_HEAD_INITIALIZER (priv_list);
@@ -632,7 +632,7 @@ }else if (strcmp (key,"event_us" ) ==0 ) { priv->event_us = (uint32_t )tmp; }else if (strcmp (key,"no_traffic_time" ) ==0 ) { - priv->no_traffic_time_s = (uint32_t )tmp; + priv->no_traffic_max = (uint32_t )tmp; }else if (strcmp (key,"event_core" ) ==0 ) {if (tmp >= (unsigned long )n_cores)DRV_LOG (WARNING ,"Invalid event_core %s." , val);
@@ -658,7 +658,7 @@ priv->event_mode =MLX5_VDPA_EVENT_MODE_FIXED_TIMER ; priv->event_us =0 ; priv->event_core =-1 ; - priv->no_traffic_time_s =MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S ; + priv->no_traffic_max =MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX ;if (devargs ==NULL )return ; kvlist =rte_kvargs_parse (devargs->args,NULL );
@@ -671,7 +671,7 @@ priv->event_us =MLX5_VDPA_DEFAULT_TIMER_STEP_US ;DRV_LOG (DEBUG ,"event mode is %d." , priv->event_mode);DRV_LOG (DEBUG ,"event_us is %u us." , priv->event_us); -DRV_LOG (DEBUG ,"no traffic time is %u s." , priv->no_traffic_time_s); +DRV_LOG (DEBUG ,"no traffic max is %u." , priv->no_traffic_max); }/**
drivers/vdpa/mlx5/mlx5_vdpa.h +2 -6
@@ -120,16 +120,13 @@ struct mlx5_vdpa_priv {TAILQ_ENTRY (mlx5_vdpa_priv) next;uint8_t configured;pthread_mutex_t vq_config_lock; -uint64_t last_traffic_tic; +uint64_t no_traffic_counter;pthread_t timer_tid; -pthread_mutex_t timer_lock; -pthread_cond_t timer_cond; -volatile uint8_t timer_on;int event_mode;int event_core;/* Event thread cpu affinity core. */ uint32_t event_us;uint32_t timer_delay_us; -uint32_t no_traffic_time_s; +uint32_t no_traffic_max;uint8_t hw_latency_mode;/* Hardware CQ moderation mode. */ uint16_t hw_max_latency_us;/* Hardware CQ moderation period in usec. */ uint16_t hw_max_pending_comp;/* Hardware CQ moderation counter. */
@@ -146,7 +143,6 @@ struct mlx5_vdpa_priv {struct mlx5dv_devx_event_channel *eventc;struct mlx5dv_devx_event_channel *err_chnl;struct mlx5dv_devx_uar *uar; -struct rte_intr_handle intr_handle;struct rte_intr_handle err_intr_handle;struct mlx5_devx_obj *td;struct mlx5_devx_obj *tiss[16 ];/* TIS list for each LAG port. */
drivers/vdpa/mlx5/mlx5_vdpa_event.c +124 -184
363 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 17 lines · Matan Azrad
The driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by
event_modedevice argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
Quoted 9 lines
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 308 +++++++++++++++--------------------- 4 files changed, 134 insertions(+), 198 deletions(-)
Thanks,
Maxime
Quoted 34 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Matan Azrad
Sent: Thursday, March 18, 2021 5:13 PM
To: [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [dpdk-dev] [PATCH] vdpa/mlx5: improve interrupt managementThe driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by
event_modedevice argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 308 +++++++++++++++-------------------- - 4 files changed, 134 insertions(+), 198 deletions(-)
Quoted 2 lines
--
1.8.3.1
Patch applied to next-virtio/main with conflict resolved.
Thanks!
07/04/2021 08:49, Xia, Chenbo:
Quoted 6 lines
Quoted 2 lines
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>Patch applied to next-virtio/main with conflict resolved.
Thanks!
Sorry it cannot be pulled in the main tree because it breaks compilation with musl libc.
It can be fixed in the same way as in41b5a7a8494e ("vdpa/mlx5: replace pthread functions unavailable in musl") The function pthread_attr_setaffinity_np() must be replaced with pthread_setaffinity_np() if moved after the call to pthread_create().
We could add a checkpatch check for forbidden functions like
pthread_yield, pthread_attr_setaffinity_np
and forbidden includes:
<error.h>, <sys/fcntl.h>
Hi Matan,
Quoted 16 lines · Thomas Monjalon
07/04/2021 08:49, Xia, Chenbo:
Quoted 6 lines
Quoted 2 lines
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>Patch applied to next-virtio/main with conflict resolved.
Thanks!
Sorry it cannot be pulled in the main tree because it breaks compilation with musl libc.
It can be fixed in the same way as in
41b5a7a8494e("vdpa/mlx5: replace pthread functions unavailable in musl") The functionpthread_attr_setaffinity_np()must be replaced withpthread_setaffinity_np()if moved after the call topthread_create().
Quoted 6 lines
We could add a checkpatch check for forbidden functions like
pthread_yield,pthread_attr_setaffinity_np
and forbidden includes:<error.h>, <sys/fcntl.h>
Could you please send a new version taking care of Thomas' request.
Thanks,
Maxime
From: Maxime Coquelin
Quoted 27 lines
Hi Matan,
Quoted 17 lines · Thomas Monjalon
07/04/2021 08:49, Xia, Chenbo:
Quoted 6 lines
Quoted 2 lines
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>Patch applied to next-virtio/main with conflict resolved.
Thanks!
Sorry it cannot be pulled in the main tree because it breaks compilation with musl libc.
It can be fixed in the same way as in
41b5a7a8494e("vdpa/mlx5: replace pthread functions unavailable in musl") The functionpthread_attr_setaffinity_np()must be replaced withpthread_setaffinity_np()if moved after the call topthread_create().Quoted 6 lines
We could add a checkpatch check for forbidden functions like
pthread_yield,pthread_attr_setaffinity_npand forbidden
includes:<error.h>, <sys/fcntl.h>
Quoted 4 lines
Could you please send a new version taking care of Thomas' request.
Thanks,
Maxime
Done.
PATCH v2 1/1 vdpa/mlx5: improve interrupt management
In reply to Matan AzradThe driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by event_mode device argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.
Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 304 +++++++++++----------------- 4 files changed, 130 insertions(+), 198 deletions(-)
v2:
Rebased on top of latest updates by Thomas.
doc/guides/vdpadevs/mlx5.rst +4 -4
@@ -129,10 +129,10 @@ Driver options - ``no_traffic_time`` parameter [int] - A nonzero value defines the traffic off time, in seconds, that moves the - driver to no-traffic mode. In this mode the timer events are stopped and - interrupts are configured to the device in order to notify traffic for the - driver. Default value is 2s. + A nonzero value defines the traffic off time, in polling cycle time units, + that moves the driver to no-traffic mode. In this mode the polling is stopped + and interrupts are configured to the device in order to notify traffic for the + driver. Default value is 16. - ``event_core`` parameter [int]
drivers/vdpa/mlx5/mlx5_vdpa.c +4 -4
@@ -44,7 +44,7 @@#define MLX5_VDPA_MAX_RETRIES 20#define MLX5_VDPA_USEC 1000 -#define MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S 2LLU +#define MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX 16LLU TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =TAILQ_HEAD_INITIALIZER (priv_list);
@@ -632,7 +632,7 @@ mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque) }else if (strcmp (key,"event_us" ) ==0 ) { priv->event_us = (uint32_t )tmp; }else if (strcmp (key,"no_traffic_time" ) ==0 ) { - priv->no_traffic_time_s = (uint32_t )tmp; + priv->no_traffic_max = (uint32_t )tmp; }else if (strcmp (key,"event_core" ) ==0 ) {if (tmp >= (unsigned long )n_cores)DRV_LOG (WARNING ,"Invalid event_core %s." , val);
@@ -658,7 +658,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) priv->event_mode =MLX5_VDPA_EVENT_MODE_FIXED_TIMER ; priv->event_us =0 ; priv->event_core =-1 ; - priv->no_traffic_time_s =MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S ; + priv->no_traffic_max =MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX ;if (devargs ==NULL )return ; kvlist =rte_kvargs_parse (devargs->args,NULL );
@@ -671,7 +671,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) priv->event_us =MLX5_VDPA_DEFAULT_TIMER_STEP_US ;DRV_LOG (DEBUG ,"event mode is %d." , priv->event_mode);DRV_LOG (DEBUG ,"event_us is %u us." , priv->event_us); -DRV_LOG (DEBUG ,"no traffic time is %u s." , priv->no_traffic_time_s); +DRV_LOG (DEBUG ,"no traffic max is %u." , priv->no_traffic_max); }/**
drivers/vdpa/mlx5/mlx5_vdpa.h +2 -6
@@ -120,16 +120,13 @@ struct mlx5_vdpa_priv {TAILQ_ENTRY (mlx5_vdpa_priv) next;uint8_t configured;pthread_mutex_t vq_config_lock; -uint64_t last_traffic_tic; +uint64_t no_traffic_counter;pthread_t timer_tid; -pthread_mutex_t timer_lock; -pthread_cond_t timer_cond; -volatile uint8_t timer_on;int event_mode;int event_core;/* Event thread cpu affinity core. */ uint32_t event_us;uint32_t timer_delay_us; -uint32_t no_traffic_time_s; +uint32_t no_traffic_max;uint8_t hw_latency_mode;/* Hardware CQ moderation mode. */ uint16_t hw_max_latency_us;/* Hardware CQ moderation period in usec. */ uint16_t hw_max_pending_comp;/* Hardware CQ moderation counter. */
@@ -146,7 +143,6 @@ struct mlx5_vdpa_priv {struct mlx5dv_devx_event_channel *eventc;struct mlx5dv_devx_event_channel *err_chnl;struct mlx5dv_devx_uar *uar; -struct rte_intr_handle intr_handle;struct rte_intr_handle err_intr_handle;struct mlx5_devx_obj *td;struct mlx5_devx_obj *tiss[16 ];/* TIS list for each LAG port. */
drivers/vdpa/mlx5/mlx5_vdpa_event.c +120 -184
359 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 26 lines · Matan Azrad
The driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by
event_modedevice argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 304 +++++++++++----------------- 4 files changed, 130 insertions(+), 198 deletions(-)
Quoted 4 lines
v2:
Rebased on top of latest updates by Thomas.
Thanks,
Maxime
Maxime Coquelin
AppliedQuoted 26 lines · Matan Azrad
The driver should notify the guest for each traffic burst detected by CQ polling.
The CQ polling trigger is defined by
event_modedevice argument, either by busy polling on all the CQs or by blocked call to HW completion event using DevX channel.Also, the polling event modes can move to blocked call when the traffic rate is low.
The current blocked call uses the EAL interrupt API suffering a lot of overhead in the API management and serve all the drivers and libraries using only single thread.
Use blocking FD of the DevX channel in order to do blocked call directly by the DevX channel FD mechanism.
Signed-off-by Matan Azrad <[email protected]>Acked-by Xueming Li <[email protected]>--- doc/guides/vdpadevs/mlx5.rst | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 8 +- drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +- drivers/vdpa/mlx5/mlx5_vdpa_event.c | 304 +++++++++++----------------- 4 files changed, 130 insertions(+), 198 deletions(-)
Quoted 3 lines
v2:
Rebased on top of latest updates by Thomas.
Applied to dpdk-next-virtio/main.
Thanks,
Maxime