Tracepoints and static branch in Rust
Subsystems (7)
Alice Ryhl
maintainerv3 cover Tracepoints and static branch in Rust
An important part of a production ready Linux kernel driver is tracepoints. So to write production ready Linux kernel drivers in Rust, we must be able to call tracepoints from Rust code. This patch series adds support for calling tracepoints declared in C from Rust.
To use the tracepoint support, you must:
1. Declare the tracepoint in a C header file as usual.
2. Add #define CREATE_RUST_TRACE_POINTS next to your #define CREATE_TRACE_POINTS.
2. Make sure that the header file is visible to bindgen.
3. Use the declare_trace! macro in your Rust code to generate Rust functions that call into the tracepoint.
For example, the kernel has a tracepoint called sched_kthread_stop. It is declared like this:
TRACE_EVENT(sched_kthread_stop,
TP_PROTO(struct task_struct *t),
TP_ARGS(t),
TP_STRUCT__entry(
__array( char, comm, TASK_COMM_LEN )
__field( pid_t, pid )
),
TP_fast_assign(
memcpy(__entry->comm, t->comm, TASK_COMM_LEN);
__entry->pid = t->pid;
),
TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
);To call the above tracepoint from Rust code, you must first ensure that the Rust helper for the tracepoint is generated. To do this, you would modify kernel/sched/core.c by adding #define CREATE_RUST_TRACE_POINTS.
Next, you would include include/trace/events/sched.h in rust/bindings/bindings_helper.h so that the exported C functions are visible to Rust, and then you would declare the tracepoint in Rust:
declare_trace! {
fn sched_kthread_stop(task: *mut task_struct);
}This will define an inline Rust function that checks the static key, calling into rust_do_trace_##name if the tracepoint is active. Since these tracepoints often take raw pointers as arguments, it may be convenient to wrap it in a safe wrapper:
mod raw {
declare_trace! {
fn sched_kthread_stop(task: *mut task_struct);
}
}
#[inline]
pub fn trace_sched_kthread_stop(task: &Task) {
// SAFETY: The pointer to `task` is valid.
unsafe { raw::sched_kthread_stop(task.as_raw()) }
}A future expansion of the tracepoint support could generate these safe versions automatically, but that is left as future work for now.
This is intended for use in the Rust Binder driver, which was originally sent as an RFC [1]. The RFC did not include tracepoint support, but you can see how it will be used in Rust Binder at [2]. The author has verified that the tracepoint support works on Android devices.
This implementation implements support for static keys in Rust so that the actual static branch happens in the Rust object file. However, the __DO_TRACE body remains in C code. See v1 for an implementation where __DO_TRACE is also implemented in Rust.
---
Changes in v3:
- Support for Rust static_key on loongarch64 and riscv64.
- Avoid failing compilation on architectures that are missing Rust static_key support when the archtectures does not actually use it.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Call into C code for __DO_TRACE.
- Drop static_call patch, as it is no longer needed.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Alice Ryhl (2):
rust: add static_key_false
rust: add tracepoint support
include/linux/tracepoint.h | 18 ++++- include/trace/define_trace.h | 7 ++ rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 2 + rust/kernel/static_key.rs | 143 ++++++++++++++++++++++++++++++++++++++++ rust/kernel/tracepoint.rs | 47 +++++++++++++ scripts/Makefile.build | 2 +- 7 files changed, 218 insertions(+), 2 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240606-tracepoint-31e15b90e471
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
maintainerPATCH v3 1/2 rust: add static_key_false
Add just enough support for static key so that we can use it from tracepoints. Tracepoints rely on static_key_false even though it is deprecated, so we add the same functionality to Rust.
It is not possible to use the existing C implementation of arch_static_branch because it passes the argument key to inline assembly as an 'i' parameter, so any attempt to add a C helper for this function will fail to compile because the value of key must be known at compile-time.
--- rust/kernel/lib.rs | 1 + rust/kernel/static_key.rs | 143 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 2 +- 3 files changed, 145 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +1 -0
@@ -38,6 +38,7 @@pub mod prelude;pub mod print;mod static_assert; +pub mod static_key;#[doc(hidden)] pub mod std_vendor;pub mod str;
rust/kernel/static_key.rs new file +143 -0
143 lines not on this page · raw message
scripts/Makefile.build +1 -1
@@ -263,7 +263,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := new_uninit +rust_allowed_features := asm_const,asm_goto,new_uninit # `--out-dir` is required to avoid temporaries being created by `rustc` in the # current working directory, which may be not accessible in the out-of-tree
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
Re: [PATCH v3 1/2] rust: add static_key_false
Hi Alice,
Quoted 11 lines · Alice Ryhl
Add just enough support for static key so that we can use it from tracepoints. Tracepoints rely on
static_key_falseeven though it is deprecated, so we add the same functionality to Rust.It is not possible to use the existing C implementation of
arch_static_branchbecause it passes the argumentkeyto inline assembly as an 'i' parameter, so any attempt to add a C helper for this function will fail to compile because the value ofkeymust be known at compile-time.Signed-off-by Alice Ryhl <[email protected]>
[Add linux-arch, and related arch maintainers Cced]
Since inline asms are touched here, please consider copying linux-arch and arch maintainers next time ;-)
Quoted 75 lines
--- rust/kernel/lib.rs | 1 + rust/kernel/static_key.rs | 143 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 2 +- 3 files changed, 145 insertions(+), 1 deletion(-)rust/kernel/lib.rs +1
-0@@ -38,6 +38,7 @@pub mod prelude;pub mod print;mod static_assert; +pub mod static_key;#[doc(hidden)] pub mod std_vendor;pub mod str;rust/kernel/static_key.rs new file +51
-0@@ -0,0 +1,143 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Copyright (C) 2024 Google LLC. + +//! Logic for static keys. + +use crate ::bindings::*; + +#[doc(hidden)] +#[macro_export] +#[cfg(target_arch = "x86_64" )] +macro_rules! _static_key_false { + ($key:path, $keytyp:ty, $field:ident) => {'my_label: { + core::arch::asm!( +r#" +1: .byte 0x0f,0x1f,0x44,0x00,0x00 + +.pushsection __jump_table, "aw" +.balign 8 +.long 1b - . +.long {0} - . +.quad {1} + {2} - . +.popsection +"# , +label { +break 'my_labeltrue ; + }, + sym $key, +const ::core::mem::offset_of!($keytyp, $field), + ); + +break 'my_labelfalse ; + }}; +} + +#[doc(hidden)] +#[macro_export] +#[cfg(target_arch = "aarch64" )] +macro_rules! _static_key_false { + ($key:path, $keytyp:ty, $field:ident) => {'my_label: { + core::arch::asm!( +r#" +1: nop + +.pushsection __jump_table, "aw" +.align 3 +.long 1b - ., {0} - . +.quad {1} + {2} - . +.popsection +"# , +label {
rust/kernel/static_key.rs line 61
Quoted 10 lines
rust/kernel/static_key.rs new file +10
-0+break 'my_labeltrue ; + }, + sym $key, + const ::core::mem::offset_of!($keytyp, $field), + ); + +break 'my_labelfalse ; + }}; +} +
For x86_64 and arm64 bits:
One thing though, we should split the arch-specific impls into different files, for example: rust/kernel/arch/arm64.rs or rust/arch/arm64.rs. That'll be easier for arch maintainers to watch the Rust changes related to a particular architecture.
Another thought is that, could you implement an arch_static_branch!() (instead of _static_key_false!()) and use it for static_key_false!() similar to what we have in C? The benefit is that at least for myself it'll be easier to compare the implementation between C and Rust.
Regards,
Boqun
Quoted 99 lines
rust/kernel/static_key.rs new file +82
-0+#[doc(hidden)] +#[macro_export] +#[cfg(target_arch = "loongarch64" )] +macro_rules! _static_key_false { + ($key:path, $keytyp:ty, $field:ident) => {'my_label: { + core::arch::asm!( +r#" +1: nop + +.pushsection __jump_table, "aw" +.align 3 +.long 1b - ., {0} - . +.quad {1} + {2} - . +.popsection +"# , +label { +break 'my_labeltrue ; + }, + sym $key, +const ::core::mem::offset_of!($keytyp, $field), + ); + +break 'my_labelfalse ; + }}; +} + +#[doc(hidden)] +#[macro_export] +#[cfg(target_arch = "riscv64" )] +macro_rules! _static_key_false { + ($key:path, $keytyp:ty, $field:ident) => {'my_label: { + core::arch::asm!( +r#" +.align 2 +.option push +.option norelax +.option norvc +1: nop +.option pop +.pushsection __jump_table, "aw" +.align 3 +.long 1b - ., {0} - . +.dword {1} + {2} - . +.popsection +"# , +label { +break 'my_labeltrue ; + }, + sym $key, +const ::core::mem::offset_of!($keytyp, $field), + ); + +break 'my_labelfalse ; + }}; +} + +/// Branch based on a static key. +/// +/// Takes three arguments: +/// +/// * `key` - the path to the static variable containing the `static_key`. +/// * `keytyp` - the type of `key`. +/// * `field` - the name of the field of `key` that contains the `static_key`. +#[macro_export] +macro_rules! static_key_false { +// Forward to the real implementation. Separated like this so that we don't have to duplicate +// the documentation. + ($key:path, $keytyp:ty, $field:ident) => {{ +// Assert that `$key` has type `$keytyp` and that `$key.$field` has type `static_key`. +// +// SAFETY: We know that `$key` is a static because otherwise the inline assembly will not +// compile. The raw pointers created in this block are in-bounds of `$key`. +static _TY_ASSERT: () =unsafe { +let key: *const $keytyp = ::core::ptr::addr_of!($key); +let _: *const $crate::bindings::static_key = ::core::ptr::addr_of!((*key).$field); + }; + + $crate::_static_key_false! { $key, $keytyp, $field } + }}; +} + +pub use static_key_false;scripts/Makefile.build +1
-1@@ -263,7 +263,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := new_uninit +rust_allowed_features := asm_const,asm_goto,new_uninit # `--out-dir` is required to avoid temporaries being created by `rustc` in the # current working directory, which may be not accessible in the out-of-treeSignature · 2 lines
-- 2.45.2.741.gdbec12cfda-goog
Alice Ryhl
maintainerRe: [PATCH v3 1/2] rust: add static_key_false
Quoted 14 lines · Boqun Feng
Hi Alice,
Quoted 10 lines · Alice Ryhl
Add just enough support for static key so that we can use it from tracepoints. Tracepoints rely on
static_key_falseeven though it is deprecated, so we add the same functionality to Rust.It is not possible to use the existing C implementation of
arch_static_branchbecause it passes the argumentkeyto inline assembly as an 'i' parameter, so any attempt to add a C helper for this function will fail to compile because the value ofkeymust be known at compile-time.
Quoted 6 lines
Quoted 1 line
Signed-off-by Alice Ryhl <[email protected]>[Add linux-arch, and related arch maintainers Cced]
Since inline asms are touched here, please consider copying linux-arch and arch maintainers next time ;-)
Will do.
Quoted 8 lines
For
x86_64and arm64 bits:Acked-by Boqun Feng <[email protected]>One thing though, we should split the arch-specific impls into different files, for example:
rust/kernel/arch/arm64.rsorrust/arch/arm64.rs. That'll be easier for arch maintainers to watch the Rust changes related to a particular architecture.
Is that how you would prefer to name these files? You don't want static_key somewhere in the filename?
Quoted 4 lines
Another thought is that, could you implement an arch_static_branch!() (instead of _static_key_false!()) and use it for static_key_false!() similar to what we have in C? The benefit is that at least for myself it'll be easier to compare the implementation between C and Rust.
I can try to include that.
Alice
Re: [PATCH v3 1/2] rust: add static_key_false
Quoted 28 lines · Alice Ryhl
Quoted 14 lines · Boqun Feng
Hi Alice,
Quoted 10 lines · Alice Ryhl
Add just enough support for static key so that we can use it from tracepoints. Tracepoints rely on
static_key_falseeven though it is deprecated, so we add the same functionality to Rust.It is not possible to use the existing C implementation of
arch_static_branchbecause it passes the argumentkeyto inline assembly as an 'i' parameter, so any attempt to add a C helper for this function will fail to compile because the value ofkeymust be known at compile-time.Quoted 6 lines
Quoted 1 line
Signed-off-by Alice Ryhl <[email protected]>[Add linux-arch, and related arch maintainers Cced]
Since inline asms are touched here, please consider copying linux-arch and arch maintainers next time ;-)
Will do.
Quoted 4 lines
For
x86_64and arm64 bits:Acked-by Boqun Feng <[email protected]>
Quoted 8 lines
Quoted 4 lines
One thing though, we should split the arch-specific impls into different files, for example:
rust/kernel/arch/arm64.rsorrust/arch/arm64.rs. That'll be easier for arch maintainers to watch the Rust changes related to a particular architecture.Is that how you would prefer to name these files? You don't want
static_keysomewhere in the filename?
I could have been more explicit. My preference is (for example ARM64)
* we have a rust/kernel/arch.rs, where we do:
#[cfg(CONFIG_ARM64)] mod arm64::*; #[cfg(CONFIG_ARM64)] pub use arm64::*;
* we have a rust/kernel/arch/arm64.rs:
pub(crate) mod jump_label;
* we have a rust/kernel/arch/arm64/jump_label.rs, where we put
ARM64 arch_static_branch() there. (or static_key.rs and arch_static_key_false()).
Then linux-arch can watch:
rust/kernel/arch.rs
rust/kernel/arch/
And ARM64 maintainers can watch:
rust/kernel/arch/arm64.rs
rust/kernel/arch/arm64
This is similar to how <asm/*.h> are organized today.
Does this make sense?
Regards,
Boqun
Quoted 8 lines
Quoted 4 lines
Another thought is that, could you implement an arch_static_branch!() (instead of _static_key_false!()) and use it for static_key_false!() similar to what we have in C? The benefit is that at least for myself it'll be easier to compare the implementation between C and Rust.
I can try to include that.
Alice
Alice Ryhl
maintainerPATCH v3 2/2 rust: add tracepoint support
In reply to Alice RyhlMake it possible to have Rust code call into tracepoints defined by C code. It is still required that the tracepoint is declared in a C header, and that this header is included in the input to bindgen.
--- include/linux/tracepoint.h | 18 +++++++++++++++- include/trace/define_trace.h | 7 ++++++ rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/tracepoint.rs | 47 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-)
include/linux/tracepoint.h +17 -1
@@ -238,6 +238,20 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define __DECLARE_TRACE_RCU (name, proto, args, cond)#endif +/* +* 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); \ + } +/* * Make sure the alignment of the structure in the __tracepoints section will * not add unwanted padding between the beginning of the section and the
@@ -253,6 +267,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) extern int __traceiter_##name(data_proto); \ DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ extern struct tracepoint __tracepoint_##name; \ + extern void rust_do_trace_##name(proto); \ static inline void trace_##name(proto) \ { \ if (static_key_false(&__tracepoint_##name.key)) \
@@ -337,7 +352,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) 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));
include/trace/define_trace.h +7 -0
@@ -72,6 +72,13 @@#define DECLARE_TRACE (name, proto, args) \ DEFINE_TRACE(name, PARAMS(proto), PARAMS(args)) +/* If requested, create helpers for calling these tracepoints from Rust. */ +#ifdef CREATE_RUST_TRACE_POINTS +#undef DEFINE_RUST_DO_TRACE +#define DEFINE_RUST_DO_TRACE (name, proto, args) \ + DEFINE_RUST_DO_TRACE_REAL(name, PARAMS(proto), PARAMS(args)) +#endif +#undef TRACE_INCLUDE#undef __TRACE_INCLUDE
rust/bindings/bindings_helper.h +1 -0
@@ -15,6 +15,7 @@#include <linux/refcount.h> #include <linux/sched.h> #include <linux/slab.h> +#include <linux/tracepoint.h> #include <linux/wait.h> #include <linux/workqueue.h>
rust/kernel/lib.rs +1 -0
@@ -45,6 +45,7 @@pub mod sync;pub mod task;pub mod time; +pub mod tracepoint;pub mod types;pub mod workqueue;
rust/kernel/tracepoint.rs new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
Alice Ryhl
maintainerRe: [PATCH v3 2/2] rust: add tracepoint support
rust/bindings/bindings_helper.h
Quoted 76 lines · Alice Ryhl
Make it possible to have Rust code call into tracepoints defined by C code. It is still required that the tracepoint is declared in a C header, and that this header is included in the input to bindgen.
Signed-off-by Alice Ryhl <[email protected]>--- include/linux/tracepoint.h | 18 +++++++++++++++- include/trace/define_trace.h | 7 ++++++ rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/tracepoint.rs | 47 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-)include/linux/tracepoint.h +17
-1@@ -238,6 +238,20 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define __DECLARE_TRACE_RCU (name, proto, args, cond)#endif +/* +* 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); \ + } +/* * Make sure the alignment of the structure in the __tracepoints section will * not add unwanted padding between the beginning of the section and the @@ -253,6 +267,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) extern int __traceiter_##name(data_proto); \ DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ extern struct tracepoint __tracepoint_##name; \ + extern void rust_do_trace_##name(proto); \ static inline void trace_##name(proto) \ { \ if (static_key_false(&__tracepoint_##name.key)) \@@ -337,7 +352,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) 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));include/trace/define_trace.h +7
-0@@ -72,6 +72,13 @@#define DECLARE_TRACE (name, proto, args) \ DEFINE_TRACE(name, PARAMS(proto), PARAMS(args)) +/* If requested, create helpers for calling these tracepoints from Rust. */ +#ifdef CREATE_RUST_TRACE_POINTS +#undef DEFINE_RUST_DO_TRACE +#define DEFINE_RUST_DO_TRACE (name, proto, args) \ + DEFINE_RUST_DO_TRACE_REAL(name, PARAMS(proto), PARAMS(args)) +#endif +#undef TRACE_INCLUDE#undef __TRACE_INCLUDErust/bindings/bindings_helper.h +0
-0
Hmm, I tried using the support where I have both events and hooks:
#define CREATE_TRACE_POINTS
#define CREATE_RUST_TRACE_POINTS
#include <trace/hooks/rust_binder.h>
#include <trace/events/rust_binder.h>
But it's not really working. Initially I thought that it's because I need to undef DEFINE_RUST_DO_TRACE at the end of this file, but even when I added that, I still get this error:
error: redefinition of 'str__rust_binder__trace_system_name'
Is the Rust support missing something, or is the answer just that you can't have two files of the same name like this? Or am I doing something else wrong?
Alice
Re: [PATCH v3 2/2] rust: add tracepoint support
On Fri, Jun 21, 2024 at 02:52:10PM +0200, Alice Ryhl wrote:
[...]
Quoted 12 lines
Hmm, I tried using the support where I have both events and hooks:
#define
CREATE_TRACE_POINTS
#defineCREATE_RUST_TRACE_POINTS
#include <trace/hooks/rust_binder.h>
#include <trace/events/rust_binder.h>But it's not really working. Initially I thought that it's because I need to undef
DEFINE_RUST_DO_TRACEat the end of this file, but even when I added that, I still get this error:
Quoted 6 lines
error: redefinition of '
str__rust_binder__trace_system_name'Is the Rust support missing something, or is the answer just that you can't have two files of the same name like this? Or am I doing something else wrong?
Because your hooks/rust_binder.h and events/rust_binder.h use the same TRACE_SYSTEM name? Could you try something like:
#define TRACE_SYSTEM rust_binder_hook
in your hooks/rust_binder.h?
Regards,
Boqun
Quoted 1 line
Alice
Alice Ryhl
maintainerRe: [PATCH v3 2/2] rust: add tracepoint support
Quoted 22 lines · Boqun Feng
On Fri, Jun 21, 2024 at 02:52:10PM +0200, Alice Ryhl wrote:
[...]Quoted 12 lines
Hmm, I tried using the support where I have both events and hooks:
#define
CREATE_TRACE_POINTS
#defineCREATE_RUST_TRACE_POINTS
#include <trace/hooks/rust_binder.h>
#include <trace/events/rust_binder.h>But it's not really working. Initially I thought that it's because I need to undef
DEFINE_RUST_DO_TRACEat the end of this file, but even when I added that, I still get this error:Quoted 6 lines
error: redefinition of '
str__rust_binder__trace_system_name'Is the Rust support missing something, or is the answer just that you can't have two files of the same name like this? Or am I doing something else wrong?
Quoted 6 lines
Because your
hooks/rust_binder.handevents/rust_binder.huse the sameTRACE_SYSTEMname? Could you try something like:#define TRACE_SYSTEM rust_binder_hookin your
hooks/rust_binder.h?
I was able to get it to work by moving the includes into two different .c files. I don't think changing TRACE_SYSTEM works because it must match the filename.
Alice
Steven Rostedt
maintainerRe: [PATCH v3 2/2] rust: add tracepoint support
Quoted 11 lines · On Wed, 26 Jun 2024 10:48:23 +0200 Alice Ryhl <[email protected]> wrote:
Quoted 7 lines
Because your
hooks/rust_binder.handevents/rust_binder.huse the sameTRACE_SYSTEMname? Could you try something like:#define TRACE_SYSTEM rust_binder_hookin your
hooks/rust_binder.h?I was able to get it to work by moving the includes into two different .c files. I don't think changing
TRACE_SYSTEMworks because it must match the filename.
Try to use:
#define TRACE_SYSTEM_VAR rust_binder_hook_other_name
in one. Then that is used as the variable for that file.
-- Steve
Alice Ryhl
maintainerRe: [PATCH v3 2/2] rust: add tracepoint support
Quoted 16 lines · Steven Rostedt
Quoted 11 lines · On Wed, 26 Jun 2024 10:48:23 +0200 Alice Ryhl <[email protected]> wrote:
Quoted 7 lines
Because your
hooks/rust_binder.handevents/rust_binder.huse the sameTRACE_SYSTEMname? Could you try something like:#define TRACE_SYSTEM rust_binder_hookin your
hooks/rust_binder.h?I was able to get it to work by moving the includes into two different .c files. I don't think changing
TRACE_SYSTEMworks because it must match the filename.
Quoted 5 lines
Try to use:
#define
TRACE_SYSTEM_VARrust_binder_hook_other_namein one. Then that is used as the variable for that file.
Thanks. I also made a change to restore the value of DEFINE_RUST_DO_TRACE after define_trace.h
Alice