[PATCH 6/6] cyclictest: Add support for auxiliary clocks

Thomas Weißschuh (Schneider Electric) <[email protected]> Tue, 07 Apr 2026 08:48:46 +0200
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
The Linux kernel provides support for non-standard auxiliary clocks.
These run independently from the system clock and each other.

Allow cyclictest to also use those.

Signed-off-by: Thomas Weißschuh (Schneider Electric) <[email protected]>

---
Currently clock_nanosleep() for these auxiliary clocks is not yet in the
mainline kernel.

Instead of having a dedicated parsing function, I used the unrolled
switch-case as it keeps the logic simple in the face of error handling.
---
 src/cyclictest/cyclictest.8 |  2 ++
 src/cyclictest/cyclictest.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index 1a59d3b29048..f3390bc5c57d 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -59,6 +59,8 @@ select clock
 monotonic (default)
 .br
 realtime
+.br
+aux0 - aux7
 .TP
 .B \-\-deepest\-idle\-state=n
 Reduce exit from idle latency by limiting idle state up to n on used cpus (-1 disables all idle states). Power management is not suppresed on other cpus.
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 2d1ff968f8aa..afc3a8c452da 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -52,6 +52,10 @@
 #define SCHED_NORMAL SCHED_OTHER
 #endif
 
+#ifndef CLOCK_AUX
+#define CLOCK_AUX 16
+#endif
+
 #define sigev_notify_thread_id _sigev_un._tid
 
 #ifdef __UCLIBC__
@@ -952,6 +956,7 @@ static void display_help(int error)
 	       "-c CLOCK --clock=CLOCK     select clock\n"
 	       "                           monotonic (default)\n"
 	       "                           realtime\n"
+	       "                           aux0 - aux7\n"
 	       "         --deepest-idle-state=n\n"
 	       "                           Reduce exit from idle latency by limiting idle state\n"
 	       "                           up to n on used cpus (-1 disables all idle states).\n"
@@ -1049,6 +1054,22 @@ static int handleclock(const char *clockarg)
 		used_clock = CLOCK_REALTIME;
 	else if (strcmp(clockarg, "realtime") == 0)
 		used_clock = CLOCK_REALTIME;
+	else if (strcmp(clockarg, "aux0") == 0)
+		used_clock = CLOCK_AUX + 0;
+	else if (strcmp(clockarg, "aux1") == 0)
+		used_clock = CLOCK_AUX + 1;
+	else if (strcmp(clockarg, "aux2") == 0)
+		used_clock = CLOCK_AUX + 2;
+	else if (strcmp(clockarg, "aux3") == 0)
+		used_clock = CLOCK_AUX + 3;
+	else if (strcmp(clockarg, "aux4") == 0)
+		used_clock = CLOCK_AUX + 4;
+	else if (strcmp(clockarg, "aux5") == 0)
+		used_clock = CLOCK_AUX + 5;
+	else if (strcmp(clockarg, "aux6") == 0)
+		used_clock = CLOCK_AUX + 6;
+	else if (strcmp(clockarg, "aux7") == 0)
+		used_clock = CLOCK_AUX + 7;
 	else
 		return 1;
 

-- 
2.53.0