DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eal/x86: fix memcpy alignment mask definition
@ 2026-09-04  9:20 Morten Brørup
  2026-09-04 11:19 ` [PATCH v2] " Morten Brørup
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Morten Brørup @ 2026-09-04  9:20 UTC (permalink / raw)
  To: dev, Bruce Richardson, Konstantin Ananyev, Vipin Varghese,
	Stephen Hemminger
  Cc: Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
purposes, but it is publicly exposed when including the header file,
potentially colliding with existing definitions with the same name.
Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
definition.

Furthermore, the superfluous function declaration at the top of the file
was removed, and its description was moved to the function definition,
to improve search results with source code browsers.

Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 8ed8c55010..41fb08ab95 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
-- 
2.43.0


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

* [PATCH v2] eal/x86: fix memcpy alignment mask definition
  2026-09-04  9:20 [PATCH] eal/x86: fix memcpy alignment mask definition Morten Brørup
@ 2026-09-04 11:19 ` Morten Brørup
  2026-09-04 11:25   ` Bruce Richardson
  2026-09-04 11:31 ` [PATCH v3] " Morten Brørup
  2026-09-04 11:34 ` [PATCH v4] " Morten Brørup
  2 siblings, 1 reply; 7+ messages in thread
From: Morten Brørup @ 2026-09-04 11:19 UTC (permalink / raw)
  To: dev, Bruce Richardson, Konstantin Ananyev, Vipin Varghese,
	Stephen Hemminger
  Cc: Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
purposes, but it is publicly exposed when including the header file,
potentially colliding with existing definitions with the same name.
Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
definition.

Furthermore, the superfluous function declaration at the top of the file
was removed, and its description was moved to the function definition,
to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK
coding style.

None of these changes should have any practical effect.

Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 8ed8c55010..41fb08ab95 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
-- 
2.43.0


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

* Re: [PATCH v2] eal/x86: fix memcpy alignment mask definition
  2026-09-04 11:19 ` [PATCH v2] " Morten Brørup
@ 2026-09-04 11:25   ` Bruce Richardson
  2026-09-04 11:28     ` Morten Brørup
  0 siblings, 1 reply; 7+ messages in thread
From: Bruce Richardson @ 2026-09-04 11:25 UTC (permalink / raw)
  To: Morten Brørup
  Cc: dev, Konstantin Ananyev, Vipin Varghese, Stephen Hemminger

On Fri, Sep 04, 2026 at 11:19:12AM +0000, Morten Brørup wrote:
> An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
> purposes, but it is publicly exposed when including the header file,
> potentially colliding with existing definitions with the same name.
> Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
> definition.
> 
> Furthermore, the superfluous function declaration at the top of the file
> was removed, and its description was moved to the function definition,
> to improve search results with source code browsers.
> 
> Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK
> coding style.
> 
> None of these changes should have any practical effect.
> 
> Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> v2:
> * Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

Did you miss this change in v2? I still see the "!" below.
> ---
>  lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 20 deletions(-)
> 
> diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
> index 8ed8c55010..41fb08ab95 100644
> --- a/lib/eal/x86/include/rte_memcpy.h
> +++ b/lib/eal/x86/include/rte_memcpy.h
> @@ -32,21 +32,6 @@ extern "C" {
>  #define RTE_MEMCPY_AVX
>  #endif
>  
> -/**
> - * Copy bytes from one location to another. The locations must not overlap.
> - *
> - * @param dst
> - *   Pointer to the destination of the data.
> - * @param src
> - *   Pointer to the source data.
> - * @param n
> - *   Number of bytes to copy.
> - * @return
> - *   Pointer to the destination data.
> - */
> -static __rte_always_inline void *
> -rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
> -
>  /**
>   * Copy bytes from one location to another,
>   * locations must not overlap.
> @@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
>   * AVX512 implementation below
>   */
>  
> -#define ALIGNMENT_MASK 0x3F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
>  
>  /**
>   * Copy 128-byte blocks from one location to another,
> @@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
>   * AVX implementation below
>   */
>  
> -#define ALIGNMENT_MASK 0x1F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
>  
>  /**
>   * Copy 128-byte blocks from one location to another,
> @@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
>   * SSE implementation below
>   */
>  
> -#define ALIGNMENT_MASK 0x0F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
>  
>  /**
>   * Macro for copying unaligned block from one location to another with constant load offset,
> @@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
>  	return ret;
>  }
>  
> +/**
> + * Copy bytes from one location to another. The locations must not overlap.
> + *
> + * @param dst
> + *   Pointer to the destination of the data.
> + * @param src
> + *   Pointer to the source data.
> + * @param n
> + *   Number of bytes to copy.
> + * @return
> + *   Pointer to the destination data.
> + */
>  static __rte_always_inline void *
>  rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
>  {
> @@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
>  	}
>  
>  	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
> -	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
> +	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
>  		return rte_memcpy_aligned_more_than_64(dst, src, n);
>  	else
>  		return rte_memcpy_generic_more_than_64(dst, src, n);
>  }
>  
> -#undef ALIGNMENT_MASK
> +#undef RTE_MEMCPY_ALIGNMENT_MASK
>  
>  #ifdef __cplusplus
>  }
> -- 
> 2.43.0
> 

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

* RE: [PATCH v2] eal/x86: fix memcpy alignment mask definition
  2026-09-04 11:25   ` Bruce Richardson
@ 2026-09-04 11:28     ` Morten Brørup
  0 siblings, 0 replies; 7+ messages in thread
From: Morten Brørup @ 2026-09-04 11:28 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, Konstantin Ananyev, Vipin Varghese, Stephen Hemminger

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Friday, 4 September 2026 13.25
> 
> On Fri, Sep 04, 2026 at 11:19:12AM +0000, Morten Brørup wrote:
> > An alignment mask (ALIGNMENT_MASK) is temporarily defined for
> internal
> > purposes, but it is publicly exposed when including the header file,
> > potentially colliding with existing definitions with the same name.
> > Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
> > definition.
> >
> > Furthermore, the superfluous function declaration at the top of the
> file
> > was removed, and its description was moved to the function
> definition,
> > to improve search results with source code browsers.
> >
> > Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow
> DPDK
> > coding style.
> >
> > None of these changes should have any practical effect.
> >
> > Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")
> >
> > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> > v2:
> > * Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)
> 
> Did you miss this change in v2? I still see the "!" below.

Thank you, yes.
It's in my editor, but not on disk. :-\

Will send v3 shortly.


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

* [PATCH v3] eal/x86: fix memcpy alignment mask definition
  2026-09-04  9:20 [PATCH] eal/x86: fix memcpy alignment mask definition Morten Brørup
  2026-09-04 11:19 ` [PATCH v2] " Morten Brørup
@ 2026-09-04 11:31 ` Morten Brørup
  2026-09-04 11:34 ` [PATCH v4] " Morten Brørup
  2 siblings, 0 replies; 7+ messages in thread
From: Morten Brørup @ 2026-09-04 11:31 UTC (permalink / raw)
  To: dev, Bruce Richardson, Konstantin Ananyev, Vipin Varghese,
	Stephen Hemminger
  Cc: Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
purposes, but it is publicly exposed when including the header file,
potentially colliding with existing definitions with the same name.
Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
definition.

Furthermore, the superfluous function declaration at the top of the file
was removed, and its description was moved to the function definition,
to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK
coding style.

None of these changes should have any practical effect.

Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v3:
* Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0".
  In v2, it was changed in my editor, but not saved to disk.
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 8ed8c55010..41fb08ab95 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
-- 
2.43.0


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

* [PATCH v4] eal/x86: fix memcpy alignment mask definition
  2026-09-04  9:20 [PATCH] eal/x86: fix memcpy alignment mask definition Morten Brørup
  2026-09-04 11:19 ` [PATCH v2] " Morten Brørup
  2026-09-04 11:31 ` [PATCH v3] " Morten Brørup
@ 2026-09-04 11:34 ` Morten Brørup
  2026-09-07 14:10   ` Konstantin Ananyev
  2 siblings, 1 reply; 7+ messages in thread
From: Morten Brørup @ 2026-09-04 11:34 UTC (permalink / raw)
  To: dev, Bruce Richardson, Konstantin Ananyev, Vipin Varghese,
	Stephen Hemminger
  Cc: Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
purposes, but it is publicly exposed when including the header file,
potentially colliding with existing definitions with the same name.
Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
definition.

Furthermore, the superfluous function declaration at the top of the file
was removed, and its description was moved to the function definition,
to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK
coding style.

None of these changes should have any practical effect.

Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v4:
* Really, really changed it this time.
  When editing patch files, remember to edit the code too.
v3:
* Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0".
  In v2, it was changed in my editor, but not saved to disk.
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 8ed8c55010..41fb08ab95 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if ((((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK) == 0)
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
-- 
2.43.0


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

* RE: [PATCH v4] eal/x86: fix memcpy alignment mask definition
  2026-09-04 11:34 ` [PATCH v4] " Morten Brørup
@ 2026-09-07 14:10   ` Konstantin Ananyev
  0 siblings, 0 replies; 7+ messages in thread
From: Konstantin Ananyev @ 2026-09-07 14:10 UTC (permalink / raw)
  To: Morten Brørup, dev@dpdk.org, Bruce Richardson,
	Vipin Varghese, Stephen Hemminger



> An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal
> purposes, but it is publicly exposed when including the header file,
> potentially colliding with existing definitions with the same name.
> Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the
> definition.
> 
> Furthermore, the superfluous function declaration at the top of the file
> was removed, and its description was moved to the function definition,
> to improve search results with source code browsers.
> 
> Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK
> coding style.
> 
> None of these changes should have any practical effect.
> 
> Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86")
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> v4:
> * Really, really changed it this time.
>   When editing patch files, remember to edit the code too.
> v3:
> * Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0".
>   In v2, it was changed in my editor, but not saved to disk.
> v2:
> * Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)
> ---
>  lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 20 deletions(-)
> 
> diff --git a/lib/eal/x86/include/rte_memcpy.h
> b/lib/eal/x86/include/rte_memcpy.h
> index 8ed8c55010..41fb08ab95 100644
> --- a/lib/eal/x86/include/rte_memcpy.h
> +++ b/lib/eal/x86/include/rte_memcpy.h
> @@ -32,21 +32,6 @@ extern "C" {
>  #define RTE_MEMCPY_AVX
>  #endif
> 
> -/**
> - * Copy bytes from one location to another. The locations must not overlap.
> - *
> - * @param dst
> - *   Pointer to the destination of the data.
> - * @param src
> - *   Pointer to the source data.
> - * @param n
> - *   Number of bytes to copy.
> - * @return
> - *   Pointer to the destination data.
> - */
> -static __rte_always_inline void *
> -rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
> -
>  /**
>   * Copy bytes from one location to another,
>   * locations must not overlap.
> @@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t
> *__rte_restrict src)
>   * AVX512 implementation below
>   */
> 
> -#define ALIGNMENT_MASK 0x3F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
> 
>  /**
>   * Copy 128-byte blocks from one location to another,
> @@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict
> dst, const void *__rte_rest
>   * AVX implementation below
>   */
> 
> -#define ALIGNMENT_MASK 0x1F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
> 
>  /**
>   * Copy 128-byte blocks from one location to another,
> @@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict
> dst, const void *__rte_rest
>   * SSE implementation below
>   */
> 
> -#define ALIGNMENT_MASK 0x0F
> +#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
> 
>  /**
>   * Macro for copying unaligned block from one location to another with constant
> load offset,
> @@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void
> *__rte_restrict dst, const void *__rte_rest
>  	return ret;
>  }
> 
> +/**
> + * Copy bytes from one location to another. The locations must not overlap.
> + *
> + * @param dst
> + *   Pointer to the destination of the data.
> + * @param src
> + *   Pointer to the source data.
> + * @param n
> + *   Number of bytes to copy.
> + * @return
> + *   Pointer to the destination data.
> + */
>  static __rte_always_inline void *
>  rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
>  {
> @@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void
> *__rte_restrict src, size_t n)
>  	}
> 
>  	/* Implementation for size > 64 bytes depends on alignment with vector
> register size. */
> -	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
> +	if ((((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK)
> == 0)
>  		return rte_memcpy_aligned_more_than_64(dst, src, n);
>  	else
>  		return rte_memcpy_generic_more_than_64(dst, src, n);
>  }
> 
> -#undef ALIGNMENT_MASK
> +#undef RTE_MEMCPY_ALIGNMENT_MASK
> 
>  #ifdef __cplusplus
>  }
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 2.43.0


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

end of thread, other threads:[~2026-09-07 14:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  9:20 [PATCH] eal/x86: fix memcpy alignment mask definition Morten Brørup
2026-09-04 11:19 ` [PATCH v2] " Morten Brørup
2026-09-04 11:25   ` Bruce Richardson
2026-09-04 11:28     ` Morten Brørup
2026-09-04 11:31 ` [PATCH v3] " Morten Brørup
2026-09-04 11:34 ` [PATCH v4] " Morten Brørup
2026-09-07 14:10   ` Konstantin Ananyev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox