File tree Expand file tree Collapse file tree 6 files changed +61
-1
lines changed
Expand file tree Collapse file tree 6 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -20223,6 +20223,7 @@ C: zulip://rust-for-linux.zulipchat.com
2022320223P: https://rust-for-linux.com/contributing
2022420224T: git https://github.com/Rust-for-Linux/linux.git rust-next
2022520225F: Documentation/rust/
20226+ F: include/trace/events/rust_sample.h
2022620227F: rust/
2022720228F: samples/rust/
2022820229F: scripts/*rust*
Original file line number Diff line number Diff line change 1+ /* SPDX-License-Identifier: GPL-2.0-only */
2+ /*
3+ * Tracepoints for `samples/rust/rust_print.rs`.
4+ *
5+ * Copyright (C) 2024 Google, Inc.
6+ */
7+
8+ #undef TRACE_SYSTEM
9+ #define TRACE_SYSTEM rust_sample
10+
11+ #if !defined(_RUST_SAMPLE_TRACE_H ) || defined(TRACE_HEADER_MULTI_READ )
12+ #define _RUST_SAMPLE_TRACE_H
13+
14+ #include <linux/tracepoint.h>
15+
16+ TRACE_EVENT (rust_sample_loaded ,
17+ TP_PROTO (int magic_number ),
18+ TP_ARGS (magic_number ),
19+ TP_STRUCT__entry (
20+ __field (int , magic_number )
21+ ),
22+ TP_fast_assign (
23+ __entry -> magic_number = magic_number ;
24+ ),
25+ TP_printk ("magic=%d" , __entry -> magic_number )
26+ );
27+
28+ #endif /* _RUST_SAMPLE_TRACE_H */
29+
30+ /* This part must be outside protection */
31+ #include <trace/define_trace.h>
Original file line number Diff line number Diff line change 2323#include <linux/tracepoint.h>
2424#include <linux/wait.h>
2525#include <linux/workqueue.h>
26+ #include <trace/events/rust_sample.h>
2627
2728/* `bindgen` gets confused at certain things. */
2829const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN ;
Original file line number Diff line number Diff line change 11# SPDX-License-Identifier: GPL-2.0
2+ ccflags-y += -I$(src ) # needed for trace events
23
34obj-$(CONFIG_SAMPLE_RUST_MINIMAL) += rust_minimal.o
4- obj-$(CONFIG_SAMPLE_RUST_PRINT) += rust_print.o
5+ obj-$(CONFIG_SAMPLE_RUST_PRINT) += rust_print.o rust_print_events.o
56
67subdir-$(CONFIG_SAMPLE_RUST_HOSTPROGS) += hostprogs
Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ impl kernel::Module for RustPrint {
6969
7070 arc_print ( ) ?;
7171
72+ trace:: trace_rust_sample_loaded ( 42 ) ;
73+
7274 Ok ( RustPrint )
7375 }
7476}
@@ -78,3 +80,19 @@ impl Drop for RustPrint {
7880 pr_info ! ( "Rust printing macros sample (exit)\n " ) ;
7981 }
8082}
83+
84+ mod trace {
85+ use core:: ffi:: c_int;
86+
87+ kernel:: declare_trace! {
88+ /// # Safety
89+ ///
90+ /// Always safe to call.
91+ unsafe fn rust_sample_loaded( magic: c_int) ;
92+ }
93+
94+ pub ( crate ) fn trace_rust_sample_loaded ( magic : i32 ) {
95+ // SAFETY: Always safe to call.
96+ unsafe { rust_sample_loaded ( magic as c_int ) }
97+ }
98+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-2.0-only
2+ /*
3+ * Copyright 2024 Google LLC
4+ */
5+
6+ #define CREATE_TRACE_POINTS
7+ #define CREATE_RUST_TRACE_POINTS
8+ #include <trace/events/rust_sample.h>
You can’t perform that action at this time.
0 commit comments