Skip to contentSkip to conversation

net/virtio: fix AVX512 datapath selection

PATCH In review Maxime Coquelin 3 participants 12 messages May 11, 2020 – May 12, 2020

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

PATCH 1/1 net/virtio: fix AVX512 datapath selection

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
---
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.c +4 -2
index 312871cb48..49ccef12c7 100644
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support packed ring vectorized");
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif
 		}
 	}
Signature · 1 line
2.25.4
#1 lore raw
Quoted 22 lines · Maxime Coquelin

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
---
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 312871cb48..49ccef12c7 100644
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support packed ring vectorized");

drivers/net/virtio/virtio_ethdev.c eth_virtio_dev_init(struct rte_eth_dev *eth_dev) · line 1974

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +4 -2
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif
 		}
 	}

Bruce & Radu also highlighted that the in meson, instead of updating 'cflags', which is for all driver, the cflags for 'virtio_rxtx_packed_avx.c' should be updated.

#2 lore raw

PATCH v2 1/1 net/virtio: fix AVX512 datapath selection

In reply to Maxime Coquelin

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not able to test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/virtio/meson.build +7 -2
index 5cc529f6aa..3fd6051f4b 100644
@@ -11,8 +11,14 @@ deps += ['kvargs', 'bus_pci']
 if arch_subdir == 'x86'
 	if not machine_args.contains('-mno-avx512f')
 		if cc.has_argument('-mavx512f') and cc.has_argument('-mavx512vl') and cc.has_argument('-mavx512bw')
-			cflags += ['-mavx512f', '-mavx512bw', '-mavx512vl']
 			cflags += ['-DCC_AVX512_SUPPORT']
+			virtio_avx512_lib = static_library('virtio_avx512_lib',
+					      'virtio_rxtx_packed_avx.c',
+					      dependencies: [static_rte_ethdev,
+						static_rte_kvargs, static_rte_bus_pci],
+					      include_directories: includes,
+					      c_args: [cflags, '-mavx512f', '-mavx512bw', '-mavx512vl'])
+			objs += virtio_avx512_lib.extract_objects('virtio_rxtx_packed_avx.c')
 			if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
 				cflags += '-DVHOST_GCC_UNROLL_PRAGMA'
 			elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
@@ -20,7 +26,6 @@ if arch_subdir == 'x86'
 			elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0'))
 				cflags += '-DVHOST_ICC_UNROLL_PRAGMA'
 			endif
-			sources += files('virtio_rxtx_packed_avx.c')
 		endif
 	endif
 	sources += files('virtio_rxtx_simple_sse.c')
drivers/net/virtio/virtio_ethdev.c +4 -2
index 312871cb48..49ccef12c7 100644
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support packed ring vectorized");
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif
 		}
 	}
Signature · 1 line
2.25.4
author Acked-by on v2 1/1
#3 lore raw
Quoted 21 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

Quoted 6 lines

For meson I mainly adapted implementation from other driver, not able to test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

Thanks Ferruh, I cannot test either right now but it looks good to me:

In case you're waiting for it:

Maxime

Applied
#4 lore raw
Quoted 31 lines · Maxime Coquelin
Quoted 21 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

Quoted 6 lines

For meson I mainly adapted implementation from other driver, not able to test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
Quoted 5 lines

Thanks Ferruh, I cannot test either right now but it looks good to me:

In case you're waiting for it:

Applied to dpdk-next-net/master, thanks.

#5 lore raw
In reply to Maxime Coquelin
Quoted 39 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 3:50 AM
To: Yigit, Ferruh <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>; Liu, Yong <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 14 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
Quoted 8 lines

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not able

Quoted 9 lines

to

Quoted 5 lines

test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

Thanks Ferruh, I cannot test either right now but it looks good to me:

Hi Maxime & Ferruh,
IMHO, meson build update is the essential part for fixing unexpected AVX512 instructions.
Change in virtio_ethdev may cause building issues on ppc and arm platform. Is it convenient to revert that change?

Regards,
Marvin

Quoted 4 lines

In case you're waiting for it:

Maxime

#6 lore raw
Quoted 46 lines · Yong
Quoted 46 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 3:50 AM
To: Yigit, Ferruh <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>; Liu, Yong <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 14 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
Quoted 8 lines

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not able

to

Quoted 5 lines

test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
Quoted 6 lines
Quoted 2 lines

Thanks Ferruh, I cannot test either right now but it looks good to me:

Hi Maxime & Ferruh,
IMHO, meson build update is the essential part for fixing unexpected AVX512 instructions.
Change in virtio_ethdev may cause building issues on ppc and arm platform. Is it convenient to revert that change?

As replied to v1:

With a bit more of context, we can see that it only affects packed ring when CC_AVX512_SUPPORT is set. So it does break neither split ring nor ARM/PPC:

	if (vectorized) {
		if (!vtpci_packed_queue(hw)) {
			hw->use_vec_rx = 1;
		} else {
#if !defined(CC_AVX512_SUPPORT)
			PMD_DRV_LOG(INFO,
				"building environment do not support packed ring vectorized");
#else
			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
				hw->use_vec_rx = 1;
				hw->use_vec_tx = 1;
			}
#endif
		}
	}

So IMO, no revert has to be done.

Quoted 8 lines

Regards,
Marvin

Quoted 4 lines

In case you're waiting for it:

Maxime

#7 lore raw
Quoted 96 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 4:36 PM
To: Liu, Yong <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 31 lines · Yong
Quoted 31 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 3:50 AM
To: Yigit, Ferruh <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>; Liu, Yong <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 14 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not

able

Quoted 7 lines
Quoted 7 lines

to

Quoted 5 lines

test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 2 lines

Thanks Ferruh, I cannot test either right now but it looks good to me:

Hi Maxime & Ferruh,
IMHO, meson build update is the essential part for fixing unexpected

AVX512 instructions.

Quoted 1 line

Change in virtio_ethdev may cause building issues on ppc and arm

platform. Is it convenient to revert that change?

As replied to v1:

With a bit more of context, we can see that it only affects packed ring when CC_AVX512_SUPPORT is set. So it does break neither split ring nor ARM/PPC:

	if (vectorized) {
		if (!vtpci_packed_queue(hw)) {
			hw->use_vec_rx = 1;
		} else {

#if !defined(CC_AVX512_SUPPORT)
PMD_DRV_LOG(INFO,
"building environment do not support
packed ring vectorized");
#else
if

(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
				hw->use_vec_rx = 1;
				hw->use_vec_tx = 1;
			}
#endif
		}
	}
Quoted 2 lines

So IMO, no revert has to be done.

Ok, I messed it with my previous building fix. It will be no harm for this double check.

Quoted 8 lines
Quoted 8 lines

Regards,
Marvin

Quoted 4 lines

In case you're waiting for it:

Maxime

#8 lore raw
Quoted 96 lines · Yong
Quoted 96 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 4:36 PM
To: Liu, Yong <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 31 lines · Yong
Quoted 31 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 3:50 AM
To: Yigit, Ferruh <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>; Liu, Yong <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 14 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not for all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not

able

Quoted 7 lines
Quoted 7 lines

to

Quoted 5 lines

test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 2 lines

Thanks Ferruh, I cannot test either right now but it looks good to me:

Hi Maxime & Ferruh,
IMHO, meson build update is the essential part for fixing unexpected

AVX512 instructions.

Quoted 1 line

Change in virtio_ethdev may cause building issues on ppc and arm

platform. Is it convenient to revert that change?

As replied to v1:

With a bit more of context, we can see that it only affects packed ring when CC_AVX512_SUPPORT is set. So it does break neither split ring nor ARM/PPC:

	if (vectorized) {
		if (!vtpci_packed_queue(hw)) {
			hw->use_vec_rx = 1;
		} else {

#if !defined(CC_AVX512_SUPPORT)
PMD_DRV_LOG(INFO,
"building environment do not support
packed ring vectorized");
#else
if

(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
				hw->use_vec_rx = 1;
				hw->use_vec_tx = 1;
			}
#endif
		}
	}
Quoted 4 lines
Quoted 2 lines

So IMO, no revert has to be done.

Ok, I messed it with my previous building fix. It will be no harm for this double check.

While it does not break, I agree for the unnecessary double-check. You can send a clean-up patch to remove this part in -rc3.

Thanks,
Maxime

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

Regards,
Marvin

Quoted 4 lines

In case you're waiting for it:

Maxime

#9 lore raw
Quoted 115 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 6:04 PM
To: Liu, Yong <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 15 lines · Yong
Quoted 15 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 4:36 PM
To: Liu, Yong <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu <[email protected]>; Luca Boccassi <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 8 lines
Quoted 8 lines · Yong
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, May 12, 2020 3:50 AM
To: Yigit, Ferruh <[email protected]>; Wang, Zhihong <[email protected]>; Ye, Xiaolong <[email protected]>;

Liu,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Yong <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Richardson, Bruce <[email protected]>; Nicolau, Radu

<[email protected]>;

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Luca Boccassi <[email protected]>
Subject: Re: [PATCH v2] net/virtio: fix AVX512 datapath selection

Quoted 2 lines · Ferruh Yigit

From: Maxime Coquelin <[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Also in meson build enable vectorization only for relevant file, not

for

Quoted 53 lines
Quoted 53 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

all driver.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---
Cc: Bruce Richardson <[email protected]>
Cc: Radu Nicolau <[email protected]>
Cc: Luca Boccassi <[email protected]>

For meson I mainly adapted implementation from other driver, not

able

Quoted 7 lines
Quoted 7 lines

to

Quoted 5 lines

test or verify myself.

---
 drivers/net/virtio/meson.build     | 9 +++++++--
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 2 lines

Thanks Ferruh, I cannot test either right now but it looks good to me:

Hi Maxime & Ferruh,
IMHO, meson build update is the essential part for fixing unexpected

AVX512 instructions.

Quoted 1 line

Change in virtio_ethdev may cause building issues on ppc and arm

platform. Is it convenient to revert that change?

As replied to v1:

With a bit more of context, we can see that it only affects packed ring when CC_AVX512_SUPPORT is set. So it does break neither split ring nor ARM/PPC:

	if (vectorized) {
		if (!vtpci_packed_queue(hw)) {
			hw->use_vec_rx = 1;
		} else {

#if !defined(CC_AVX512_SUPPORT)
PMD_DRV_LOG(INFO,
"building environment do not support
packed ring vectorized");
#else
if

(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
				hw->use_vec_rx = 1;
				hw->use_vec_tx = 1;
			}
#endif
		}
	}
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

So IMO, no revert has to be done.

Ok, I messed it with my previous building fix. It will be no harm for this

double check.

While it does not break, I agree for the unnecessary double-check. You can send a clean-up patch to remove this part in -rc3.

Thanks a lot, have sent clean-up patch.

Quoted 12 lines

Thanks,
Maxime

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

Regards,
Marvin

Quoted 4 lines

In case you're waiting for it:

Maxime

#10 lore raw
In reply to Maxime Coquelin
Quoted 32 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Monday, May 11, 2020 10:47 PM
To: Liu, Yong <[email protected]>; Ye, Xiaolong <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH] net/virtio: fix AVX512 datapath selection

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
---
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 312871cb48..49ccef12c7 100644
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support

drivers/net/virtio/virtio_ethdev.c eth_virtio_dev_init(struct rte_eth_dev *eth_dev) · line 1974

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +4 -2
 packed ring vectorized");
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if
 (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif

Hi Maxime,
Here is pre-setting for vectorized path selection, virtio_dev_configure will do second time check.
Running environment will be checked in second time check. We can move some checks from virtio_dev_configure to here, but is it needed to do that?

BTW, both split ring and packed ring will utilized this setting, it will break split vectorized datapath is server not has AVX512F flag. And it may cause building issue on those platforms which not defined RTE_CPUFLAG_AVX512F.

Thanks,
Marvin

Quoted 4 lines
drivers/net/virtio/virtio_ethdev.c +0 -1
 		}
 	}
--

2.25.4

#11 lore raw
Quoted 47 lines · Yong
Quoted 32 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Monday, May 11, 2020 10:47 PM
To: Liu, Yong <[email protected]>; Ye, Xiaolong <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH] net/virtio: fix AVX512 datapath selection

The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it.

This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported.

Fixes ccb10995c2ad ("net/virtio: add election for vectorized path")
---
 drivers/net/virtio/virtio_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.c +0 -0
index 312871cb48..49ccef12c7 100644
@@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			PMD_DRV_LOG(INFO,
 				"building environment do not support

drivers/net/virtio/virtio_ethdev.c eth_virtio_dev_init(struct rte_eth_dev *eth_dev) · line 1974

Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +4 -2
 packed ring vectorized");
 #else
-			hw->use_vec_rx = 1;
-			hw->use_vec_tx = 1;
+			if
 (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+				hw->use_vec_rx = 1;
+				hw->use_vec_tx = 1;
+			}
 #endif

Hi Maxime,
Here is pre-setting for vectorized path selection, virtio_dev_configure will do second time check.
Running environment will be checked in second time check. We can move some checks from virtio_dev_configure to here, but is it needed to do that?

Quoted 2 lines

BTW, both split ring and packed ring will utilized this setting, it will break split vectorized datapath is server not has AVX512F flag. And it may cause building issue on those platforms which not defined RTE_CPUFLAG_AVX512F.

With a bit more of context, we can see that it only affects packed ring when CC_AVX512_SUPPORT is set. So it does break neither split ring nor ARM/PPC:

	if (vectorized) {
		if (!vtpci_packed_queue(hw)) {
			hw->use_vec_rx = 1;
		} else {
#if !defined(CC_AVX512_SUPPORT)
			PMD_DRV_LOG(INFO,
				"building environment do not support packed ring vectorized");
#else
			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
				hw->use_vec_rx = 1;
				hw->use_vec_tx = 1;
			}
#endif
		}
	}
Quoted 8 lines

Thanks,
Marvin

Quoted 4 lines
drivers/net/virtio/virtio_ethdev.c +0 -1
 		}
 	}
--

2.25.4