patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor
       [not found] ` <20210923081122.176735-1-xuemingl@nvidia.com>
@ 2021-09-23  8:11   ` Xueming Li
  2021-09-23  9:53     ` Kevin Traynor
  2021-09-23  8:11   ` [dpdk-stable] [PATCH v2 2/2] vdpa/mlx5: fix large VM memory region registration Xueming Li
  1 sibling, 1 reply; 3+ messages in thread
From: Xueming Li @ 2021-09-23  8:11 UTC (permalink / raw)
  To: Matan Azrad, dev
  Cc: xuemingl, Kevin Traynor, stable, Cristian Dumitrescu, Jasvinder Singh

This patch adds new function that compute the greatest common
divisor of 64 bits, also changes the original 32 bits function to call
this new 64 bits version.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Cc: stable@dpdk.org
---
 lib/sched/rte_sched_common.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/sched/rte_sched_common.h b/lib/sched/rte_sched_common.h
index 96706df7bd..340a0df312 100644
--- a/lib/sched/rte_sched_common.h
+++ b/lib/sched/rte_sched_common.h
@@ -51,10 +51,10 @@ rte_min_pos_4_u16(uint16_t *x)
  *    gcd(a, b) = gcd(b, a mod b)
  *
  */
-static inline uint32_t
-rte_get_gcd(uint32_t a, uint32_t b)
+static inline uint64_t
+rte_get_gcd64(uint64_t a, uint64_t b)
 {
-	uint32_t c;
+	uint64_t c;
 
 	if (a == 0)
 		return b;
@@ -76,6 +76,15 @@ rte_get_gcd(uint32_t a, uint32_t b)
 	return a;
 }
 
+/*
+ * 32bit version of Compute the Greatest Common Divisor (GCD).
+ */
+static inline uint32_t
+rte_get_gcd(uint32_t a, uint32_t b)
+{
+	return rte_get_gcd64(a, b);
+}
+
 /*
  * Compute the Lowest Common Denominator (LCD) of two numbers.
  * This implementation computes GCD first:
-- 
2.33.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH v2 2/2] vdpa/mlx5: fix large VM memory region registration
       [not found] ` <20210923081122.176735-1-xuemingl@nvidia.com>
  2021-09-23  8:11   ` [dpdk-stable] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor Xueming Li
@ 2021-09-23  8:11   ` Xueming Li
  1 sibling, 0 replies; 3+ messages in thread
From: Xueming Li @ 2021-09-23  8:11 UTC (permalink / raw)
  To: Matan Azrad, dev
  Cc: xuemingl, Kevin Traynor, matan, stable, Viacheslav Ovsiienko,
	Maxime Coquelin

When VM size larger than 4G(u32) and memory region larger than 4G, the
32 bits GCD function overflow and returned wrong value that resulted
memory registration failed.

This patch calls 64 bits GCD function to avoid overflow.

Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: matan@mellanox.com
Cc: stable@dpdk.org
Reviewed-by: Matan Azrad <matan@nvidia.com>

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
index 59ce4e891c..a06681b494 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c
@@ -103,15 +103,15 @@ mlx5_vdpa_vhost_mem_regions_prepare(int vid, uint8_t *mode, uint64_t *mem_size,
 			size = mem->regions[i].guest_phys_addr -
 				(mem->regions[i - 1].guest_phys_addr +
 				 mem->regions[i - 1].size);
-			*gcd = rte_get_gcd(*gcd, size);
+			*gcd = rte_get_gcd64(*gcd, size);
 			klm_entries_num += KLM_NUM_MAX_ALIGN(size);
 		}
 		size = mem->regions[i].size;
-		*gcd = rte_get_gcd(*gcd, size);
+		*gcd = rte_get_gcd64(*gcd, size);
 		klm_entries_num += KLM_NUM_MAX_ALIGN(size);
 	}
 	if (*gcd > MLX5_MAX_KLM_BYTE_COUNT)
-		*gcd = rte_get_gcd(*gcd, MLX5_MAX_KLM_BYTE_COUNT);
+		*gcd = rte_get_gcd64(*gcd, MLX5_MAX_KLM_BYTE_COUNT);
 	if (!RTE_IS_POWER_OF_2(*gcd)) {
 		uint64_t candidate_gcd = rte_align64prevpow2(*gcd);
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor
  2021-09-23  8:11   ` [dpdk-stable] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor Xueming Li
@ 2021-09-23  9:53     ` Kevin Traynor
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Traynor @ 2021-09-23  9:53 UTC (permalink / raw)
  To: Xueming Li, Matan Azrad, dev; +Cc: stable, Cristian Dumitrescu, Jasvinder Singh

On 23/09/2021 09:11, Xueming Li wrote:
> This patch adds new function that compute the greatest common
> divisor of 64 bits, also changes the original 32 bits function to call
> this new 64 bits version.
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> Cc: stable@dpdk.org
> ---

lgtm.

Acked-by: Kevin Traynor <ktraynor@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-23  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <32dc9e20-86dc-a0a6-74a2-9894cb680170@redhat.com>
     [not found] ` <20210923081122.176735-1-xuemingl@nvidia.com>
2021-09-23  8:11   ` [dpdk-stable] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor Xueming Li
2021-09-23  9:53     ` Kevin Traynor
2021-09-23  8:11   ` [dpdk-stable] [PATCH v2 2/2] vdpa/mlx5: fix large VM memory region registration Xueming Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).