Skip to contentSkip to conversation

test/ring: remove excessive inlining

PATCH Superseded Stanislaw Kardach 5 participants 9 messages May 10, 2022 – May 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/ring: remove excessive inlining

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

However there is no reason to force inlining as the test code works perfectly fine without it.

Fixes a9fe152363 test/ring: add custom element size functional tests
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h +3 -3
index c8bfec8399..45c263f3ff 100644
@@ -97,7 +97,7 @@ test_ring_copy_from(struct rte_ring_zc_data *zcd, void *dst, int esize,
 	}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)
 {
@@ -158,7 +158,7 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 		}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)
 {
@@ -222,7 +222,7 @@ test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 /* This function is placed here as it is required for both
  * performance and functional tests.
  */
-static __rte_always_inline void *
+static inline void *
 test_ring_calloc(unsigned int rsize, int esize)
 {
 	unsigned int sz;
Signature · 1 line
2.30.2
#1 lore raw

+ Bruce, Stephen

<snip>

Quoted 8 lines

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

Quoted 6 lines

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

Is there a bug report created for this? Is it possible to add a link to the bug report?

Quoted 3 lines

However there is no reason to force inlining as the test code works perfectly fine without it.

If this solves the problem, I prefer this as it is test code.

Quoted 43 lines
Fixes a9fe152363 test/ring: add custom element size functional tests
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h index renamed from app/test/test_ring.h +0 -0

c8bfec8399..45c263f3ff 100644

app/test/test_ring.h +1 -1
@@ -97,7 +97,7 @@ test_ring_copy_from(struct rte_ring_zc_data *zcd, void
 *dst, int esize,
 	}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)

{

app/test/test_ring.h +1 -1
@@ -158,7 +158,7 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int
 esize, unsigned int n,
 		}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)

{

app/test/test_ring.h +1 -2
@@ -222,7 +222,7 @@ test_ring_dequeue(struct rte_ring *r, void **obj, int
 esize, unsigned int n,
 /* This function is placed here as it is required for both
  * performance and functional tests.
  */
-static __rte_always_inline void *
+static inline void *
 test_ring_calloc(unsigned int rsize, int esize)  {
 	unsigned int sz;
--

2.30.2

#2 lore raw
Quoted 18 lines · Honnappa Nagarahalli

+ Bruce, Stephen

<snip>

Quoted 8 lines

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

Quoted 6 lines

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

Quoted 7 lines

Is there a bug report created for this? Is it possible to add a link to the bug report?

Quoted 3 lines

However there is no reason to force inlining as the test code works perfectly fine without it.

If this solves the problem, I prefer this as it is test code.

+1 to this. I'm quite wary of changing the ring code itself.

#4 lore raw

PATCH v2 1/1 test/ring: remove excessive inlining

In reply to Stanislaw Kardach

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

However there is no reason to force inlining as the test code works perfectly fine without it.

GCC has a bug report for a similar case (with conditionals):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062

Fixes a9fe152363 test/ring: add custom element size functional tests
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h +3 -3
index c8bfec8399..45c263f3ff 100644
@@ -97,7 +97,7 @@ test_ring_copy_from(struct rte_ring_zc_data *zcd, void *dst, int esize,
 	}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)
 {
@@ -158,7 +158,7 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 		}
 }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
 test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 			unsigned int api_type)
 {
@@ -222,7 +222,7 @@ test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 /* This function is placed here as it is required for both
  * performance and functional tests.
  */
-static __rte_always_inline void *
+static inline void *
 test_ring_calloc(unsigned int rsize, int esize)
 {
 	unsigned int sz;
Signature · 1 line
2.30.2
Acked-by on v2 1/1
#5 lore raw
Quoted 18 lines · Stanislaw Kardach

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

However there is no reason to force inlining as the test code works perfectly fine without it.

Quoted 6 lines

GCC has a bug report for a similar case (with conditionals):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062

Fixes a9fe152363 test/ring: add custom element size functional tests
Reviewed-by Honnappa Nagarahalli Acked-by Konstantin Ananyev Applied
#6 lore raw
Quoted 17 lines · Bruce Richardson
Quoted 15 lines · Stanislaw Kardach

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

Quoted 7 lines
Quoted 7 lines

However there is no reason to force inlining as the test code works perfectly fine without it.

GCC has a bug report for a similar case (with conditionals):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062

Fixes a9fe152363 test/ring: add custom element size functional tests
Fixes a9fe152363e2 ("test/ring: add custom element size functional tests")
Quoted 3 lines
Quoted 2 lines

Applied, thanks.

Signature · 1 line
David Marchand
Reviewed-by on v2 1/1
#7 lore raw
In reply to Stanislaw Kardach

<snip>

Quoted 18 lines

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

However there is no reason to force inlining as the test code works perfectly fine without it.

Quoted 6 lines

GCC has a bug report for a similar case (with conditionals):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062

Fixes a9fe152363 test/ring: add custom element size functional tests
Acked-by on v2 1/1
#8 lore raw
In reply to Stanislaw Kardach

11/05/2022 16:07, Stanislaw Kardach пишет:

Quoted 51 lines

Forcing inlining in test_ring_enqueue and test_ring_dequeue can cause the compiled code to grow extensively when compiled with no optimization (-O0 or -Og). This is default in the meson's debug configuration. This can collide with compiler bugs and cause issues during linking of unit tests where the api_type or esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize and api_type are const values.

One such case was discovered when porting DPDK to RISC-V. GCC 11.2 (and no fix still in 12.1) is generating a short relative jump instruction (J <offset>) for goto and for loops. When loop body grows extensively in ring test, the target offset goes beyond supported offfset of +/- 1MB from PC. This is an obvious bug in the GCC as RISC-V has a two-instruction construct to jump to any absolute address (AUIPC+JALR).

However there is no reason to force inlining as the test code works perfectly fine without it.

GCC has a bug report for a similar case (with conditionals):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062

Fixes a9fe152363 test/ring: add custom element size functional tests
---
  app/test/test_ring.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h +2 -2
index c8bfec8399..45c263f3ff 100644
@@ -97,7 +97,7 @@ test_ring_copy_from(struct rte_ring_zc_data *zcd, void *dst, int esize,
  	}
  }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
  test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
  			unsigned int api_type)
  {
@@ -158,7 +158,7 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
  		}
  }
 
-static __rte_always_inline unsigned int
+static inline unsigned int
  test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
  			unsigned int api_type)
  {

app/test/test_ring.h test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n, · line 228

Quoted 8 lines
app/test/test_ring.h +1 -1
@@ -222,7 +222,7 @@ test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,
  /* This function is placed here as it is required for both
   * performance and functional tests.
   */
-static __rte_always_inline void *
+static inline void *
  test_ring_calloc(unsigned int rsize, int esize)
  {
  	unsigned int sz;