From: Linus Torvalds Date: Mon, 25 Nov 2024 23:44:29 +0000 (-0800) Subject: Merge tag 'trace-rust-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace... X-Git-Tag: microblaze-v6.16~554 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=7f4f3b14e8079ecde096bd734af10e30d40c27b7;p=linux-2.6-microblaze.git Merge tag 'trace-rust-v6.13' of git://git./linux/kernel/git/trace/linux-trace Pull rust trace event support from Steven Rostedt: "Allow Rust code to have trace events Trace events is a popular way to debug what is happening inside the kernel or just to find out what is happening. Rust code is being added to the Linux kernel but it currently does not support the tracing infrastructure. Add support of trace events inside Rust code" * tag 'trace-rust-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rust: jump_label: skip formatting generated file jump_label: rust: pass a mut ptr to `static_key_count` samples: rust: fix `rust_print` build making it a combined module rust: add arch_static_branch jump_label: adjust inline asm to be consistent rust: samples: add tracepoint to Rust sample rust: add tracepoint support rust: add static_branch_unlikely for static_key_false --- 7f4f3b14e8079ecde096bd734af10e30d40c27b7 diff --cc include/linux/tracepoint.h index 425123e921ac,84c4924e499f..6073a8c7e38c --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@@ -299,9 -304,14 +318,15 @@@ static inline struct tracepoint *tracep #define __DECLARE_TRACE_SYSCALL(name, proto, args, cond, data_proto) \ __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ + static inline void __rust_do_trace_##name(proto) \ + { \ + __DO_TRACE(name, \ + TP_ARGS(args), \ + TP_CONDITION(cond), 1); \ + } \ static inline void trace_##name(proto) \ { \ + might_fault(); \ if (static_branch_unlikely(&__tracepoint_##name.key)) \ __DO_TRACE(name, \ TP_ARGS(args), \ @@@ -354,26 -364,11 +379,27 @@@ void __probestub_##_name(void *__data, proto) \ { \ } \ - DEFINE_STATIC_CALL(tp_func_##_name, __traceiter_##_name); + DEFINE_STATIC_CALL(tp_func_##_name, __traceiter_##_name); \ + DEFINE_RUST_DO_TRACE(_name, TP_PROTO(proto), TP_ARGS(args)) -#define DEFINE_TRACE(name, proto, args) \ - DEFINE_TRACE_FN(name, NULL, NULL, PARAMS(proto), PARAMS(args)); +#define DEFINE_TRACE_FN(_name, _reg, _unreg, _proto, _args) \ + static struct tracepoint_ext __tracepoint_ext_##_name = { \ + .regfunc = _reg, \ + .unregfunc = _unreg, \ + .faultable = false, \ + }; \ + __DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args)); + +#define DEFINE_TRACE_SYSCALL(_name, _reg, _unreg, _proto, _args) \ + static struct tracepoint_ext __tracepoint_ext_##_name = { \ + .regfunc = _reg, \ + .unregfunc = _unreg, \ + .faultable = true, \ + }; \ + __DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args)); + +#define DEFINE_TRACE(_name, _proto, _args) \ + __DEFINE_TRACE_EXT(_name, NULL, PARAMS(_proto), PARAMS(_args)); #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \ EXPORT_SYMBOL_GPL(__tracepoint_##name); \ diff --cc rust/bindings/bindings_helper.h index ca13659ded4c,b072c197ce9e..0e9fee0a4a27 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@@ -10,23 -10,20 +10,26 @@@ #include #include #include +#include #include #include +#include #include +#include #include + #include #include #include +#include +#include #include #include +#include #include + #include #include #include + #include /* `bindgen` gets confused at certain things. */ const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; diff --cc rust/helpers/helpers.c index 62022b18caf5,17e1b60d178f..463b970154de --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@@ -11,9 -11,8 +11,10 @@@ #include "bug.c" #include "build_assert.c" #include "build_bug.c" +#include "cred.c" #include "err.c" +#include "fs.c" + #include "jump_label.c" #include "kunit.c" #include "mutex.c" #include "page.c" diff --cc rust/kernel/lib.rs index 9843eedd4293,97286b99270e..29947bb8593b --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@@ -35,9 -34,9 +35,10 @@@ pub mod device pub mod error; #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] pub mod firmware; +pub mod fs; pub mod init; pub mod ioctl; + pub mod jump_label; #[cfg(CONFIG_KUNIT)] pub mod kunit; pub mod list;