Skip to content

Commit 3788e32

Browse files
arighihtejun
authored andcommitted
selftests/sched_ext: Fix build error in dequeue selftest
Building the dequeue selftest with newer compilers (e.g., gcc 16) triggers the following error: dequeue.c:28:22: error: variable 'sum' set but not used The 'volatile' qualifier prevents the writes from being optimized away, but does not silence the unused variable 'sum' is indeed only written and never read. Consume 'sum' via an empty asm() with a register input constraint. This forces the compiler to keep the accumulated value (preserving the CPU stress loop) and avoiding the build error. Fixes: 658ad22 ("selftests/sched_ext: Add test to validate ops.dequeue() semantics") Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent d3e73a0 commit 3788e32

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

tools/testing/selftests/sched_ext/dequeue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static void worker_fn(int id)
3333
/* Do some work to trigger scheduling events */
3434
for (j = 0; j < 10000; j++)
3535
sum += j;
36+
asm volatile("" : : "r"(sum));
3637

3738
/* Sleep to trigger dequeue */
3839
usleep(1000 + (id * 100));

0 commit comments

Comments
 (0)