mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest
@ 2026-10-12 11:59 Samuele Mariotti
  2026-10-12 13:17 ` Kuba Piecuch
  2026-10-12 18:01 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Samuele Mariotti @ 2026-10-12 11:59 UTC (permalink / raw)
  To: tj
  Cc: void, arighi, changwoo, jpiecuch, shuah, sched-ext,
	linux-kselftest, linux-kernel, Samuele Mariotti

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.

Fixes: cc07fae1de5d ("selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves")

Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
---
 tools/testing/selftests/sched_ext/dequeue_remote.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/sched_ext/dequeue_remote.c b/tools/testing/selftests/sched_ext/dequeue_remote.c
index f2c1901030de..af344581d5f1 100644
--- a/tools/testing/selftests/sched_ext/dequeue_remote.c
+++ b/tools/testing/selftests/sched_ext/dequeue_remote.c
@@ -43,6 +43,7 @@ static void worker_fn(int id)
 
 		for (j = 0; j < 20000 + id * 1000; j++)
 			sum += j;
+		asm volatile("" : : "r"(sum));
 		if (id & 1)
 			usleep(100);
 		else
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest
  2026-10-12 11:59 [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest Samuele Mariotti
@ 2026-10-12 13:17 ` Kuba Piecuch
  2026-10-12 18:01 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Kuba Piecuch @ 2026-10-12 13:17 UTC (permalink / raw)
  To: Samuele Mariotti, tj
  Cc: void, arighi, changwoo, jpiecuch, shuah, sched-ext,
	linux-kselftest, linux-kernel

On Mon Oct 12, 2026 at 11:59 AM UTC, Samuele Mariotti wrote:
> 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.
>
> Fixes: cc07fae1de5d ("selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves")
>
> Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
> ---
>  tools/testing/selftests/sched_ext/dequeue_remote.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/sched_ext/dequeue_remote.c b/tools/testing/selftests/sched_ext/dequeue_remote.c
> index f2c1901030de..af344581d5f1 100644
> --- a/tools/testing/selftests/sched_ext/dequeue_remote.c
> +++ b/tools/testing/selftests/sched_ext/dequeue_remote.c
> @@ -43,6 +43,7 @@ static void worker_fn(int id)
>  
>  		for (j = 0; j < 20000 + id * 1000; j++)
>  			sum += j;
> +		asm volatile("" : : "r"(sum));
>  		if (id & 1)
>  			usleep(100);
>  		else

LGTM, thank you Samuele!

Reviewed-by: Kuba Piecuch <jpiecuch@google.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest
  2026-10-12 11:59 [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest Samuele Mariotti
  2026-10-12 13:17 ` Kuba Piecuch
@ 2026-10-12 18:01 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2026-10-12 18:01 UTC (permalink / raw)
  To: Samuele Mariotti
  Cc: void, arighi, changwoo, jpiecuch, shuah, sched-ext,
	linux-kselftest, linux-kernel

Applied to sched_ext/for-7.4 with the Fixes tag dropped and the following
tag added:

    Reviewed-by: Kuba Piecuch <jpiecuch@google.com>

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-12 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-12 11:59 [PATCH] selftests/sched_ext: Fix build error in dequeue_remote selftest Samuele Mariotti
2026-10-12 13:17 ` Kuba Piecuch
2026-10-12 18:01 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®