Merge tag 'trace-rust-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 25 Nov 2024 23:44:29 +0000 (15:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 25 Nov 2024 23:44:29 +0000 (15:44 -0800)
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

1  2 
MAINTAINERS
include/linux/tracepoint.h
include/trace/define_trace.h
rust/bindings/bindings_helper.h
rust/helpers/helpers.c
rust/kernel/lib.rs

diff --cc MAINTAINERS
Simple merge
@@@ -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),                          \
        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);                         \
Simple merge
  #include <linux/blk-mq.h>
  #include <linux/blk_types.h>
  #include <linux/blkdev.h>
 +#include <linux/cred.h>
  #include <linux/errname.h>
  #include <linux/ethtool.h>
 +#include <linux/file.h>
  #include <linux/firmware.h>
 +#include <linux/fs.h>
  #include <linux/jiffies.h>
+ #include <linux/jump_label.h>
  #include <linux/mdio.h>
  #include <linux/phy.h>
 +#include <linux/pid_namespace.h>
 +#include <linux/poll.h>
  #include <linux/refcount.h>
  #include <linux/sched.h>
 +#include <linux/security.h>
  #include <linux/slab.h>
+ #include <linux/tracepoint.h>
  #include <linux/wait.h>
  #include <linux/workqueue.h>
+ #include <trace/events/rust_sample.h>
  
  /* `bindgen` gets confused at certain things. */
  const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN;
  #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"
@@@ -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;