Skip to contentSkip to conversation

tracing: Latency updates for 6.15

PATCH New Steven Rostedt 1 participant 4 messages Mar 8, 2025

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Latency updates for 6.15

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
latency/for-next

Head SHA1: 41a4d2d3e3b6fe86bd54cc4c3b731378290a0d00

Gabriele Monaco (2):
tracing: Fix DECLARE_TRACE_CONDITION
rv: Add license identifiers to monitor files

Tomas Glozar (1):
trace/osnoise: Add trace events for samples

----

 include/trace/define_trace.h                    |  7 ++
 include/trace/events/osnoise.h                  | 96 +++++++++++++++++++++++++
 kernel/trace/rv/monitors/wip/Kconfig            |  2 +
 kernel/trace/rv/monitors/wip/wip.h              |  1 +
 kernel/trace/rv/monitors/wwnr/Kconfig           |  2 +
 kernel/trace/rv/monitors/wwnr/wwnr.h            |  1 +
 kernel/trace/trace_osnoise.c                    | 55 +++++---------
 tools/verification/dot2/dot2k.py                |  1 +
 tools/verification/dot2/dot2k_templates/Kconfig |  2 +
 9 files changed, 128 insertions(+), 39 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 trace/osnoise: Add trace events for samples

From: Tomas Glozar <[email protected]>

Add trace events that fire at osnoise and timerlat sample generation, in addition to the already existing noise and threshold events.

This allows processing the samples directly in the kernel, either with ftrace triggers or with BPF.

---
 include/trace/events/osnoise.h | 96 ++++++++++++++++++++++++++++++++++
 kernel/trace/trace_osnoise.c   | 55 ++++++-------------
 2 files changed, 112 insertions(+), 39 deletions(-)
include/trace/events/osnoise.h +96 -0
index a2379a4f0684..3f4273623801 100644
@@ -3,9 +3,105 @@
 #define TRACE_SYSTEM osnoise
 
 #if !defined(_OSNOISE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+
+#ifndef _OSNOISE_TRACE_H
 #define _OSNOISE_TRACE_H
+/*
+ * osnoise sample structure definition. Used to store the statistics of a
+ * sample run.
+ */
+struct osnoise_sample {
+	u64			runtime;	/* runtime */
+	u64			noise;		/* noise */
+	u64			max_sample;	/* max single noise sample */
+	int			hw_count;	/* # HW (incl. hypervisor) interference */
+	int			nmi_count;	/* # NMIs during this sample */
+	int			irq_count;	/* # IRQs during this sample */
+	int			softirq_count;	/* # softirqs during this sample */
+	int			thread_count;	/* # threads during this sample */
+};
+
+#ifdef CONFIG_TIMERLAT_TRACER
+/*
+ * timerlat sample structure definition. Used to store the statistics of
+ * a sample run.
+ */
+struct timerlat_sample {
+	u64			timer_latency;	/* timer_latency */
+	unsigned int		seqnum;		/* unique sequence */
+	int			context;	/* timer context */
+};
+#endif // CONFIG_TIMERLAT_TRACER
+#endif // _OSNOISE_TRACE_H
 
 #include <linux/tracepoint.h>
+TRACE_EVENT(osnoise_sample,
+
+	TP_PROTO(struct osnoise_sample *s),
+
+	TP_ARGS(s),
+
+	TP_STRUCT__entry(
+		__field(	u64,		runtime	)
+		__field(	u64,		noise	)
+		__field(	u64,		max_sample	)
+		__field(	int,		hw_count	)
+		__field(	int,		irq_count	)
+		__field(	int,		nmi_count	)
+		__field(	int, 		softirq_count	)
+		__field(	int,		thread_count	)
+	),
+
+	TP_fast_assign(
+		__entry->runtime = s->runtime;
+		__entry->noise = s->noise;
+		__entry->max_sample = s->max_sample;
+		__entry->hw_count = s->hw_count;
+		__entry->irq_count = s->irq_count;
+		__entry->nmi_count = s->nmi_count;
+		__entry->softirq_count = s->softirq_count;
+		__entry->thread_count = s->thread_count;
+	),
+
+	TP_printk("runtime=%llu noise=%llu max_sample=%llu hw_count=%d"
+		  " irq_count=%d nmi_count=%d softirq_count=%d"
+		  " thread_count=%d",
+		  __entry->runtime,
+		  __entry->noise,
+		  __entry->max_sample,
+		  __entry->hw_count,
+		  __entry->irq_count,
+		  __entry->nmi_count,
+		  __entry->softirq_count,
+		  __entry->thread_count)
+);
+
+#ifdef CONFIG_TIMERLAT_TRACER
+TRACE_EVENT(timerlat_sample,
+
+	TP_PROTO(struct timerlat_sample *s),
+
+	TP_ARGS(s),
+
+	TP_STRUCT__entry(
+		__field(	u64,		timer_latency	)
+		__field(	unsigned int,	seqnum		)
+		__field(	int,		context		)
+	),
+
+	TP_fast_assign(
+		__entry->timer_latency = s->timer_latency;
+		__entry->seqnum = s->seqnum;
+		__entry->context = s->context;
+	),
+
+	TP_printk("timer_latency=%llu seqnum=%u context=%d",
+		  __entry->timer_latency,
+		  __entry->seqnum,
+		  __entry->context)
+);
+#endif // CONFIG_TIMERLAT_TRACER
+
 TRACE_EVENT(thread_noise,
 
 	TP_PROTO(struct task_struct *t, u64 start, u64 duration),
kernel/trace/trace_osnoise.c +16 -39

130 lines not on this page · raw message

Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH 2/3 tracing: Fix DECLARE_TRACE_CONDITION

In reply to Steven Rostedt

From: Gabriele Monaco <[email protected]>

Commit 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()") adds macros to define conditional trace events (TRACE_EVENT_CONDITIONAL) and tracepoints (DECLARE_TRACE_CONDITION), but sets up functionality for direct use only for the former.

Add preprocessor bits in define_trace.h to allow usage of DECLARE_TRACE_CONDITION just like DECLARE_TRACE.

---
 include/trace/define_trace.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/trace/define_trace.h +7 -0
index e1c1079f8c8d..ed52d0506c69 100644
@@ -76,6 +76,10 @@
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)	\
+	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 /* If requested, create helpers for calling these tracepoints from Rust. */
 #ifdef CREATE_RUST_TRACE_POINTS
 #undef DEFINE_RUST_DO_TRACE
@@ -108,6 +112,8 @@
 /* Make all open coded DECLARE_TRACE nops */
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)
 
 #ifdef TRACEPOINTS_ENABLED
 #include <trace/trace_events.h>
@@ -129,6 +135,7 @@
 #undef DEFINE_EVENT_CONDITION
 #undef TRACE_HEADER_MULTI_READ
 #undef DECLARE_TRACE
+#undef DECLARE_TRACE_CONDITION
 
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE
Signature · 1 line
2.47.2
author maintainer
#3 lore raw

PATCH 3/3 Add license identifiers to monitor files

In reply to Steven Rostedt

From: Gabriele Monaco <[email protected]>

Some monitor files like the main header and the Kconfig are missing the license identifier.

Add it to those and make sure the automatic generation script includes the line in newly created monitors.

---
 kernel/trace/rv/monitors/wip/Kconfig            | 2 ++
 kernel/trace/rv/monitors/wip/wip.h              | 1 +
 kernel/trace/rv/monitors/wwnr/Kconfig           | 2 ++
 kernel/trace/rv/monitors/wwnr/wwnr.h            | 1 +
 tools/verification/dot2/dot2k.py                | 1 +
 tools/verification/dot2/dot2k_templates/Kconfig | 2 ++
 6 files changed, 9 insertions(+)
kernel/trace/rv/monitors/wip/Kconfig +2 -0
index 3ef664b5cd90..e464b9294865 100644
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
 config RV_MON_WIP
 	depends on RV
 	depends on PREEMPT_TRACER
kernel/trace/rv/monitors/wip/wip.h +1 -0
index 2e373f2c65ed..c7193748bf36 100644
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Automatically generated C representation of wip automaton
  * For further information about this format, see kernel documentation:
kernel/trace/rv/monitors/wwnr/Kconfig +2 -0
index ee741aa6d6b8..d3bfc20037db 100644
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
 config RV_MON_WWNR
 	depends on RV
 	select DA_MON_EVENTS_ID
kernel/trace/rv/monitors/wwnr/wwnr.h +1 -0
index d0d9c4b8121b..0a59d23edf61 100644
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Automatically generated C representation of wwnr automaton
  * For further information about this format, see kernel documentation:
tools/verification/dot2/dot2k.py +1 -0
index 7547eb290b7d..153cc14bcca4 100644
@@ -160,6 +160,7 @@ class dot2k(Dot2c):
 
     def fill_model_h_header(self):
         buff = []
+        buff.append("/* SPDX-License-Identifier: GPL-2.0 */")
         buff.append("/*")
         buff.append(" * Automatically generated C representation of %s automaton" % (self.name))
         buff.append(" * For further information about this format, see kernel documentation:")
tools/verification/dot2/dot2k_templates/Kconfig +2 -0
index 90cdc1e9379e..03100eda1707 100644
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
 config RV_MON_%%MODEL_NAME_UP%%
 	depends on RV
 	select %%MONITOR_CLASS_TYPE%%
Signature · 1 line
2.47.2