[3/3] eal: deduplicate roundup code
Checks
Commit Message
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
> 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>
@@ -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