Commit 3788e325 authored by Andrea Righi's avatar Andrea Righi Committed by Tejun Heo
Browse files

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: 658ad225 ("selftests/sched_ext: Add test to validate ops.dequeue() semantics")
Signed-off-by: default avatarAndrea Righi <arighi@nvidia.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent d3e73a08
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ static void worker_fn(int id)
		/* Do some work to trigger scheduling events */
		for (j = 0; j < 10000; j++)
			sum += j;
		asm volatile("" : : "r"(sum));

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