test/ring: remove excessive inlining
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.
--- app/test/test_ring.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h +3 -3
@@ -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
+ Bruce, Stephen
<snip>
Quoted 8 lines
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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 testsSigned-off-by Stanislaw Kardach <[email protected]>--- 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..45c263f3ff100644app/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
Quoted 18 lines · Honnappa Nagarahalli
+ Bruce, Stephen
<snip>
Quoted 8 lines
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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.
On Wed, May 11, 2022 at 1:24 AM Honnappa Nagarahalli <[email protected]> wrote:
<snip>
Quoted 1 line
Is there a bug report created for this? Is it possible to add a link to the bug report?
I have found a bug for a similar issue (with "if" conditional):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93062
I'll add it in v2.
PATCH v2 1/1 test/ring: remove excessive inlining
In reply to Stanislaw KardachForcing 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
--- app/test/test_ring.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_ring.h +3 -3
@@ -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
Quoted 18 lines · Stanislaw Kardach
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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=93062Fixes a9fe152363 test/ring: add custom element size functional testsSigned-off-by Stanislaw Kardach <[email protected]>
Quoted 17 lines · Bruce Richardson
Quoted 15 lines · Stanislaw Kardach
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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=93062Fixes a9fe152363 test/ring: add custom element size functional tests
Quoted 3 lines
Quoted 2 lines
Signed-off-by Stanislaw Kardach <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand
<snip>
Quoted 18 lines
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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=93062Fixes a9fe152363 test/ring: add custom element size functional testsSigned-off-by Stanislaw Kardach <[email protected]>
11/05/2022 16:07, Stanislaw Kardach пишет:
Quoted 51 lines
Forcing inlining in
test_ring_enqueueandtest_ring_dequeuecan 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 theapi_typeor esize are non-const variables causing inlining cascade. In perf tests this is not the case in perf-tests as esize andapi_typeare 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=93062Fixes a9fe152363 test/ring: add custom element size functional testsSigned-off-by Stanislaw Kardach <[email protected]>--- app/test/test_ring.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)app/test/test_ring.h +2
-2@@ -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;