Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] selftests/rseq: Mark variables only some builds read as unused
@ 2026-12-01 18:08 Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2026-12-01 18:08 UTC (permalink / raw)
  To: Mathieu Desnoyers, Peter Zijlstra, Paul E. McKenney, Boqun Feng
  Cc: Sasha Levin, Thomas Gleixner, Shuah Khan, linux-kselftest,
	linux-kernel, Nathan Chancellor, llvm

loop_cnt_1 to loop_cnt_6 are only read by the x86 delay injection
assembly, and verbose, opt_signal and signals_delivered only when
BENCHMARK is not defined. clang 23 warns about them in the other builds:

  param_test.c:29:12: warning: variable 'loop_cnt_1' set but not used [-Wunused-but-set-global]
  param_test.c:36:24: warning: variable 'verbose' set but not used [-Wunused-but-set-global]

It warns about loop_cnt_1 to loop_cnt_6 on x86 too, as it does not see
the assembly reading them.

Mark them unused, like yield_mod_cnt and nr_abort.

Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/rseq/param_test.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c
index e1e98dbabe4bc..d40f60f62c9e9 100644
--- a/tools/testing/selftests/rseq/param_test.c
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -26,22 +26,22 @@ static inline pid_t rseq_gettid(void)
 #define NR_INJECT	9
 static int loop_cnt[NR_INJECT + 1];
 
-static int loop_cnt_1 asm("asm_loop_cnt_1") __attribute__((used));
-static int loop_cnt_2 asm("asm_loop_cnt_2") __attribute__((used));
-static int loop_cnt_3 asm("asm_loop_cnt_3") __attribute__((used));
-static int loop_cnt_4 asm("asm_loop_cnt_4") __attribute__((used));
-static int loop_cnt_5 asm("asm_loop_cnt_5") __attribute__((used));
-static int loop_cnt_6 asm("asm_loop_cnt_6") __attribute__((used));
+static int loop_cnt_1 asm("asm_loop_cnt_1") __attribute__((used, unused));
+static int loop_cnt_2 asm("asm_loop_cnt_2") __attribute__((used, unused));
+static int loop_cnt_3 asm("asm_loop_cnt_3") __attribute__((used, unused));
+static int loop_cnt_4 asm("asm_loop_cnt_4") __attribute__((used, unused));
+static int loop_cnt_5 asm("asm_loop_cnt_5") __attribute__((used, unused));
+static int loop_cnt_6 asm("asm_loop_cnt_6") __attribute__((used, unused));
 
-static int opt_modulo, verbose;
+static int opt_modulo, verbose __attribute__((unused));
 
-static int opt_yield, opt_signal, opt_sleep,
+static int opt_yield, opt_signal __attribute__((unused)), opt_sleep,
 		opt_disable_rseq, opt_threads = 200,
 		opt_disable_mod = 0, opt_test = 's';
 static bool opt_rseq_legacy;
 static long long opt_reps = 5000;
 
-static __thread __attribute__((tls_model("initial-exec")))
+static __thread __attribute__((tls_model("initial-exec"), unused))
 unsigned int signals_delivered;
 
 #ifndef BENCHMARK
-- 
2.53.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01 18:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 18:08 [PATCH] selftests/rseq: Mark variables only some builds read as unused Sasha Levin

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