Skip to contentSkip to conversation

compress/isal: fix getting information about CPU

PATCH Applied Tomasz Cel 3 participants 5 messages Mar 7, 2019 – Mar 29, 2019

lore
Share & tools
lore

Tomasz Cel

author
#0 lore raw

PATCH 1/1 compress/isal: fix getting information about CPU

This patch adds query about CPU features

Fixes 53a9baa98c36 ("compress/isal: add basic PMD ops")
---
 drivers/compress/isal/isal_compress_pmd_ops.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/compress/isal/isal_compress_pmd_ops.c +12 -4
index 7b91849..fe99959 100644
@@ -135,10 +135,18 @@ isal_comp_pmd_info_get(struct rte_compressdev *dev __rte_unused,
 {
 	if (dev_info != NULL) {
 		dev_info->capabilities = isal_pmd_capabilities;
-		dev_info->feature_flags = RTE_COMPDEV_FF_CPU_AVX512 |
-				RTE_COMPDEV_FF_CPU_AVX2 |
-				RTE_COMPDEV_FF_CPU_AVX |
-				RTE_COMPDEV_FF_CPU_SSE;
+
+		/* Check CPU for supported vector instruction and set
+		 * feature_flags
+		 */
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX512;
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX2;
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX;
+		else
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_SSE;
 	}
 }
 
Signature · 1 line
2.7.4
#1 lore raw

Hi Fiona/Lee,

Could you please review this patch.

Thanks,
Akhil

Quoted 37 lines · Tomasz Cel

This patch adds query about CPU features

Fixes 53a9baa98c36 ("compress/isal: add basic PMD ops")
---
  drivers/compress/isal/isal_compress_pmd_ops.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)
drivers/compress/isal/isal_compress_pmd_ops.c +12 -4
index 7b91849..fe99959 100644
@@ -135,10 +135,18 @@ isal_comp_pmd_info_get(struct rte_compressdev *dev __rte_unused,
  {
  	if (dev_info != NULL) {
  		dev_info->capabilities = isal_pmd_capabilities;
-		dev_info->feature_flags = RTE_COMPDEV_FF_CPU_AVX512 |
-				RTE_COMPDEV_FF_CPU_AVX2 |
-				RTE_COMPDEV_FF_CPU_AVX |
-				RTE_COMPDEV_FF_CPU_SSE;
+
+		/* Check CPU for supported vector instruction and set
+		 * feature_flags
+		 */
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX512;
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX2;
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_AVX;
+		else
+			dev_info->feature_flags |= RTE_COMPDEV_FF_CPU_SSE;
  	}
  }
 
#2 lore raw

Hi Tomasz,

This patch makes sense to check does the CPU have the capability of certain instructions before
Adding it to the dev_info flags. I think one more addition should be made in isal_compress_pmd.c
When checking what compression level should be used , decided by the AVX instructions available, it previously used the Rte_cpu_get_flag_enabled() function, however, I don’t believe that is needed any more since it will now be checked beforehand, it would be doing twice the work. When the driver now needs to decide the compression level it should now just check the feature_flags set below. Perhaps a V2 could be sent with this addition. Regards,
Lee.

Quoted 43 lines

Review

Quoted 11 lines

This patch adds query about CPU features

Fixes 53a9baa98c36 ("compress/isal: add basic PMD ops")
---
  drivers/compress/isal/isal_compress_pmd_ops.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/compress/isal/isal_compress_pmd_ops.c

drivers/compress/isal/isal_compress_pmd_ops.c isal_comp_pmd_info_get(struct

Quoted 4 lines

index 7b91849..fe99959 100644

drivers/compress/isal/isal_compress_pmd_ops.c +0 -0
@@ -135,10 +135,18 @@ isal_comp_pmd_info_get(struct

rte_compressdev *dev __rte_unused,

drivers/compress/isal/isal_compress_pmd_ops.c isal_comp_pmd_info_get(struct rte_compressdev *dev __rte_unused,

Quoted 13 lines
drivers/compress/isal/isal_compress_pmd_ops.c +6 -4
  {
  	if (dev_info != NULL) {
  		dev_info->capabilities = isal_pmd_capabilities;
-		dev_info->feature_flags = RTE_COMPDEV_FF_CPU_AVX512 |
-				RTE_COMPDEV_FF_CPU_AVX2 |
-				RTE_COMPDEV_FF_CPU_AVX |
-				RTE_COMPDEV_FF_CPU_SSE;
+
+		/* Check CPU for supported vector instruction and set
+		 * feature_flags
+		 */
+		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+			dev_info->feature_flags |=

RTE_COMPDEV_FF_CPU_AVX512;

drivers/compress/isal/isal_compress_pmd_ops.c isal_comp_pmd_info_get(struct · line 145

Quoted 2 lines
drivers/compress/isal/isal_compress_pmd_ops.c +2 -0
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+			dev_info->feature_flags |=

RTE_COMPDEV_FF_CPU_AVX2;

drivers/compress/isal/isal_compress_pmd_ops.c isal_comp_pmd_info_get(struct · line 147

Quoted 2 lines
drivers/compress/isal/isal_compress_pmd_ops.c +2 -0
+		else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
+			dev_info->feature_flags |=

RTE_COMPDEV_FF_CPU_AVX;

drivers/compress/isal/isal_compress_pmd_ops.c isal_comp_pmd_info_get(struct · line 149

Quoted 2 lines
drivers/compress/isal/isal_compress_pmd_ops.c +2 -0
+		else
+			dev_info->feature_flags |=

RTE_COMPDEV_FF_CPU_SSE;

Quoted 3 lines
drivers/compress/isal/isal_compress_pmd_ops.c +0 -0
  	}
  }
 
Acked-by
#3 lore raw

Hi Tomasz,
After some testing I can now see the approach in your patch in the best method for getting the CPU info.
Rgds,
Lee.

Quoted 11 lines

-----Original Message-----
From: Daly, Lee
Sent: Wednesday, March 27, 2019 3:01 PM
To: Akhil Goyal <[email protected]>; Cel, TomaszX <[email protected]>; [email protected]
Cc: [email protected]; Trahe, Fiona <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] compress/isal: fix getting information about CPU

Hi Tomasz,

Quoted 21 lines

This patch makes sense to check does the CPU have the capability of
certain instructions before Adding it to the dev_info flags. I think one more addition should be made in isal_compress_pmd.c When checking what compression level should be used , decided by the AVX instructions available, it previously used the
Rte_cpu_get_flag_enabled() function, however, I don’t believe that is needed any more since it will now be checked beforehand, it would be doing twice the work.
When the driver now needs to decide the compression level it should now just check the feature_flags set below. Perhaps a V2 could be sent with this addition.
Regards,
Lee.

Quoted 7 lines
Quoted 7 lines

This patch adds query about CPU features

Fixes 53a9baa98c36 ("compress/isal: add basic PMD ops")

---

Applied
#4 lore raw
Quoted 29 lines · Lee

Hi Tomasz,
After some testing I can now see the approach in your patch in the best method for getting the CPU info.
Rgds,
Lee.

Quoted 25 lines

-----Original Message-----
From: Daly, Lee
Sent: Wednesday, March 27, 2019 3:01 PM
To: Akhil Goyal <[email protected]>; Cel, TomaszX <[email protected]>; [email protected]
Cc: [email protected]; Trahe, Fiona <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] compress/isal: fix getting information about CPU

Hi Tomasz,

This patch makes sense to check does the CPU have the capability of
certain instructions before Adding it to the dev_info flags. I think one more addition should be made in isal_compress_pmd.c When checking what compression level should be used , decided by the AVX instructions available, it previously used the
Rte_cpu_get_flag_enabled() function, however, I don’t believe that is needed any more since it will now be checked beforehand, it would be doing twice the work.
When the driver now needs to decide the compression level it should now just check the feature_flags set below. Perhaps a V2 could be sent with this addition.
Regards,
Lee.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

This patch adds query about CPU features

Fixes 53a9baa98c36 ("compress/isal: add basic PMD ops")

---

Applied to dpdk-next-crypto

Thanks.