Skip to contentSkip to conversation

tracing: Fixes and updates for 6.0

PATCH New Steven Rostedt 1 participant 8 messages Sep 7, 2022

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Fixes and updates for 6.0

Alison Schofield (1):
tracepoint: Allow trace events in modules with TAINT_TEST

Daniel Bristot de Oliveira (2):
rv/monitors: Make monitor's automata definition static
MAINTAINERS: Add Runtime Verification (RV) entry

Lukas Bulwahn (1):
MAINTAINERS: add scripts/tracing/ to TRACING

Masami Hiramatsu (Google) (1):
tracing: Fix to check event_mutex is held while accessing trigger list

Xiu Jianfeng (1):
rv/reactor: add __init/__exit annotations to module init/exit funcs

Yipeng Zou (1):
tracing: hold caller_addr to hardirq_{enable,disable}_ip

----

 MAINTAINERS                          | 12 ++++++++++++
 kernel/trace/rv/monitors/wip/wip.h   |  2 +-
 kernel/trace/rv/monitors/wwnr/wwnr.h |  2 +-
 kernel/trace/rv/reactor_panic.c      |  4 ++--
 kernel/trace/rv/reactor_printk.c     |  4 ++--
 kernel/trace/trace_events_trigger.c  |  3 ++-
 kernel/trace/trace_preemptirq.c      |  4 ++--
 kernel/tracepoint.c                  |  5 +++--
 8 files changed, 25 insertions(+), 11 deletions(-)
author maintainer
#1 lore raw

PATCH 1/7 rv/monitors: Make monitors automata definition static

From: Daniel Bristot de Oliveira <[email protected]>

Monitor's automata definition is only used locally, so make them static for all existing monitors.

Fixes ccc319dcb450 ("rv/monitor: Add the wwnr monitor")
Fixes 8812d21219b9 ("rv/monitor: Add the wip monitor skeleton created by dot2k")
---
 kernel/trace/rv/monitors/wip/wip.h   | 2 +-
 kernel/trace/rv/monitors/wwnr/wwnr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/trace/rv/monitors/wip/wip.h +1 -1
index c1c47e2305ef..dacc37b62a2c 100644
@@ -27,7 +27,7 @@ struct automaton_wip {
 	bool final_states[state_max_wip];
 };
 
-struct automaton_wip automaton_wip = {
+static struct automaton_wip automaton_wip = {
 	.state_names = {
 		"preemptive",
 		"non_preemptive"
kernel/trace/rv/monitors/wwnr/wwnr.h +1 -1
index d1afe55cdd4c..118e576b91b4 100644
@@ -27,7 +27,7 @@ struct automaton_wwnr {
 	bool final_states[state_max_wwnr];
 };
 
-struct automaton_wwnr automaton_wwnr = {
+static struct automaton_wwnr automaton_wwnr = {
 	.state_names = {
 		"not_running",
 		"running"
Signature · 1 line
2.35.1
author maintainer
#2 lore raw

PATCH 2/7 MAINTAINERS: Add Runtime Verification (RV) entry

In reply to Steven Rostedt

From: Daniel Bristot de Oliveira <[email protected]>

Add a Runtime Verification (RV) entry in the MAINTAINERS file with Steven Rostedt and myself as maintainers.

---
 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index d30f26e07cd3..b89b70af0b07 100644
@@ -17735,6 +17735,17 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/infiniband/ulp/rtrs/
 
+RUNTIME VERIFICATION (RV)
+M:	Daniel Bristot de Oliveira <[email protected]>
+M:	Steven Rostedt <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/trace/rv/
+F:	include/linux/rv.h
+F:	include/rv/
+F:	kernel/trace/rv/
+F:	tools/verification/
+
 RXRPC SOCKETS (AF_RXRPC)
 M:	David Howells <[email protected]>
 M:	Marc Dionne <[email protected]>
Signature · 1 line
2.35.1
author maintainer
#3 lore raw

PATCH 3/7 MAINTAINERS: add scripts/tracing/ to TRACING

In reply to Steven Rostedt

From: Lukas Bulwahn <[email protected]>

The files in scripts/tracing/ belong to the TRACING subsystem.

Add a corresponding file entry for TRACING.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index b89b70af0b07..93ffebc3e6c0 100644
@@ -20612,6 +20612,7 @@ F:	include/*/ftrace.h
 F:	include/linux/trace*.h
 F:	include/trace/
 F:	kernel/trace/
+F:	scripts/tracing/
 F:	tools/testing/selftests/ftrace/
 
 TRACING MMIO ACCESSES (MMIOTRACE)
Signature · 1 line
2.35.1
author maintainer
#4 lore raw

PATCH 4/7 tracepoint: Allow trace events in modules with TAINT_TEST

In reply to Steven Rostedt

From: Alison Schofield <[email protected]>

Commit 2852ca7fba9f ("panic: Taint kernel if tests are run") introduced a new taint type, TAINT_TEST, to signal that an in-kernel test module has been loaded.

TAINT_TEST taint type defaults into a 'bad_taint' list for kernel tracing and blocks the creation of trace events. This causes a problem for CXL testing where loading the cxl_test module makes all CXL modules out-of-tree, blocking any trace events.

Trace events are in development for CXL at the moment and this issue was found in test with v6.0-rc1.

---
 kernel/tracepoint.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/tracepoint.c +3 -2
index 64ea283f2f86..ef42c1a11920 100644
@@ -571,7 +571,8 @@ static void for_each_tracepoint_range(
 bool trace_module_has_bad_taint(struct module *mod)
 {
 	return mod->taints & ~((1 << TAINT_OOT_MODULE) | (1 << TAINT_CRAP) |
-			       (1 << TAINT_UNSIGNED_MODULE));
+			       (1 << TAINT_UNSIGNED_MODULE) |
+			       (1 << TAINT_TEST));
 }
 
 static BLOCKING_NOTIFIER_HEAD(tracepoint_notify_list);
@@ -647,7 +648,7 @@ static int tracepoint_module_coming(struct module *mod)
 	/*
 	 * We skip modules that taint the kernel, especially those with different
 	 * module headers (for forced load), to make sure we don't cause a crash.
-	 * Staging, out-of-tree, and unsigned GPL modules are fine.
+	 * Staging, out-of-tree, unsigned GPL, and test modules are fine.
 	 */
 	if (trace_module_has_bad_taint(mod))
 		return 0;
Signature · 1 line
2.35.1
author maintainer
#5 lore raw

PATCH 5/7 tracing: hold caller_addr to hardirq_{enable,disable}_ip

In reply to Steven Rostedt

From: Yipeng Zou <[email protected]>

Currently, The arguments passing to lockdep_hardirqs_{on,off} was fixed in CALLER_ADDR0.
The function trace_hardirqs_on_caller should have been intended to use caller_addr to represent the address that caller wants to be traced.

For example, lockdep log in riscv showing the last {enabled,disabled} at __trace_hardirqs_{on,off} all the time(if called by):

[   57.853175] hardirqs last  enabled at (2519): __trace_hardirqs_on+0xc/0x14
[   57.853848] hardirqs last disabled at (2520): __trace_hardirqs_off+0xc/0x14

After use trace_hardirqs_xx_caller, we can get more effective information:

[   53.781428] hardirqs last  enabled at (2595): restore_all+0xe/0x66
[   53.782185] hardirqs last disabled at (2596): ret_from_exception+0xa/0x10
Fixes c3bc8fd637a96 ("tracing: Centralize preemptirq tracepoints and unify their usage")
---
 kernel/trace/trace_preemptirq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_preemptirq.c +2 -2
index 95b58bd757ce..1e130da1b742 100644
@@ -95,14 +95,14 @@ __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
 	}
 
 	lockdep_hardirqs_on_prepare();
-	lockdep_hardirqs_on(CALLER_ADDR0);
+	lockdep_hardirqs_on(caller_addr);
 }
 EXPORT_SYMBOL(trace_hardirqs_on_caller);
 NOKPROBE_SYMBOL(trace_hardirqs_on_caller);
 
 __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
 {
-	lockdep_hardirqs_off(CALLER_ADDR0);
+	lockdep_hardirqs_off(caller_addr);
 
 	if (!this_cpu_read(tracing_irq_cpu)) {
 		this_cpu_write(tracing_irq_cpu, 1);
Signature · 1 line
2.35.1
author maintainer
#6 lore raw

PATCH 6/7 tracing: Fix to check event_mutex is held while accessing trigger list

In reply to Steven Rostedt

From: "Masami Hiramatsu (Google)" <[email protected]>

Since the check_user_trigger() is called outside of RCU read lock, this list_for_each_entry_rcu() caused a suspicious RCU usage warning.

 # echo hist:keys=pid > events/sched/sched_stat_runtime/trigger
 # cat events/sched/sched_stat_runtime/trigger
[   43.167032]
[   43.167418] =============================
[   43.167992] WARNING: suspicious RCU usage
[   43.168567] 5.19.0-rc5-00029-g19ebe4651abf #59 Not tainted
[   43.169283] -----------------------------
[   43.169863] kernel/trace/trace_events_trigger.c:145 RCU-list traversed in non-reader section!!
...

However, this file->triggers list is safe when it is accessed under event_mutex is held.
To fix this warning, adds a lockdep_is_held check to the list_for_each_entry_rcu().

Fixes 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
---
 kernel/trace/trace_events_trigger.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_events_trigger.c +2 -1
index cb866c3141af..918730d74932 100644
@@ -142,7 +142,8 @@ static bool check_user_trigger(struct trace_event_file *file)
 {
 	struct event_trigger_data *data;
 
-	list_for_each_entry_rcu(data, &file->triggers, list) {
+	list_for_each_entry_rcu(data, &file->triggers, list,
+				lockdep_is_held(&event_mutex)) {
 		if (data->flags & EVENT_TRIGGER_FL_PROBE)
 			continue;
 		return true;
Signature · 1 line
2.35.1
author maintainer
#7 lore raw

PATCH 7/7 rv/reactor: add __init/__exit annotations to module init/exit funcs

In reply to Steven Rostedt

From: Xiu Jianfeng <[email protected]>

Add missing __init/__exit annotations to module init/exit funcs.

Fixes 135b881ea885 ("rv/reactor: Add the printk reactor")
Fixes e88043c0ac16 ("rv/reactor: Add the panic reactor")
---
 kernel/trace/rv/reactor_panic.c  | 4 ++--
 kernel/trace/rv/reactor_printk.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/trace/rv/reactor_panic.c +2 -2
index b698d05dd069..d65f6c25a87c 100644
@@ -24,13 +24,13 @@ static struct rv_reactor rv_panic = {
 	.react = rv_panic_reaction
 };
 
-static int register_react_panic(void)
+static int __init register_react_panic(void)
 {
 	rv_register_reactor(&rv_panic);
 	return 0;
 }
 
-static void unregister_react_panic(void)
+static void __exit unregister_react_panic(void)
 {
 	rv_unregister_reactor(&rv_panic);
 }
kernel/trace/rv/reactor_printk.c +2 -2
index 31899f953af4..4b6b7106a477 100644
@@ -23,13 +23,13 @@ static struct rv_reactor rv_printk = {
 	.react = rv_printk_reaction
 };
 
-static int register_react_printk(void)
+static int __init register_react_printk(void)
 {
 	rv_register_reactor(&rv_printk);
 	return 0;
 }
 
-static void unregister_react_printk(void)
+static void __exit unregister_react_printk(void)
 {
 	rv_unregister_reactor(&rv_printk);
 }
Signature · 1 line
2.35.1