selftests/sched_ext: Fix build error in dequeue_remote selftest
Subsystems (2)
PATCH 1/1 selftests/sched_ext: Fix build error in dequeue_remote selftest
Building the dequeue_remote selftest with newer compilers (e.g., gcc 16) triggers the following error:
dequeue_remote.c:39:32: error: variable ‘sum’ set but not used
The 'volatile' qualifier prevents the writes from being optimized away, but does not silence the warning, since 'sum' is indeed only written and never read.
Consume 'sum' via an empty asm() with a register input constraint, as already done for the dequeue selftest in commit 3788e3251653 ("selftests/sched_ext: Fix build error in dequeue selftest"). This forces the compiler to keep the accumulated value (preserving the CPU stress loop) and avoids the build error.
--- tools/testing/selftests/sched_ext/dequeue_remote.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/sched_ext/dequeue_remote.c +1 -0
@@ -43,6 +43,7 @@ static void worker_fn(int id)for (j =0 ; j <20000 + id *1000 ; j++) sum += j; + asmvolatile ("" : :"r" (sum));if (id &1 )usleep (100 );else
Signature · 1 line
2.56.0
Quoted 27 lines · Samuele Mariotti
Building the
dequeue_remoteselftest with newer compilers (e.g., gcc 16) triggers the following error:dequeue_remote.c:39:32: error: variable ‘sum’ set but not used
The 'volatile' qualifier prevents the writes from being optimized away, but does not silence the warning, since 'sum' is indeed only written and never read.
Consume 'sum' via an empty
asm()with a register input constraint, as already done for the dequeue selftest in commit3788e3251653("selftests/sched_ext: Fix build error in dequeue selftest"). This forces the compiler to keep the accumulated value (preserving the CPU stress loop) and avoids the build error.Fixes cc07fae1de5d ("selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves")Signed-off-by Samuele Mariotti <[email protected]>--- tools/testing/selftests/sched_ext/dequeue_remote.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/sched_ext/dequeue_remote.c +0
-0
tools/testing/selftests/sched_ext/dequeue_remote.c static void worker_fn(int id) · line 49
Quoted 7 lines
tools/testing/selftests/sched_ext/dequeue_remote.c +1
-0@@ -43,6 +43,7 @@ static void worker_fn(int id)for (j =0 ; j <20000 + id *1000 ; j++) sum += j; + asmvolatile ("" : :"r" (sum));if (id &1 )usleep (100 );else
LGTM, thank you Samuele!
Applied to sched_ext/for-7.4 with the Fixes tag dropped and the following tag added:
Thanks.
--
tejun