[3/3] eal: deduplicate roundup code

Message ID 20220821205009.1317044-4-dmitry.kozliuk@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series eal: small rte_common.h fixes and cleanup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Dmitry Kozlyuk Aug. 21, 2022, 8:50 p.m. UTC
  RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/eal/include/rte_common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Morten Brørup Aug. 22, 2022, 7:25 a.m. UTC | #1
> From: Dmitry Kozlyuk [mailto:dmitry.kozliuk@gmail.com]
> Sent: Sunday, 21 August 2022 22.50
> 
> RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
> In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
> so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
>  lib/eal/include/rte_common.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/eal/include/rte_common.h
> b/lib/eal/include/rte_common.h
> index 772e40f8c2..86c50c55e0 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
>  #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
> 
>  /** Return the first cache-aligned value greater or equal to size. */
> -#define RTE_CACHE_LINE_ROUNDUP(size) \
> -	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
> -	RTE_CACHE_LINE_SIZE))
> +#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size,
> RTE_CACHE_LINE_SIZE)
> 
>  /** Cache line size in terms of log2 */
>  #if RTE_CACHE_LINE_SIZE == 64
> --
> 2.33.1
> 

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 772e40f8c2..86c50c55e0 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -425,9 +425,7 @@  rte_is_aligned(void *ptr, unsigned align)
 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
 
 /** Return the first cache-aligned value greater or equal to size. */
-#define RTE_CACHE_LINE_ROUNDUP(size) \
-	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
-	RTE_CACHE_LINE_SIZE))
+#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
 
 /** Cache line size in terms of log2 */
 #if RTE_CACHE_LINE_SIZE == 64