Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d723736 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

tracing/events: add support for modules to TRACE_EVENT



Impact: allow modules to add TRACE_EVENTS on load

This patch adds the final hooks to allow modules to use the TRACE_EVENT
macro. A notifier and a data structure are used to link the TRACE_EVENTs
defined in the module to connect them with the ftrace event tracing system.

It also adds the necessary automated clean ups to the trace events when a
module is removed.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 17c873ec
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

struct trace_array;
struct tracer;
struct dentry;

/*
 * The trace entry - the most basic unit of tracing. This is what
@@ -87,6 +88,7 @@ struct ftrace_event_call {
	char			*name;
	char			*system;
	struct dentry		*dir;
	struct trace_event	*event;
	int			enabled;
	int			(*regfunc)(void);
	void			(*unregfunc)(void);
@@ -97,6 +99,7 @@ struct ftrace_event_call {
	struct list_head	fields;
	int			n_preds;
	struct filter_pred	**preds;
	void			*mod;

#ifdef CONFIG_EVENT_PROFILE
	atomic_t	profile_count;
+4 −0
Original line number Diff line number Diff line
@@ -337,6 +337,10 @@ struct module
	const char **trace_bprintk_fmt_start;
	unsigned int num_trace_bprintk_fmt;
#endif
#ifdef CONFIG_EVENT_TRACING
	struct ftrace_event_call *trace_events;
	unsigned int num_trace_events;
#endif

#ifdef CONFIG_MODULE_UNLOAD
	/* What modules depend on me? */
+2 −0
Original line number Diff line number Diff line
#ifndef _LINUX_TRACE_SEQ_H
#define _LINUX_TRACE_SEQ_H

#include <linux/fs.h>

/*
 * Trace sequences are used to allow a function to call several other functions
 * to create a string of data to use (up to a max of PAGE_SIZE.
+1 −0
Original line number Diff line number Diff line
@@ -477,6 +477,7 @@ __attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) event_##call = {		\
	.name			= #call,				\
	.system			= __stringify(TRACE_SYSTEM),		\
	.event			= &ftrace_event_type_##call,		\
	.raw_init		= ftrace_raw_init_event_##call,		\
	.regfunc		= ftrace_raw_reg_event_##call,		\
	.unregfunc		= ftrace_raw_unreg_event_##call,	\
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
*/
#include <linux/module.h>
#include <linux/moduleloader.h>
#include <linux/ftrace_event.h>
#include <linux/init.h>
#include <linux/kallsyms.h>
#include <linux/fs.h>
@@ -2172,6 +2173,12 @@ static noinline struct module *load_module(void __user *umod,
					sizeof(*mod->tracepoints),
					&mod->num_tracepoints);
#endif
#ifdef CONFIG_EVENT_TRACING
	mod->trace_events = section_objs(hdr, sechdrs, secstrings,
					 "_ftrace_events",
					 sizeof(*mod->trace_events),
					 &mod->num_trace_events);
#endif

#ifdef CONFIG_MODVERSIONS
	if ((mod->num_syms && !mod->crcs)
Loading