[PATCH 5/6] cyclictest: Allow symbolic clock names

Thomas Weißschuh (Schneider Electric) <[email protected]> Tue, 07 Apr 2026 08:48:45 +0200
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
The numeric values are not self-explanatory. New clocks are about to be
added, exarcerbating the issue.

Allow users to specify symbolic clock names and document those.

The old numbers are still handled for backwards compatibility.

Signed-off-by: Thomas Weißschuh (Schneider Electric) <[email protected]>
---
 src/cyclictest/cyclictest.8 | 4 ++--
 src/cyclictest/cyclictest.c | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index ff2cb968fc01..1a59d3b29048 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -56,9 +56,9 @@ Send break trace command when latency > USEC
 .B \-c, \-\-clock=CLOCK
 select clock
 .br
-0 = CLOCK_MONOTONIC (default)
+monotonic (default)
 .br
-1 = CLOCK_REALTIME
+realtime
 .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 40da2cc4119d..2d1ff968f8aa 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -950,8 +950,8 @@ static void display_help(int error)
 	       "-A USEC  --aligned=USEC    align thread wakeups to a specific offset\n"
 	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
 	       "-c CLOCK --clock=CLOCK     select clock\n"
-	       "                           0 = CLOCK_MONOTONIC (default)\n"
-	       "                           1 = CLOCK_REALTIME\n"
+	       "                           monotonic (default)\n"
+	       "                           realtime\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"
@@ -1043,8 +1043,12 @@ static int handleclock(const char *clockarg)
 {
 	if (strcmp(clockarg, "0") == 0)
 		used_clock = CLOCK_MONOTONIC;
+	else if (strcmp(clockarg, "monotonic") == 0)
+		used_clock = CLOCK_MONOTONIC;
 	else if (strcmp(clockarg, "1") == 0)
 		used_clock = CLOCK_REALTIME;
+	else if (strcmp(clockarg, "realtime") == 0)
+		used_clock = CLOCK_REALTIME;
 	else
 		return 1;
 

-- 
2.53.0