Re: [PATCH v4 2/2] rust: add tracepoint support

From
Steven Rostedt <rostedt@goodmis.org>
Date
2024-07-31 16:15:10
Also in
linux-arch, linux-riscv, lkml, loongarch, rust-for-linux
Reply to
Gary Guo, 2024-07-30
On Tue, 30 Jul 2024 11:35:27 +0100
Gary Guo [off-list ref] wrote:
quoted
+/*
+ * Declare an exported function that Rust code can call to trigger this
+ * tracepoint. This function does not include the static branch; that is done
+ * in Rust to avoid a function call when the tracepoint is disabled.
+ */
+#define DEFINE_RUST_DO_TRACE(name, proto, args)
+#define DEFINE_RUST_DO_TRACE_REAL(name, proto, args)			\
+	notrace void rust_do_trace_##name(proto)			\
+	{								\
+		__DO_TRACE(name,					\
+			TP_ARGS(args),					\
+			cpu_online(raw_smp_processor_id()), 0);		\  
I guess this doesn't support conditions. Currently the conditions are
specified during declaration and not during definition.

Would it make sense to have

	static inline void do_trace_##name(proto)
	{
		__DO_TRACE(name, TP_ARGS(args), TP_CONDITION(cond), 0);
But where is the "cond" passed in from?

I guess in the future if you want to add conditions, you would then just
add:

#define DEFINE_RUST_DO_TRACE_REAL_CONDITION(name, proto, args, cond)			\
	notrace void rust_do_trace_##name(proto)			\
	{								\
		__DO_TRACE(name,					\
			TP_ARGS(args),					\
			cpu_online(raw_smp_processor_id()) &&		\
			TP_CONDITION(cond), 0);				\  

-- Steve
	}

in `__DECLARE_TRACE` and then simply call it in `rust_do_trace_##name`?
quoted
+	}
+
 /*
Thread (13 messages) 13 messages, 7 authors, last reply 2024-08-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help