Skip to contentSkip to conversation

eal: force gcc to inline rte_movX function

PATCH Applied Junjie Chen 3 participants 5 messages Apr 12, 2018 – Apr 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: force gcc to inline rte_movX function

From: "Chen, Junjie" <[email protected]>

Sometimes gcc does not inline the function despite keyword *inline*, we obeserve rte_movX is not inline when doing performance profiling, so use *always_inline* keyword to force gcc to inline the function.

---
 .../common/include/arch/x86/rte_memcpy.h           | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +11 -11
index cc140ecca..5ead68ab2 100644
@@ -52,7 +52,7 @@ rte_memcpy(void *dst, const void *src, size_t n);
  * Copy 16 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov16(uint8_t *dst, const uint8_t *src)
 {
 	__m128i xmm0;
@@ -65,7 +65,7 @@ rte_mov16(uint8_t *dst, const uint8_t *src)
  * Copy 32 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov32(uint8_t *dst, const uint8_t *src)
 {
 	__m256i ymm0;
@@ -78,7 +78,7 @@ rte_mov32(uint8_t *dst, const uint8_t *src)
  * Copy 64 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov64(uint8_t *dst, const uint8_t *src)
 {
 	__m512i zmm0;
@@ -91,7 +91,7 @@ rte_mov64(uint8_t *dst, const uint8_t *src)
  * Copy 128 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov128(uint8_t *dst, const uint8_t *src)
 {
 	rte_mov64(dst + 0 * 64, src + 0 * 64);
@@ -102,7 +102,7 @@ rte_mov128(uint8_t *dst, const uint8_t *src)
  * Copy 256 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov256(uint8_t *dst, const uint8_t *src)
 {
 	rte_mov64(dst + 0 * 64, src + 0 * 64);
@@ -293,7 +293,7 @@ rte_memcpy_generic(void *dst, const void *src, size_t n)
  * Copy 16 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov16(uint8_t *dst, const uint8_t *src)
 {
 	__m128i xmm0;
@@ -306,7 +306,7 @@ rte_mov16(uint8_t *dst, const uint8_t *src)
  * Copy 32 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov32(uint8_t *dst, const uint8_t *src)
 {
 	__m256i ymm0;
@@ -319,7 +319,7 @@ rte_mov32(uint8_t *dst, const uint8_t *src)
  * Copy 64 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov64(uint8_t *dst, const uint8_t *src)
 {
 	rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
@@ -486,7 +486,7 @@ rte_memcpy_generic(void *dst, const void *src, size_t n)
  * Copy 16 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov16(uint8_t *dst, const uint8_t *src)
 {
 	__m128i xmm0;
@@ -499,7 +499,7 @@ rte_mov16(uint8_t *dst, const uint8_t *src)
  * Copy 32 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov32(uint8_t *dst, const uint8_t *src)
 {
 	rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16);
@@ -510,7 +510,7 @@ rte_mov32(uint8_t *dst, const uint8_t *src)
  * Copy 64 bytes from one location to another,
  * locations should not overlap.
  */
-static inline void
+static __rte_always_inline void
 rte_mov64(uint8_t *dst, const uint8_t *src)
 {
 	rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16);
Signature · 1 line
2.16.0
#1 lore raw

12/04/2018 07:16, Junjie Chen:

Quoted 10 lines

From: "Chen, Junjie" <[email protected]>

Sometimes gcc does not inline the function despite keyword *inline*, we obeserve rte_movX is not inline when doing performance profiling, so use *always_inline* keyword to force gcc to inline the function.

---
 .../common/include/arch/x86/rte_memcpy.h           | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

The title should start with "eal/x86:" Something like that:
eal/x86: force inlining of memcpy sub-functions

Bruce, Konstantin, any review of the content/optimization?

#2 lore raw
Quoted 12 lines · Thomas Monjalon

12/04/2018 07:16, Junjie Chen:

Quoted 10 lines

From: "Chen, Junjie" <[email protected]>

Sometimes gcc does not inline the function despite keyword *inline*, we obeserve rte_movX is not inline when doing performance profiling, so use *always_inline* keyword to force gcc to inline the function.

---
 .../common/include/arch/x86/rte_memcpy.h           | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
Quoted 6 lines

The title should start with "eal/x86:" Something like that:
eal/x86: force inlining of memcpy sub-functions

Bruce, Konstantin, any review of the content/optimization?

No objection here.

#3 lore raw

Thanks to point this out. I agree for the title change.

Do you want me to send v2 patch? Or you can handle it when committing?

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines

Sometimes gcc does not inline the function despite keyword *inline*, we obeserve rte_movX is not inline when doing performance profiling, so use *always_inline* keyword to force gcc to inline the function.

---
 .../common/include/arch/x86/rte_memcpy.h           | 22

+++++++++++-----------

Quoted 8 lines
Quoted 1 line
 1 file changed, 11 insertions(+), 11 deletions(-)

The title should start with "eal/x86:" Something like that:
eal/x86: force inlining of memcpy sub-functions

Bruce, Konstantin, any review of the content/optimization?

No objection here.

#4 lore raw

18/04/2018 04:43, Chen, Junjie J:

Quoted 23 lines

Thanks to point this out. I agree for the title change.

Do you want me to send v2 patch? Or you can handle it when committing?

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines

Sometimes gcc does not inline the function despite keyword *inline*, we obeserve rte_movX is not inline when doing performance profiling, so use *always_inline* keyword to force gcc to inline the function.

---
 .../common/include/arch/x86/rte_memcpy.h           | 22

+++++++++++-----------

Quoted 8 lines
Quoted 1 line
 1 file changed, 11 insertions(+), 11 deletions(-)

The title should start with "eal/x86:" Something like that:
eal/x86: force inlining of memcpy sub-functions

Bruce, Konstantin, any review of the content/optimization?

No objection here.

Applied, thanks