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

Commit 2b6080f2 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt
Browse files

tracing: Encapsulate global_trace and remove dependencies on global vars



The global_trace variable in kernel/trace/trace.c has been kept 'static' and
local to that file so that it would not be used too much outside of that
file. This has paid off, even though there were lots of changes to make
the trace_array structure more generic (not depending on global_trace).

Removal of a lot of direct usages of global_trace is needed to be able to
create more trace_arrays such that we can add multiple buffers.

Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent ae3b5093
Loading
Loading
Loading
Loading
+330 −231

File changed.

Preview size limit exceeded, changes collapsed.

+20 −1
Original line number Original line Diff line number Diff line
@@ -127,12 +127,21 @@ enum trace_flag_type {


#define TRACE_BUF_SIZE		1024
#define TRACE_BUF_SIZE		1024


struct trace_array;

struct trace_cpu {
	struct trace_array	*tr;
	struct dentry		*dir;
	int			cpu;
};

/*
/*
 * The CPU trace array - it consists of thousands of trace entries
 * The CPU trace array - it consists of thousands of trace entries
 * plus some other descriptor data: (for example which task started
 * plus some other descriptor data: (for example which task started
 * the trace, etc.)
 * the trace, etc.)
 */
 */
struct trace_array_cpu {
struct trace_array_cpu {
	struct trace_cpu	trace_cpu;
	atomic_t		disabled;
	atomic_t		disabled;
	void			*buffer_page;	/* ring buffer spare */
	void			*buffer_page;	/* ring buffer spare */


@@ -151,6 +160,8 @@ struct trace_array_cpu {
	char			comm[TASK_COMM_LEN];
	char			comm[TASK_COMM_LEN];
};
};


struct tracer;

/*
/*
 * The trace array - an array of per-CPU trace arrays. This is the
 * The trace array - an array of per-CPU trace arrays. This is the
 * highest level data structure that individual tracers deal with.
 * highest level data structure that individual tracers deal with.
@@ -161,9 +172,16 @@ struct trace_array {
	struct list_head	list;
	struct list_head	list;
	int			cpu;
	int			cpu;
	int			buffer_disabled;
	int			buffer_disabled;
	struct trace_cpu	trace_cpu;	/* place holder */
	int			stop_count;
	int			clock_id;
	struct tracer		*current_trace;
	unsigned int		flags;
	unsigned int		flags;
	cycle_t			time_start;
	cycle_t			time_start;
	raw_spinlock_t		start_lock;
	struct dentry		*dir;
	struct dentry		*dir;
	struct dentry		*options;
	struct dentry		*percpu_dir;
	struct dentry		*event_dir;
	struct dentry		*event_dir;
	struct list_head	systems;
	struct list_head	systems;
	struct list_head	events;
	struct list_head	events;
@@ -474,6 +492,7 @@ struct dentry *trace_create_file(const char *name,
				 void *data,
				 void *data,
				 const struct file_operations *fops);
				 const struct file_operations *fops);


struct dentry *tracing_init_dentry_tr(struct trace_array *tr);
struct dentry *tracing_init_dentry(void);
struct dentry *tracing_init_dentry(void);


struct ring_buffer_event;
struct ring_buffer_event;
@@ -979,7 +998,7 @@ extern const char *__stop___trace_bprintk_fmt[];
void trace_printk_init_buffers(void);
void trace_printk_init_buffers(void);
void trace_printk_start_comm(void);
void trace_printk_start_comm(void);
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
int set_tracer_flag(unsigned int mask, int enabled);
int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);


#undef FTRACE_ENTRY
#undef FTRACE_ENTRY
#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter)	\
#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter)	\
+4 −4
Original line number Original line Diff line number Diff line
@@ -561,8 +561,8 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
	save_flags = trace_flags;
	save_flags = trace_flags;


	/* non overwrite screws up the latency tracers */
	/* non overwrite screws up the latency tracers */
	set_tracer_flag(TRACE_ITER_OVERWRITE, 1);
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
	set_tracer_flag(TRACE_ITER_LATENCY_FMT, 1);
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);


	tracing_max_latency = 0;
	tracing_max_latency = 0;
	irqsoff_trace = tr;
	irqsoff_trace = tr;
@@ -581,8 +581,8 @@ static void irqsoff_tracer_reset(struct trace_array *tr)


	stop_irqsoff_tracer(tr, is_graph());
	stop_irqsoff_tracer(tr, is_graph());


	set_tracer_flag(TRACE_ITER_LATENCY_FMT, lat_flag);
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
	set_tracer_flag(TRACE_ITER_OVERWRITE, overwrite_flag);
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
}
}


static void irqsoff_tracer_start(struct trace_array *tr)
static void irqsoff_tracer_start(struct trace_array *tr)
+4 −4
Original line number Original line Diff line number Diff line
@@ -543,8 +543,8 @@ static int __wakeup_tracer_init(struct trace_array *tr)
	save_flags = trace_flags;
	save_flags = trace_flags;


	/* non overwrite screws up the latency tracers */
	/* non overwrite screws up the latency tracers */
	set_tracer_flag(TRACE_ITER_OVERWRITE, 1);
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
	set_tracer_flag(TRACE_ITER_LATENCY_FMT, 1);
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);


	tracing_max_latency = 0;
	tracing_max_latency = 0;
	wakeup_trace = tr;
	wakeup_trace = tr;
@@ -573,8 +573,8 @@ static void wakeup_tracer_reset(struct trace_array *tr)
	/* make sure we put back any tasks we are tracing */
	/* make sure we put back any tasks we are tracing */
	wakeup_reset(tr);
	wakeup_reset(tr);


	set_tracer_flag(TRACE_ITER_LATENCY_FMT, lat_flag);
	set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
	set_tracer_flag(TRACE_ITER_OVERWRITE, overwrite_flag);
	set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
}
}


static void wakeup_tracer_start(struct trace_array *tr)
static void wakeup_tracer_start(struct trace_array *tr)