sched: support 64 bits greatest common divisor
Subsystems (2)
PATCH 1/1 sched: support 64 bits greatest common divisor
This patch changes inline function that compute the greatest common divisor to 64 bits.
--- lib/sched/rte_sched_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/sched/rte_sched_common.h +3 -3
@@ -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_gcd (uint64_t a,uint64_t b) { -uint32_t c; +uint64_t c;if (a ==0 )return b;
Signature · 1 line
2.25.1
PATCH 1/1 sched: adds function to get 64 bits greatest common divisor
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.
---
v1: add 64 bits version and make 32 bits api call it
lib/sched/rte_sched_common.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
lib/sched/rte_sched_common.h +16 -3
@@ -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,19 @@ rte_get_gcd(uint32_t a, uint32_t b)return a; } +/* +* Compute the Greatest Common Divisor (GCD) of two u32 numbers. +* This implementation uses Euclid's algorithm: +* gcd(a, 0) = a +* gcd(a, b) = gcd(b, a mod b) +* +*/ +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:
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v1] sched: adds function to get 64 bits greatest common divisor
Quoted 4 lines · Xueming Li
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.
Can you say why it is needed? It's unused apart from being called for the original 32 bit version.
Quoted 26 lines
Signed-off-by Xueming Li <[email protected]>---
v1: add 64 bits version and make 32 bits api call itlib/sched/rte_sched_common.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)lib/sched/rte_sched_common.h +3
-3@@ -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;
lib/sched/rte_sched_common.h rte_get_gcd(uint32_t a, uint32_t b) · line 85
Quoted 10 lines
lib/sched/rte_sched_common.h +7
-0@@ -76,6 +76,19 @@ rte_get_gcd(uint32_t a, uint32_t b)return a; } +/* +* Compute the Greatest Common Divisor (GCD) of two u32 numbers. +* This implementation uses Euclid's algorithm: +* gcd(a, 0) = a +* gcd(a, b) = gcd(b, a mod b) +* +*/
I would probably not describe the algorithm here as it is not implemented in this function.
Quoted 10 lines
lib/sched/rte_sched_common.h +6
-0+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:
Re: [dpdk-dev] [PATCH v1] sched: adds function to get 64 bits greatest common divisor
Quoted 8 lines · Kevin Traynor
Quoted 4 lines · Xueming Li
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.
Can you say why it is needed? It's unused apart from being called for the original 32 bit version.
mlx5 vdpa driver is expecting to use a 64 bit version.
Quoted 30 lines
Quoted 30 lines
Signed-off-by Xueming Li <[email protected]>---
v1: add 64 bits version and make 32 bits api call itlib/sched/rte_sched_common.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)lib/sched/rte_sched_common.h +3
-3@@ -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,19 @@ rte_get_gcd(uint32_t a, uint32_t b)return a; }
Quoted 10 lines
lib/sched/rte_sched_common.h rte_get_gcd(uint32_t a, uint32_t b) · line 85
Quoted 7 lines
lib/sched/rte_sched_common.h +7
-0+/* +* Compute the Greatest Common Divisor (GCD) of two u32 numbers. +* This implementation uses Euclid's algorithm: +* gcd(a, 0) = a +* gcd(a, b) = gcd(b, a mod b) +* +*/ I would probably not describe the algorithm here as it is not implemented in this function.
Thanks, I'll just mention that a 32 bit version of GCD.
Quoted 12 lines
Quoted 11 lines
lib/sched/rte_sched_common.h +6
-0+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:
v2 cover sched: adds function to get 64 bits greatest common divisor
In reply to Kevin TraynorAdds 64bit version of GCD.
v1: keep both 32 and 64 bit version
v2:
- update 32bit function comments
- add mlx5 patch
Xueming Li (2):
sched: adds function to get 64 bits greatest common divisor vdpa/mlx5: fix large VM memory region registration
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 6 +++--- lib/sched/rte_sched_common.h | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
2.33.0
PATCH v2 1/2 sched: adds function to get 64 bits greatest common divisor
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.
--- lib/sched/rte_sched_common.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
lib/sched/rte_sched_common.h +12 -3
@@ -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:
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 1/2] sched: adds function to get 64 bits greatest common divisor
Quoted 7 lines · Xueming Li
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 <[email protected]>---
lgtm.
PATCH v2 2/2 vdpa/mlx5: fix large VM memory region registration
In reply to Xueming LiWhen 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.
--- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa_mem.c +3 -3
@@ -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);
Signature · 1 line
2.33.0
Re: [dpdk-dev] [PATCH v2 0/2] sched: adds function to get 64 bits greatest common divisor
In reply to Xueming LiQuoted 3 lines
Xueming Li (2):
sched: adds function to get 64 bits greatest common divisor vdpa/mlx5: fix large VM memory region registration
Series applied, thanks.
Note: commit logs are arranged, especially for adding verbs and sorting tags.
Re: [dpdk-dev] [PATCH v2 0/2] sched: adds function to get 64 bits greatest common divisor
Quoted 8 lines · Thomas Monjalon
Quoted 3 lines
Xueming Li (2):
sched: adds function to get 64 bits greatest common divisor vdpa/mlx5: fix large VM memory region registrationSeries applied, thanks.
Note: commit logs are arranged, especially for adding verbs and sorting tags.
Thanks very much!