linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing/probes: Differentiate BTF support from start of function
@ 2023-07-17 20:39 Steven Rostedt
  2023-07-18  0:00 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2023-07-17 20:39 UTC (permalink / raw)
  To: Linux Trace Kernel, LKML; +Cc: Masami Hiramatsu, Mark Rutland

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Having a typo in the function name to trace one of the arguments using
BTF, gave me an error message that BTF was not supported by this kernel:

~# echo 'p:lock __raw_spin_lock lock=lock' > /sys/kernel/tracing/kprobe_events
-bash: echo: write error: Invalid argument
~# cat /sys/kernel/tracing/error_log
[   34.382149] trace_kprobe: error: BTF is not available or not supported
  Command: p:lock __raw_spin_lock lock=lock
                                       ^

I added two underscores instead of one underscore for the function
_raw_spin_lock(). But I spent too much time trying to figure out why BTF
was not supported, because in reality it was! The problem was that the
function wasn't found (this could happen if a function offset is used as
well).

Instead, add a new error message that gives a better description of the
problem.

~# echo 'p:lock __raw_spin_lock lock=lock' > /sys/kernel/tracing/kprobe_events
-bash: echo: write error: Invalid argument
~# cat /sys/kernel/tracing/error_log
[   45.922742] trace_kprobe: error: BTF arg can be used only on function entry
  Command: p:lock __raw_spin_lock lock=lock
                                       ^
Fixes: b576e09701c7d ("tracing/probes: Support function parameters if BTF is available")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_probe.c | 2 +-
 kernel/trace/trace_probe.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index cf504efd0694..328a51b1d068 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1023,7 +1023,7 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
 	default:
 		if (isalpha(arg[0]) || arg[0] == '_') {	/* BTF variable */
 			if (!tparg_is_function_entry(ctx->flags)) {
-				trace_probe_log_err(ctx->offset, NOSUP_BTFARG);
+				trace_probe_log_err(ctx->offset, NOFENTRY_BTFARG);
 				return -EINVAL;
 			}
 			ret = parse_btf_arg(arg, pcode, end, ctx);
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 604d6fb9c5ff..554fe2995ca1 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -493,6 +493,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
 	C(BAD_ATTACH_ARG,	"Attached event does not have this field"),\
 	C(NO_EP_FILTER,		"No filter rule after 'if'"),		\
 	C(NOSUP_BTFARG,		"BTF is not available or not supported"),	\
+	C(NOFENTRY_BTFARG,	"BTF arg can be used only on function entry"),	\
 	C(NO_BTFARG,		"This variable is not found at this probe point"),\
 	C(NO_BTF_ENTRY,		"No BTF entry for this probe point"),	\
 	C(BAD_VAR_ARGS,		"$arg* must be an independent parameter without name etc."),\
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-18  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 20:39 [PATCH] tracing/probes: Differentiate BTF support from start of function Steven Rostedt
2023-07-18  0:00 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).