]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/tracing: Add s390-tod clock
authorSven Schnelle <svens@linux.ibm.com>
Thu, 21 May 2026 10:41:44 +0000 (12:41 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 26 May 2026 06:15:41 +0000 (08:15 +0200)
In order to allow comparing trace timestamps between different
systems or virtual machines on s390, add a s390-tod trace clock.
This clock just uses the returned TOD clock value from stcke
directly.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Documentation/trace/ftrace.rst
arch/s390/include/asm/trace_clock.h [new file with mode: 0644]
arch/s390/kernel/Makefile
arch/s390/kernel/trace_clock.c [new file with mode: 0644]

index b9efb148a5c22b11397ae5f3c7d72a929c98fab5..f4d3f4d35ed5b4277bc2b71644a0fd534490337d 100644 (file)
@@ -570,6 +570,10 @@ of ftrace. Here is a list of some of the key files:
                to correlate events across hypervisor/guest if
                tb_offset is known.
 
+       s390-tod:
+               This uses the s390 TOD clock value. This clock is usually in
+               sync across virtual machines and STP-enabled machines.
+
        mono:
                This uses the fast monotonic clock (CLOCK_MONOTONIC)
                which is monotonic and is subject to NTP rate adjustments.
diff --git a/arch/s390/include/asm/trace_clock.h b/arch/s390/include/asm/trace_clock.h
new file mode 100644 (file)
index 0000000..273e05c
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_S390_TRACE_CLOCK_H
+#define _ASM_S390_TRACE_CLOCK_H
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+u64 notrace trace_clock_s390_tod(void);
+
+#define ARCH_TRACE_CLOCKS \
+       { trace_clock_s390_tod, "s390-tod", .in_ns = 0 },
+
+#endif /* _ASM_S390_TRACE_CLOCK_H */
index 137e4793ec1175348792cdca947b0fef09d77a66..6c88476d79a31193195e399584d965c7c2888289 100644 (file)
@@ -62,6 +62,7 @@ obj-$(CONFIG_KPROBES)         += mcount.o
 obj-$(CONFIG_RETHOOK)          += rethook.o
 obj-$(CONFIG_FUNCTION_TRACER)  += ftrace.o
 obj-$(CONFIG_FUNCTION_TRACER)  += mcount.o
+obj-$(CONFIG_TRACING)          += trace_clock.o
 obj-$(CONFIG_CRASH_DUMP)       += crash_dump.o
 obj-$(CONFIG_KEXEC_CORE)       += machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_VMCORE_INFO)      += vmcore_info.o
diff --git a/arch/s390/kernel/trace_clock.c b/arch/s390/kernel/trace_clock.c
new file mode 100644 (file)
index 0000000..9ca5680
--- /dev/null
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/trace_clock.h>
+#include <linux/timex.h>
+/*
+ * trace_clock_s390_tod(): trace clock based on the s390 TOD clock
+ *
+ * Unlike the other clocks, this is not in nanoseconds.
+ */
+u64 notrace trace_clock_s390_tod(void)
+{
+       return get_tod_clock();
+}