diff mbox series

[v2,1/1] test/ring: remove excessive inlining

Message ID 20220511150725.744021-1-kda@semihalf.com (mailing list archive)
State New
Delegated to: David Marchand
Headers show
Series [v2,1/1] test/ring: remove excessive inlining | expand

Checks

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

Commit Message

Stanisław Kardach May 11, 2022, 3:07 p.m. UTC
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

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Bruce Richardson May 11, 2022, 3:48 p.m. UTC | #1
On Wed, May 11, 2022 at 05:07:25PM +0200, Stanislaw Kardach wrote:
> 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
> 
> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Honnappa Nagarahalli May 11, 2022, 4:51 p.m. UTC | #2
<snip>
> 
> 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
> 
> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
diff mbox series

Patch

diff --git a/app/test/test_ring.h b/app/test/test_ring.h
index c8bfec8399..45c263f3ff 100644
--- a/app/test/test_ring.h
+++ b/app/test/test_ring.h
@@ -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;