On Tue, Nov 19, 2024 at 12:27 AM Steven Rostedt <[email protected]> wrote:
>
> On Mon, 18 Nov 2024 20:27:26 +0000
> Alice Ryhl <[email protected]> wrote:
>
> > When building the rust_print sample with CONFIG_JUMP_LABEL=n, the Rust
> > static key support falls back to using static_key_count. This function
> > accepts a mutable pointer to the `struct static_key`, but the Rust
> > abstractions are incorrectly passing a const pointer.
> >
> > This means that builds using CONFIG_JUMP_LABEL=n and SAMPLE_RUST_PRINT=y
> > fail with the following error message:
> >
> >       error[E0308]: mismatched types
> >         --> <root>/samples/rust/rust_print_main.rs:87:5
> >          |
> >       87 | /     kernel::declare_trace! {
> >       88 | |         /// # Safety
> >       89 | |         ///
> >       90 | |         /// Always safe to call.
> >       91 | |         unsafe fn rust_sample_loaded(magic: c_int);
> >       92 | |     }
> >          | |     ^
> >          | |     |
> >          | |_____types differ in mutability
> >          |       arguments to this function are incorrect
> >          |
> >          = note: expected raw pointer `*mut kernel::bindings::static_key`
> >                     found raw pointer `*const kernel::bindings::static_key`
> >       note: function defined here
> >         --> <root>/rust/bindings/bindings_helpers_generated.rs:33:12
> >          |
> >       33 |     pub fn static_key_count(key: *mut static_key) -> c_int;
> >          |            ^^^^^^^^^^^^^^^^
> >
> > To fix this, insert a pointer cast so that the pointer is mutable.
>
> Hi Alice,
>
> BTW, how do you test the sample tracepoint? I see you add a tracepoint in
> the module load call, but currently we can enable module tracepoints on
> module load. How do you enable it when the rust_print module gets loaded?

I've only really used the sample in this series as a build test. The
bulk of my testing has occurred by using this tracepoint support in
Rust Binder where I have 30 different tracepoints and I've been able
to verify that I can enable them and so on there.

Alice

Reply via email to