lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250318180814.226644-1-douglas.raillard@arm.com>
Date: Tue, 18 Mar 2025 18:08:10 +0000
From: Douglas RAILLARD <douglas.raillard@....com>
To: rostedt@...dmis.org
Cc: douglas.raillard@....com,
	Masami Hiramatsu <mhiramat@...nel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	linux-kernel@...r.kernel.org,
	linux-trace-kernel@...r.kernel.org
Subject: [PATCH 1/3] tracing: Expose functions to trace a synth event

From: Douglas Raillard <douglas.raillard@....com>

The current API for synth event only allow tracing by getting a "struct
trace_event_file *", which is associated with a specific ftrace instance
that has to be looked up ahead of time. In order to be able to emit such
synth event in all instances where the event has been enabled by a user,
another function is required, using a "struct synth_event *" that then
uses the underlying tracepoint system that the tracefs interface
manipulates.

Such function already exists for the histogram feature, so simply move
it to the common trace_events_synth.c code.

Signed-off-by: Douglas Raillard <douglas.raillard@....com>
---
 include/linux/trace_events.h      |  7 +++++++
 kernel/trace/trace_events_hist.c  | 27 ---------------------------
 kernel/trace/trace_events_synth.c | 29 +++++++++++++++++++++++++++++
 kernel/trace/trace_synth.h        |  2 --
 4 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 5caea596fef0..cbe389d0e144 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -517,6 +517,13 @@ struct dynevent_cmd {
 
 extern int dynevent_create(struct dynevent_cmd *cmd);
 
+struct synth_event;
+
+extern struct synth_event *find_synth_event(const char *name);
+
+extern void trace_synth(struct synth_event *event, u64 *var_ref_vals,
+			       unsigned int *var_ref_idx);
+
 extern int synth_event_delete(const char *name);
 
 extern void synth_event_cmd_init(struct dynevent_cmd *cmd,
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 53dc6719181e..a2bc7a972763 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -814,33 +814,6 @@ static void hist_err_clear(void)
 	last_cmd_loc[0] = '\0';
 }
 
-typedef void (*synth_probe_func_t) (void *__data, u64 *var_ref_vals,
-				    unsigned int *var_ref_idx);
-
-static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals,
-			       unsigned int *var_ref_idx)
-{
-	struct tracepoint *tp = event->tp;
-
-	if (unlikely(static_key_enabled(&tp->key))) {
-		struct tracepoint_func *probe_func_ptr;
-		synth_probe_func_t probe_func;
-		void *__data;
-
-		if (!(cpu_online(raw_smp_processor_id())))
-			return;
-
-		probe_func_ptr = rcu_dereference_sched((tp)->funcs);
-		if (probe_func_ptr) {
-			do {
-				probe_func = probe_func_ptr->func;
-				__data = probe_func_ptr->data;
-				probe_func(__data, var_ref_vals, var_ref_idx);
-			} while ((++probe_func_ptr)->func);
-		}
-	}
-}
-
 static void action_trace(struct hist_trigger_data *hist_data,
 			 struct tracing_map_elt *elt,
 			 struct trace_buffer *buffer, void *rec,
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index e3f7d09e5512..9f0817eec3c2 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -845,6 +845,35 @@ struct synth_event *find_synth_event(const char *name)
 
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(find_synth_event);
+
+typedef void (*synth_probe_func_t) (void *__data, u64 *var_ref_vals,
+				    unsigned int *var_ref_idx);
+
+void trace_synth(struct synth_event *event, u64 *var_ref_vals,
+			       unsigned int *var_ref_idx)
+{
+	struct tracepoint *tp = event->tp;
+
+	if (unlikely(static_key_enabled(&tp->key))) {
+		struct tracepoint_func *probe_func_ptr;
+		synth_probe_func_t probe_func;
+		void *__data;
+
+		if (!(cpu_online(raw_smp_processor_id())))
+			return;
+
+		probe_func_ptr = rcu_dereference_sched((tp)->funcs);
+		if (probe_func_ptr) {
+			do {
+				probe_func = probe_func_ptr->func;
+				__data = probe_func_ptr->data;
+				probe_func(__data, var_ref_vals, var_ref_idx);
+			} while ((++probe_func_ptr)->func);
+		}
+	}
+}
+EXPORT_SYMBOL_GPL(trace_synth);
 
 static struct trace_event_fields synth_event_fields_array[] = {
 	{ .type = TRACE_FUNCTION_TYPE,
diff --git a/kernel/trace/trace_synth.h b/kernel/trace/trace_synth.h
index 43f6fb6078db..425a0ec7c773 100644
--- a/kernel/trace/trace_synth.h
+++ b/kernel/trace/trace_synth.h
@@ -36,6 +36,4 @@ struct synth_event {
 	struct module				*mod;
 };
 
-extern struct synth_event *find_synth_event(const char *name);
-
 #endif /* __TRACE_SYNTH_H */
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ