Skip to contentSkip to conversation

vdpa/mlx5: improve interrupt management

PATCH Superseded Matan Azrad 4 participants 9 messages Mar 18, 2021 – May 4, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 1f2ae6f..9b2f9f1 100644
@@ -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
index 4c2d886..5d70880 100644
@@ -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
index 98c71aa..e4c8575 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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_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.

Quoted 9 lines
---
 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

#2 lore raw
In reply to Matan Azrad
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 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(-)
Quoted 2 lines

--
1.8.3.1

Patch applied to next-virtio/main with conflict resolved.

Thanks!

#3 lore raw

07/04/2021 08:49, Xia, Chenbo:

Quoted 6 lines
Quoted 2 lines

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 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>
#4 lore raw

Hi Matan,

Quoted 16 lines · Thomas Monjalon

07/04/2021 08:49, Xia, Chenbo:

Quoted 6 lines
Quoted 2 lines

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 function pthread_attr_setaffinity_np() must be replaced with pthread_setaffinity_np() if moved after the call to pthread_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

#5 lore raw

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

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 function pthread_attr_setaffinity_np() must be replaced with
pthread_setaffinity_np() if moved after the call to pthread_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>
Quoted 4 lines

Could you please send a new version taking care of Thomas' request.

Thanks,
Maxime

Done.

#6 lore raw

PATCH v2 1/1 vdpa/mlx5: improve interrupt management

In reply to Matan Azrad

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 | 304 +++++++++++-----------------
 4 files changed, 130 insertions(+), 198 deletions(-)

v2:
Rebased on top of latest updates by Thomas.

doc/guides/vdpadevs/mlx5.rst +4 -4
index 1f2ae6fb92..9b2f9f12c7 100644
@@ -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
index 898e50f807..619e31d61c 100644
@@ -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
index d93b430c97..722c72b65e 100644
@@ -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
Reviewed-by on v2 1/1
#7 lore raw
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_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(-)
Quoted 4 lines

v2:
Rebased on top of latest updates by Thomas.

Thanks,
Maxime

#8 lore raw
In reply to Matan Azrad
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_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(-)
Quoted 3 lines

v2:
Rebased on top of latest updates by Thomas.

Applied to dpdk-next-virtio/main.

Thanks,
Maxime