2013-10-24 08:59:29 -05:00
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
#ifndef _LINUX_TRACE_EVENT_H
|
|
|
|
|
#define _LINUX_TRACE_EVENT_H
|
2009-04-13 11:20:49 -04:00
|
|
|
|
|
|
|
|
#include <linux/ring_buffer.h>
|
2009-09-12 19:04:54 -04:00
|
|
|
#include <linux/trace_seq.h>
|
2009-05-26 20:25:22 +02:00
|
|
|
#include <linux/percpu.h>
|
2009-09-18 06:10:28 +02:00
|
|
|
#include <linux/hardirq.h>
|
2010-01-28 09:32:29 +08:00
|
|
|
#include <linux/perf_event.h>
|
2014-04-08 17:26:21 -04:00
|
|
|
#include <linux/tracepoint.h>
|
2009-04-13 11:20:49 -04:00
|
|
|
|
|
|
|
|
struct trace_array;
|
2013-03-05 09:24:35 -05:00
|
|
|
struct trace_buffer;
|
2009-04-13 11:20:49 -04:00
|
|
|
struct tracer;
|
2009-04-10 14:53:50 -04:00
|
|
|
struct dentry;
|
2015-03-25 12:49:20 -07:00
|
|
|
struct bpf_prog;
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2009-05-26 20:25:22 +02:00
|
|
|
struct trace_print_flags {
|
|
|
|
|
unsigned long mask;
|
|
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-19 09:35:28 +08:00
|
|
|
struct trace_print_flags_u64 {
|
|
|
|
|
unsigned long long mask;
|
|
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_flags_seq(struct trace_seq *p, const char *delim,
|
|
|
|
|
unsigned long flags,
|
|
|
|
|
const struct trace_print_flags *flag_array);
|
2009-05-26 20:25:22 +02:00
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
|
|
|
|
|
const struct trace_print_flags *symbol_array);
|
2009-05-20 19:21:47 -04:00
|
|
|
|
2011-04-19 09:35:28 +08:00
|
|
|
#if BITS_PER_LONG == 32
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_symbols_seq_u64(struct trace_seq *p,
|
|
|
|
|
unsigned long long val,
|
|
|
|
|
const struct trace_print_flags_u64
|
2011-04-19 09:35:28 +08:00
|
|
|
*symbol_array);
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
|
|
|
|
|
unsigned int bitmask_size);
|
2014-05-06 13:10:24 -04:00
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_hex_seq(struct trace_seq *p,
|
|
|
|
|
const unsigned char *buf, int len);
|
2010-04-01 20:40:58 +09:00
|
|
|
|
2015-05-04 18:12:44 -04:00
|
|
|
const char *trace_print_array_seq(struct trace_seq *p,
|
2015-04-29 16:18:46 +01:00
|
|
|
const void *buf, int count,
|
2015-01-28 12:48:53 +00:00
|
|
|
size_t el_size);
|
|
|
|
|
|
2013-02-21 10:32:38 +08:00
|
|
|
struct trace_iterator;
|
|
|
|
|
struct trace_event;
|
|
|
|
|
|
2015-05-05 14:18:11 -04:00
|
|
|
int trace_raw_output_prep(struct trace_iterator *iter,
|
|
|
|
|
struct trace_event *event);
|
2013-02-21 10:32:38 +08:00
|
|
|
|
2009-04-13 11:20:49 -04:00
|
|
|
/*
|
|
|
|
|
* The trace entry - the most basic unit of tracing. This is what
|
|
|
|
|
* is printed in the end as a single line in the trace output, such as:
|
|
|
|
|
*
|
|
|
|
|
* bash-15816 [01] 235.197585: idle_cpu <- irq_enter
|
|
|
|
|
*/
|
|
|
|
|
struct trace_entry {
|
2009-03-26 11:03:29 -04:00
|
|
|
unsigned short type;
|
2009-04-13 11:20:49 -04:00
|
|
|
unsigned char flags;
|
|
|
|
|
unsigned char preempt_count;
|
|
|
|
|
int pid;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-13 13:44:36 -04:00
|
|
|
#define TRACE_EVENT_TYPE_MAX \
|
2009-03-26 11:03:29 -04:00
|
|
|
((1 << (sizeof(((struct trace_entry *)0)->type) * 8)) - 1)
|
|
|
|
|
|
2009-04-13 11:20:49 -04:00
|
|
|
/*
|
|
|
|
|
* Trace iterator - used by printout routines who present trace
|
|
|
|
|
* results to users and which routines might sleep, etc:
|
|
|
|
|
*/
|
|
|
|
|
struct trace_iterator {
|
|
|
|
|
struct trace_array *tr;
|
|
|
|
|
struct tracer *trace;
|
2013-03-05 09:24:35 -05:00
|
|
|
struct trace_buffer *trace_buffer;
|
2009-04-13 11:20:49 -04:00
|
|
|
void *private;
|
|
|
|
|
int cpu_file;
|
|
|
|
|
struct mutex mutex;
|
2012-06-27 20:46:14 -04:00
|
|
|
struct ring_buffer_iter **buffer_iter;
|
2009-06-01 15:16:05 -04:00
|
|
|
unsigned long iter_flags;
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2010-06-03 18:26:24 +08:00
|
|
|
/* trace_seq for __print_flags() and __print_symbolic() etc. */
|
|
|
|
|
struct trace_seq tmp_seq;
|
|
|
|
|
|
2013-08-02 21:16:43 +04:00
|
|
|
cpumask_var_t started;
|
|
|
|
|
|
|
|
|
|
/* it's true when current open file is snapshot */
|
|
|
|
|
bool snapshot;
|
|
|
|
|
|
2009-04-13 11:20:49 -04:00
|
|
|
/* The below is zeroed out in pipe_read */
|
|
|
|
|
struct trace_seq seq;
|
|
|
|
|
struct trace_entry *ent;
|
2010-03-31 19:49:26 -04:00
|
|
|
unsigned long lost_events;
|
2009-12-07 09:11:39 -05:00
|
|
|
int leftover;
|
2011-07-14 16:36:53 -04:00
|
|
|
int ent_size;
|
2009-04-13 11:20:49 -04:00
|
|
|
int cpu;
|
|
|
|
|
u64 ts;
|
|
|
|
|
|
|
|
|
|
loff_t pos;
|
|
|
|
|
long idx;
|
|
|
|
|
|
2013-08-02 21:16:43 +04:00
|
|
|
/* All new field here will be zeroed out in pipe_read */
|
2009-04-13 11:20:49 -04:00
|
|
|
};
|
|
|
|
|
|
2012-11-13 12:18:22 -08:00
|
|
|
enum trace_iter_flags {
|
|
|
|
|
TRACE_FILE_LAT_FMT = 1,
|
|
|
|
|
TRACE_FILE_ANNOTATE = 2,
|
|
|
|
|
TRACE_FILE_TIME_IN_NS = 4,
|
|
|
|
|
};
|
|
|
|
|
|
2009-04-13 11:20:49 -04:00
|
|
|
|
|
|
|
|
typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
|
2010-04-22 18:46:14 -04:00
|
|
|
int flags, struct trace_event *event);
|
|
|
|
|
|
|
|
|
|
struct trace_event_functions {
|
2009-04-13 11:20:49 -04:00
|
|
|
trace_print_func trace;
|
|
|
|
|
trace_print_func raw;
|
|
|
|
|
trace_print_func hex;
|
|
|
|
|
trace_print_func binary;
|
|
|
|
|
};
|
|
|
|
|
|
2010-04-22 18:46:14 -04:00
|
|
|
struct trace_event {
|
|
|
|
|
struct hlist_node node;
|
|
|
|
|
struct list_head list;
|
|
|
|
|
int type;
|
|
|
|
|
struct trace_event_functions *funcs;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-05 09:39:12 -04:00
|
|
|
extern int register_trace_event(struct trace_event *event);
|
|
|
|
|
extern int unregister_trace_event(struct trace_event *event);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
|
|
|
|
/* Return values for print_line callback */
|
|
|
|
|
enum print_line_t {
|
|
|
|
|
TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */
|
|
|
|
|
TRACE_TYPE_HANDLED = 1,
|
|
|
|
|
TRACE_TYPE_UNHANDLED = 2, /* Relay to other output functions */
|
|
|
|
|
TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
|
|
|
|
|
};
|
|
|
|
|
|
2014-11-12 10:29:54 -05:00
|
|
|
/*
|
|
|
|
|
* Several functions return TRACE_TYPE_PARTIAL_LINE if the trace_seq
|
|
|
|
|
* overflowed, and TRACE_TYPE_HANDLED otherwise. This helper function
|
|
|
|
|
* simplifies those functions and keeps them in sync.
|
|
|
|
|
*/
|
|
|
|
|
static inline enum print_line_t trace_handle_return(struct trace_seq *s)
|
|
|
|
|
{
|
|
|
|
|
return trace_seq_has_overflowed(s) ?
|
|
|
|
|
TRACE_TYPE_PARTIAL_LINE : TRACE_TYPE_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-07 01:25:54 +02:00
|
|
|
void tracing_generic_entry_update(struct trace_entry *entry,
|
|
|
|
|
unsigned long flags,
|
|
|
|
|
int pc);
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file;
|
2012-08-02 10:32:10 -04:00
|
|
|
|
|
|
|
|
struct ring_buffer_event *
|
|
|
|
|
trace_event_buffer_lock_reserve(struct ring_buffer **current_buffer,
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file *trace_file,
|
2012-08-02 10:32:10 -04:00
|
|
|
int type, unsigned long len,
|
|
|
|
|
unsigned long flags, int pc);
|
2009-04-13 11:20:49 -04:00
|
|
|
struct ring_buffer_event *
|
2009-09-02 14:17:06 -04:00
|
|
|
trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer,
|
|
|
|
|
int type, unsigned long len,
|
2009-04-13 11:20:49 -04:00
|
|
|
unsigned long flags, int pc);
|
2015-09-25 17:38:44 -04:00
|
|
|
void trace_buffer_unlock_commit(struct trace_array *tr,
|
|
|
|
|
struct ring_buffer *buffer,
|
2012-11-01 20:54:21 -04:00
|
|
|
struct ring_buffer_event *event,
|
|
|
|
|
unsigned long flags, int pc);
|
2015-09-25 17:38:44 -04:00
|
|
|
void trace_buffer_unlock_commit_regs(struct trace_array *tr,
|
|
|
|
|
struct ring_buffer *buffer,
|
2012-11-01 20:54:21 -04:00
|
|
|
struct ring_buffer_event *event,
|
|
|
|
|
unsigned long flags, int pc,
|
|
|
|
|
struct pt_regs *regs);
|
2009-09-02 14:17:06 -04:00
|
|
|
void trace_current_buffer_discard_commit(struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
|
|
|
|
void tracing_record_cmdline(struct task_struct *tsk);
|
|
|
|
|
|
2015-05-05 14:18:11 -04:00
|
|
|
int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
|
2012-08-09 19:16:14 -04:00
|
|
|
|
2009-07-20 10:20:53 +08:00
|
|
|
struct event_filter;
|
|
|
|
|
|
2010-04-21 12:27:06 -04:00
|
|
|
enum trace_reg {
|
|
|
|
|
TRACE_REG_REGISTER,
|
|
|
|
|
TRACE_REG_UNREGISTER,
|
2012-03-14 00:03:02 +01:00
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
2010-04-21 12:27:06 -04:00
|
|
|
TRACE_REG_PERF_REGISTER,
|
|
|
|
|
TRACE_REG_PERF_UNREGISTER,
|
2012-02-15 15:51:49 +01:00
|
|
|
TRACE_REG_PERF_OPEN,
|
|
|
|
|
TRACE_REG_PERF_CLOSE,
|
2012-02-15 15:51:50 +01:00
|
|
|
TRACE_REG_PERF_ADD,
|
|
|
|
|
TRACE_REG_PERF_DEL,
|
2012-03-14 00:03:02 +01:00
|
|
|
#endif
|
2010-04-21 12:27:06 -04:00
|
|
|
};
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
struct trace_event_call;
|
2010-04-21 12:27:06 -04:00
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
struct trace_event_class {
|
2015-03-31 14:37:12 -04:00
|
|
|
const char *system;
|
2010-04-21 12:27:06 -04:00
|
|
|
void *probe;
|
|
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
|
|
|
void *perf_probe;
|
|
|
|
|
#endif
|
2015-05-05 11:45:27 -04:00
|
|
|
int (*reg)(struct trace_event_call *event,
|
2012-02-15 15:51:49 +01:00
|
|
|
enum trace_reg type, void *data);
|
2015-05-05 11:45:27 -04:00
|
|
|
int (*define_fields)(struct trace_event_call *);
|
|
|
|
|
struct list_head *(*get_fields)(struct trace_event_call *);
|
2010-04-22 10:35:55 -04:00
|
|
|
struct list_head fields;
|
2015-05-05 11:45:27 -04:00
|
|
|
int (*raw_init)(struct trace_event_call *);
|
2010-04-20 10:47:33 -04:00
|
|
|
};
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
extern int trace_event_reg(struct trace_event_call *event,
|
2012-02-15 15:51:49 +01:00
|
|
|
enum trace_reg type, void *data);
|
2010-06-08 11:22:06 -04:00
|
|
|
|
2015-05-05 13:18:46 -04:00
|
|
|
struct trace_event_buffer {
|
2012-08-09 22:42:57 -04:00
|
|
|
struct ring_buffer *buffer;
|
|
|
|
|
struct ring_buffer_event *event;
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file *trace_file;
|
2012-08-09 22:42:57 -04:00
|
|
|
void *entry;
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
int pc;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-05 13:18:46 -04:00
|
|
|
void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file *trace_file,
|
2012-08-09 22:42:57 -04:00
|
|
|
unsigned long len);
|
|
|
|
|
|
2015-05-05 13:18:46 -04:00
|
|
|
void trace_event_buffer_commit(struct trace_event_buffer *fbuffer);
|
2012-08-09 22:42:57 -04:00
|
|
|
|
2010-04-23 11:12:36 -04:00
|
|
|
enum {
|
|
|
|
|
TRACE_EVENT_FL_FILTERED_BIT,
|
2010-11-18 01:39:17 +01:00
|
|
|
TRACE_EVENT_FL_CAP_ANY_BIT,
|
2011-11-01 09:09:35 +08:00
|
|
|
TRACE_EVENT_FL_NO_SET_FILTER_BIT,
|
2012-05-10 15:55:43 -04:00
|
|
|
TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
|
2013-03-04 23:05:12 -05:00
|
|
|
TRACE_EVENT_FL_WAS_ENABLED_BIT,
|
2013-10-24 08:34:17 -05:00
|
|
|
TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
|
2014-04-08 17:26:21 -04:00
|
|
|
TRACE_EVENT_FL_TRACEPOINT_BIT,
|
2015-03-25 12:49:19 -07:00
|
|
|
TRACE_EVENT_FL_KPROBE_BIT,
|
2015-07-01 02:13:50 +00:00
|
|
|
TRACE_EVENT_FL_UPROBE_BIT,
|
2010-04-23 11:12:36 -04:00
|
|
|
};
|
|
|
|
|
|
2012-05-03 23:09:03 -04:00
|
|
|
/*
|
|
|
|
|
* Event flags:
|
|
|
|
|
* FILTERED - The event has a filter attached
|
|
|
|
|
* CAP_ANY - Any user can enable for perf
|
|
|
|
|
* NO_SET_FILTER - Set when filter has error and is to be ignored
|
2015-05-13 15:12:33 -04:00
|
|
|
* IGNORE_ENABLE - For trace internal events, do not enable with debugfs file
|
2013-03-04 23:05:12 -05:00
|
|
|
* WAS_ENABLED - Set and stays set when an event was ever enabled
|
|
|
|
|
* (used for module unloading, if a module event is enabled,
|
|
|
|
|
* it is best to clear the buffers that used it).
|
2015-05-13 15:12:33 -04:00
|
|
|
* USE_CALL_FILTER - For trace internal events, don't use file filter
|
2014-04-08 17:26:21 -04:00
|
|
|
* TRACEPOINT - Event is a tracepoint
|
2015-03-25 12:49:19 -07:00
|
|
|
* KPROBE - Event is a kprobe
|
2015-07-01 02:13:50 +00:00
|
|
|
* UPROBE - Event is a uprobe
|
2012-05-03 23:09:03 -04:00
|
|
|
*/
|
2010-04-23 11:12:36 -04:00
|
|
|
enum {
|
2010-07-02 11:07:32 +08:00
|
|
|
TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
|
2010-11-18 01:39:17 +01:00
|
|
|
TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),
|
2011-11-01 09:09:35 +08:00
|
|
|
TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT),
|
2012-05-10 15:55:43 -04:00
|
|
|
TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
|
2013-03-04 23:05:12 -05:00
|
|
|
TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT),
|
2013-10-24 08:34:17 -05:00
|
|
|
TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
|
2014-04-08 17:26:21 -04:00
|
|
|
TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
|
2015-03-25 12:49:19 -07:00
|
|
|
TRACE_EVENT_FL_KPROBE = (1 << TRACE_EVENT_FL_KPROBE_BIT),
|
2015-07-01 02:13:50 +00:00
|
|
|
TRACE_EVENT_FL_UPROBE = (1 << TRACE_EVENT_FL_UPROBE_BIT),
|
2010-04-23 11:12:36 -04:00
|
|
|
};
|
|
|
|
|
|
2015-07-01 02:13:50 +00:00
|
|
|
#define TRACE_EVENT_FL_UKPROBE (TRACE_EVENT_FL_KPROBE | TRACE_EVENT_FL_UPROBE)
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
struct trace_event_call {
|
2009-04-10 13:52:20 -04:00
|
|
|
struct list_head list;
|
2015-05-05 11:45:27 -04:00
|
|
|
struct trace_event_class *class;
|
2014-04-08 17:26:21 -04:00
|
|
|
union {
|
|
|
|
|
char *name;
|
|
|
|
|
/* Set TRACE_EVENT_FL_TRACEPOINT flag when using "tp" */
|
|
|
|
|
struct tracepoint *tp;
|
|
|
|
|
};
|
2010-04-23 10:00:22 -04:00
|
|
|
struct trace_event event;
|
2015-03-24 17:58:09 -04:00
|
|
|
char *print_fmt;
|
2009-07-20 10:20:53 +08:00
|
|
|
struct event_filter *filter;
|
2009-04-10 14:53:50 -04:00
|
|
|
void *mod;
|
2009-08-10 16:52:44 -04:00
|
|
|
void *data;
|
2013-03-12 12:38:06 -04:00
|
|
|
/*
|
|
|
|
|
* bit 0: filter_active
|
|
|
|
|
* bit 1: allow trace by non root (cap any)
|
|
|
|
|
* bit 2: failed to apply filter
|
2015-05-13 15:12:33 -04:00
|
|
|
* bit 3: trace internal event (do not enable)
|
2013-03-12 12:38:06 -04:00
|
|
|
* bit 4: Event was enabled by module
|
2013-10-24 08:34:17 -05:00
|
|
|
* bit 5: use call filter rather than file filter
|
2014-04-08 17:26:21 -04:00
|
|
|
* bit 6: Event is a tracepoint
|
2013-03-12 12:38:06 -04:00
|
|
|
*/
|
2012-05-03 23:09:03 -04:00
|
|
|
int flags; /* static flags of different events */
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
|
|
|
int perf_refcount;
|
|
|
|
|
struct hlist_head __percpu *perf_events;
|
2015-03-25 12:49:20 -07:00
|
|
|
struct bpf_prog *prog;
|
2013-11-14 16:23:04 +01:00
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
int (*perf_perm)(struct trace_event_call *,
|
2013-11-14 16:23:04 +01:00
|
|
|
struct perf_event *);
|
2012-05-03 23:09:03 -04:00
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-08 17:26:21 -04:00
|
|
|
static inline const char *
|
2015-05-13 14:20:14 -04:00
|
|
|
trace_event_name(struct trace_event_call *call)
|
2014-04-08 17:26:21 -04:00
|
|
|
{
|
|
|
|
|
if (call->flags & TRACE_EVENT_FL_TRACEPOINT)
|
|
|
|
|
return call->tp ? call->tp->name : NULL;
|
|
|
|
|
else
|
|
|
|
|
return call->name;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-03 23:09:03 -04:00
|
|
|
struct trace_array;
|
2015-05-13 14:59:40 -04:00
|
|
|
struct trace_subsystem_dir;
|
2012-05-03 23:09:03 -04:00
|
|
|
|
|
|
|
|
enum {
|
2015-05-13 15:12:33 -04:00
|
|
|
EVENT_FILE_FL_ENABLED_BIT,
|
|
|
|
|
EVENT_FILE_FL_RECORDED_CMD_BIT,
|
|
|
|
|
EVENT_FILE_FL_FILTERED_BIT,
|
|
|
|
|
EVENT_FILE_FL_NO_SET_FILTER_BIT,
|
|
|
|
|
EVENT_FILE_FL_SOFT_MODE_BIT,
|
|
|
|
|
EVENT_FILE_FL_SOFT_DISABLED_BIT,
|
|
|
|
|
EVENT_FILE_FL_TRIGGER_MODE_BIT,
|
|
|
|
|
EVENT_FILE_FL_TRIGGER_COND_BIT,
|
2015-09-25 12:58:44 -04:00
|
|
|
EVENT_FILE_FL_PID_FILTER_BIT,
|
2012-05-03 23:09:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
2015-05-13 15:12:33 -04:00
|
|
|
* Event file flags:
|
2013-03-12 12:38:06 -04:00
|
|
|
* ENABLED - The event is enabled
|
2012-05-03 23:09:03 -04:00
|
|
|
* RECORDED_CMD - The comms should be recorded at sched_switch
|
2013-10-24 08:34:17 -05:00
|
|
|
* FILTERED - The event has a filter attached
|
|
|
|
|
* NO_SET_FILTER - Set when filter has error and is to be ignored
|
2013-03-12 13:26:18 -04:00
|
|
|
* SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
|
|
|
|
|
* SOFT_DISABLED - When set, do not trace the event (even though its
|
|
|
|
|
* tracepoint may be enabled)
|
2013-10-24 08:59:24 -05:00
|
|
|
* TRIGGER_MODE - When set, invoke the triggers associated with the event
|
2013-10-24 08:59:29 -05:00
|
|
|
* TRIGGER_COND - When set, one or more triggers has an associated filter
|
2015-09-25 12:58:44 -04:00
|
|
|
* PID_FILTER - When set, the event is filtered based on pid
|
2012-05-03 23:09:03 -04:00
|
|
|
*/
|
|
|
|
|
enum {
|
2015-05-13 15:12:33 -04:00
|
|
|
EVENT_FILE_FL_ENABLED = (1 << EVENT_FILE_FL_ENABLED_BIT),
|
|
|
|
|
EVENT_FILE_FL_RECORDED_CMD = (1 << EVENT_FILE_FL_RECORDED_CMD_BIT),
|
|
|
|
|
EVENT_FILE_FL_FILTERED = (1 << EVENT_FILE_FL_FILTERED_BIT),
|
|
|
|
|
EVENT_FILE_FL_NO_SET_FILTER = (1 << EVENT_FILE_FL_NO_SET_FILTER_BIT),
|
|
|
|
|
EVENT_FILE_FL_SOFT_MODE = (1 << EVENT_FILE_FL_SOFT_MODE_BIT),
|
|
|
|
|
EVENT_FILE_FL_SOFT_DISABLED = (1 << EVENT_FILE_FL_SOFT_DISABLED_BIT),
|
|
|
|
|
EVENT_FILE_FL_TRIGGER_MODE = (1 << EVENT_FILE_FL_TRIGGER_MODE_BIT),
|
|
|
|
|
EVENT_FILE_FL_TRIGGER_COND = (1 << EVENT_FILE_FL_TRIGGER_COND_BIT),
|
2015-09-25 12:58:44 -04:00
|
|
|
EVENT_FILE_FL_PID_FILTER = (1 << EVENT_FILE_FL_PID_FILTER_BIT),
|
2012-05-03 23:09:03 -04:00
|
|
|
};
|
|
|
|
|
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file {
|
2012-05-03 23:09:03 -04:00
|
|
|
struct list_head list;
|
2015-05-05 11:45:27 -04:00
|
|
|
struct trace_event_call *event_call;
|
2013-10-24 08:34:17 -05:00
|
|
|
struct event_filter *filter;
|
2012-05-03 23:09:03 -04:00
|
|
|
struct dentry *dir;
|
|
|
|
|
struct trace_array *tr;
|
2015-05-13 14:59:40 -04:00
|
|
|
struct trace_subsystem_dir *system;
|
2013-10-24 08:59:24 -05:00
|
|
|
struct list_head triggers;
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2010-04-23 11:12:36 -04:00
|
|
|
/*
|
|
|
|
|
* 32 bit flags:
|
2013-03-12 12:38:06 -04:00
|
|
|
* bit 0: enabled
|
|
|
|
|
* bit 1: enabled cmd record
|
2013-03-12 13:26:18 -04:00
|
|
|
* bit 2: enable/disable with the soft disable bit
|
|
|
|
|
* bit 3: soft disabled
|
2013-10-24 08:59:24 -05:00
|
|
|
* bit 4: trigger enabled
|
2010-04-23 11:12:36 -04:00
|
|
|
*
|
2013-03-12 13:26:18 -04:00
|
|
|
* Note: The bits must be set atomically to prevent races
|
|
|
|
|
* from other writers. Reads of flags do not need to be in
|
|
|
|
|
* sync as they occur in critical sections. But the way flags
|
2012-05-03 23:09:03 -04:00
|
|
|
* is currently used, these changes do not affect the code
|
2010-05-14 10:19:13 -04:00
|
|
|
* except that when a change is made, it may have a slight
|
|
|
|
|
* delay in propagating the changes to other CPUs due to
|
2013-03-12 13:26:18 -04:00
|
|
|
* caching and such. Which is mostly OK ;-)
|
2010-04-23 11:12:36 -04:00
|
|
|
*/
|
2013-03-12 13:26:18 -04:00
|
|
|
unsigned long flags;
|
2013-05-09 14:44:29 +09:00
|
|
|
atomic_t sm_ref; /* soft-mode reference counter */
|
2013-10-24 08:59:24 -05:00
|
|
|
atomic_t tm_ref; /* trigger-mode reference counter */
|
2009-04-13 11:20:49 -04:00
|
|
|
};
|
|
|
|
|
|
2010-11-18 02:11:42 +01:00
|
|
|
#define __TRACE_EVENT_FLAGS(name, value) \
|
|
|
|
|
static int __init trace_init_flags_##name(void) \
|
|
|
|
|
{ \
|
2014-04-08 17:26:21 -04:00
|
|
|
event_##name.flags |= value; \
|
2010-11-18 02:11:42 +01:00
|
|
|
return 0; \
|
|
|
|
|
} \
|
|
|
|
|
early_initcall(trace_init_flags_##name);
|
|
|
|
|
|
2013-11-14 16:23:04 +01:00
|
|
|
#define __TRACE_EVENT_PERF_PERM(name, expr...) \
|
2015-05-05 11:45:27 -04:00
|
|
|
static int perf_perm_##name(struct trace_event_call *tp_event, \
|
2013-11-14 16:23:04 +01:00
|
|
|
struct perf_event *p_event) \
|
|
|
|
|
{ \
|
|
|
|
|
return ({ expr; }); \
|
|
|
|
|
} \
|
|
|
|
|
static int __init trace_init_perf_perm_##name(void) \
|
|
|
|
|
{ \
|
|
|
|
|
event_##name.perf_perm = &perf_perm_##name; \
|
|
|
|
|
return 0; \
|
|
|
|
|
} \
|
|
|
|
|
early_initcall(trace_init_perf_perm_##name);
|
|
|
|
|
|
2010-03-05 05:35:37 +01:00
|
|
|
#define PERF_MAX_TRACE_SIZE 2048
|
2009-09-18 06:10:28 +02:00
|
|
|
|
2009-09-12 19:04:54 -04:00
|
|
|
#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2013-10-24 08:59:24 -05:00
|
|
|
enum event_trigger_type {
|
|
|
|
|
ETT_NONE = (0),
|
2013-10-24 08:59:25 -05:00
|
|
|
ETT_TRACE_ONOFF = (1 << 0),
|
2013-10-24 08:59:26 -05:00
|
|
|
ETT_SNAPSHOT = (1 << 1),
|
2013-10-24 08:59:27 -05:00
|
|
|
ETT_STACKTRACE = (1 << 2),
|
2013-10-24 08:59:28 -05:00
|
|
|
ETT_EVENT_ENABLE = (1 << 3),
|
2013-10-24 08:59:24 -05:00
|
|
|
};
|
|
|
|
|
|
2009-10-15 11:21:42 +08:00
|
|
|
extern int filter_match_preds(struct event_filter *filter, void *rec);
|
2013-10-24 08:34:17 -05:00
|
|
|
|
2015-05-05 10:09:53 -04:00
|
|
|
extern int filter_check_discard(struct trace_event_file *file, void *rec,
|
2013-10-24 08:34:17 -05:00
|
|
|
struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event);
|
2015-05-05 11:45:27 -04:00
|
|
|
extern int call_filter_check_discard(struct trace_event_call *call, void *rec,
|
2013-10-24 08:34:17 -05:00
|
|
|
struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event);
|
2015-05-05 10:09:53 -04:00
|
|
|
extern enum event_trigger_type event_triggers_call(struct trace_event_file *file,
|
2013-10-24 08:59:29 -05:00
|
|
|
void *rec);
|
2015-05-05 10:09:53 -04:00
|
|
|
extern void event_triggers_post_call(struct trace_event_file *file,
|
2013-10-24 08:59:29 -05:00
|
|
|
enum event_trigger_type tt);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2015-09-25 12:58:44 -04:00
|
|
|
bool trace_event_ignore_this_pid(struct trace_event_file *trace_file);
|
|
|
|
|
|
2014-01-06 21:32:10 -05:00
|
|
|
/**
|
2015-05-13 15:21:25 -04:00
|
|
|
* trace_trigger_soft_disabled - do triggers and test if soft disabled
|
2014-01-06 21:32:10 -05:00
|
|
|
* @file: The file pointer of the event to test
|
|
|
|
|
*
|
|
|
|
|
* If any triggers without filters are attached to this event, they
|
|
|
|
|
* will be called here. If the event is soft disabled and has no
|
|
|
|
|
* triggers that require testing the fields, it will return true,
|
|
|
|
|
* otherwise false.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool
|
2015-05-13 15:21:25 -04:00
|
|
|
trace_trigger_soft_disabled(struct trace_event_file *file)
|
2014-01-06 21:32:10 -05:00
|
|
|
{
|
|
|
|
|
unsigned long eflags = file->flags;
|
|
|
|
|
|
2015-05-13 15:12:33 -04:00
|
|
|
if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) {
|
|
|
|
|
if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
|
2014-01-06 21:32:10 -05:00
|
|
|
event_triggers_call(file, NULL);
|
2015-05-13 15:12:33 -04:00
|
|
|
if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
|
2014-01-06 21:32:10 -05:00
|
|
|
return true;
|
2015-09-25 12:58:44 -04:00
|
|
|
if (eflags & EVENT_FILE_FL_PID_FILTER)
|
|
|
|
|
return trace_event_ignore_this_pid(file);
|
2014-01-06 21:32:10 -05:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Helper function for event_trigger_unlock_commit{_regs}().
|
|
|
|
|
* If there are event triggers attached to this event that requires
|
|
|
|
|
* filtering against its fields, then they wil be called as the
|
|
|
|
|
* entry already holds the field information of the current event.
|
|
|
|
|
*
|
|
|
|
|
* It also checks if the event should be discarded or not.
|
|
|
|
|
* It is to be discarded if the event is soft disabled and the
|
|
|
|
|
* event was only recorded to process triggers, or if the event
|
|
|
|
|
* filter is active and this event did not match the filters.
|
|
|
|
|
*
|
|
|
|
|
* Returns true if the event is discarded, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool
|
2015-05-05 10:09:53 -04:00
|
|
|
__event_trigger_test_discard(struct trace_event_file *file,
|
2014-01-06 21:32:10 -05:00
|
|
|
struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event,
|
|
|
|
|
void *entry,
|
|
|
|
|
enum event_trigger_type *tt)
|
|
|
|
|
{
|
|
|
|
|
unsigned long eflags = file->flags;
|
|
|
|
|
|
2015-05-13 15:12:33 -04:00
|
|
|
if (eflags & EVENT_FILE_FL_TRIGGER_COND)
|
2014-01-06 21:32:10 -05:00
|
|
|
*tt = event_triggers_call(file, entry);
|
|
|
|
|
|
2015-05-13 15:12:33 -04:00
|
|
|
if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags))
|
2014-01-06 21:32:10 -05:00
|
|
|
ring_buffer_discard_commit(buffer, event);
|
|
|
|
|
else if (!filter_check_discard(file, entry, buffer, event))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* event_trigger_unlock_commit - handle triggers and finish event commit
|
|
|
|
|
* @file: The file pointer assoctiated to the event
|
|
|
|
|
* @buffer: The ring buffer that the event is being written to
|
|
|
|
|
* @event: The event meta data in the ring buffer
|
|
|
|
|
* @entry: The event itself
|
|
|
|
|
* @irq_flags: The state of the interrupts at the start of the event
|
|
|
|
|
* @pc: The state of the preempt count at the start of the event.
|
|
|
|
|
*
|
|
|
|
|
* This is a helper function to handle triggers that require data
|
|
|
|
|
* from the event itself. It also tests the event against filters and
|
|
|
|
|
* if the event is soft disabled and should be discarded.
|
|
|
|
|
*/
|
|
|
|
|
static inline void
|
2015-05-05 10:09:53 -04:00
|
|
|
event_trigger_unlock_commit(struct trace_event_file *file,
|
2014-01-06 21:32:10 -05:00
|
|
|
struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event,
|
|
|
|
|
void *entry, unsigned long irq_flags, int pc)
|
|
|
|
|
{
|
|
|
|
|
enum event_trigger_type tt = ETT_NONE;
|
|
|
|
|
|
|
|
|
|
if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
|
2015-09-25 17:38:44 -04:00
|
|
|
trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
|
2014-01-06 21:32:10 -05:00
|
|
|
|
|
|
|
|
if (tt)
|
|
|
|
|
event_triggers_post_call(file, tt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* event_trigger_unlock_commit_regs - handle triggers and finish event commit
|
|
|
|
|
* @file: The file pointer assoctiated to the event
|
|
|
|
|
* @buffer: The ring buffer that the event is being written to
|
|
|
|
|
* @event: The event meta data in the ring buffer
|
|
|
|
|
* @entry: The event itself
|
|
|
|
|
* @irq_flags: The state of the interrupts at the start of the event
|
|
|
|
|
* @pc: The state of the preempt count at the start of the event.
|
|
|
|
|
*
|
|
|
|
|
* This is a helper function to handle triggers that require data
|
|
|
|
|
* from the event itself. It also tests the event against filters and
|
|
|
|
|
* if the event is soft disabled and should be discarded.
|
|
|
|
|
*
|
|
|
|
|
* Same as event_trigger_unlock_commit() but calls
|
|
|
|
|
* trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
|
|
|
|
|
*/
|
|
|
|
|
static inline void
|
2015-05-05 10:09:53 -04:00
|
|
|
event_trigger_unlock_commit_regs(struct trace_event_file *file,
|
2014-01-06 21:32:10 -05:00
|
|
|
struct ring_buffer *buffer,
|
|
|
|
|
struct ring_buffer_event *event,
|
|
|
|
|
void *entry, unsigned long irq_flags, int pc,
|
|
|
|
|
struct pt_regs *regs)
|
|
|
|
|
{
|
|
|
|
|
enum event_trigger_type tt = ETT_NONE;
|
|
|
|
|
|
|
|
|
|
if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
|
2015-09-25 17:38:44 -04:00
|
|
|
trace_buffer_unlock_commit_regs(file->tr, buffer, event,
|
2014-01-06 21:32:10 -05:00
|
|
|
irq_flags, pc, regs);
|
|
|
|
|
|
|
|
|
|
if (tt)
|
|
|
|
|
event_triggers_post_call(file, tt);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 02:13:49 +00:00
|
|
|
#ifdef CONFIG_BPF_EVENTS
|
2015-03-25 12:49:20 -07:00
|
|
|
unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx);
|
|
|
|
|
#else
|
|
|
|
|
static inline unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-08-07 10:33:22 +08:00
|
|
|
enum {
|
|
|
|
|
FILTER_OTHER = 0,
|
|
|
|
|
FILTER_STATIC_STRING,
|
|
|
|
|
FILTER_DYN_STRING,
|
2009-08-07 10:33:43 +08:00
|
|
|
FILTER_PTR_STRING,
|
2012-02-15 15:51:53 +01:00
|
|
|
FILTER_TRACE_FN,
|
2009-08-07 10:33:22 +08:00
|
|
|
};
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
extern int trace_event_raw_init(struct trace_event_call *call);
|
|
|
|
|
extern int trace_define_field(struct trace_event_call *call, const char *type,
|
2009-08-27 05:09:51 +02:00
|
|
|
const char *name, int offset, int size,
|
|
|
|
|
int is_signed, int filter_type);
|
2015-05-05 11:45:27 -04:00
|
|
|
extern int trace_add_event_call(struct trace_event_call *call);
|
|
|
|
|
extern int trace_remove_event_call(struct trace_event_call *call);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2013-04-19 17:10:27 -04:00
|
|
|
#define is_signed_type(type) (((type)(-1)) < (type)1)
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2009-05-08 16:27:41 -04:00
|
|
|
int trace_set_clr_event(const char *system, const char *event, int set);
|
|
|
|
|
|
2009-04-13 11:20:49 -04:00
|
|
|
/*
|
|
|
|
|
* The double __builtin_constant_p is because gcc will give us an error
|
|
|
|
|
* if we try to allocate the static variable to fmt if it is not a
|
|
|
|
|
* constant. Even with the outer if statement optimizing out.
|
|
|
|
|
*/
|
|
|
|
|
#define event_trace_printk(ip, fmt, args...) \
|
|
|
|
|
do { \
|
|
|
|
|
__trace_printk_check_format(fmt, ##args); \
|
|
|
|
|
tracing_record_cmdline(current); \
|
|
|
|
|
if (__builtin_constant_p(fmt)) { \
|
|
|
|
|
static const char *trace_printk_fmt \
|
|
|
|
|
__attribute__((section("__trace_printk_fmt"))) = \
|
|
|
|
|
__builtin_constant_p(fmt) ? fmt : NULL; \
|
|
|
|
|
\
|
|
|
|
|
__trace_bprintk(ip, trace_printk_fmt, ##args); \
|
|
|
|
|
} else \
|
|
|
|
|
__trace_printk(ip, fmt, ##args); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2009-12-21 14:27:35 +08:00
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
2009-10-15 11:21:42 +08:00
|
|
|
struct perf_event;
|
2010-03-03 07:16:16 +01:00
|
|
|
|
|
|
|
|
DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
|
|
|
|
|
|
2010-05-19 14:02:22 +02:00
|
|
|
extern int perf_trace_init(struct perf_event *event);
|
|
|
|
|
extern void perf_trace_destroy(struct perf_event *event);
|
2010-06-16 14:37:10 +02:00
|
|
|
extern int perf_trace_add(struct perf_event *event, int flags);
|
|
|
|
|
extern void perf_trace_del(struct perf_event *event, int flags);
|
2010-05-19 14:02:22 +02:00
|
|
|
extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
|
2009-10-15 11:21:42 +08:00
|
|
|
char *filter_str);
|
|
|
|
|
extern void ftrace_profile_free_filter(struct perf_event *event);
|
2010-05-19 10:52:27 +02:00
|
|
|
extern void *perf_trace_buf_prepare(int size, unsigned short type,
|
2014-12-16 12:47:34 +01:00
|
|
|
struct pt_regs **regs, int *rctxp);
|
2010-01-28 09:32:29 +08:00
|
|
|
|
|
|
|
|
static inline void
|
2010-03-05 05:35:37 +01:00
|
|
|
perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
|
2012-07-11 18:14:58 +04:00
|
|
|
u64 count, struct pt_regs *regs, void *head,
|
|
|
|
|
struct task_struct *task)
|
2010-01-28 09:32:29 +08:00
|
|
|
{
|
2012-07-11 18:14:58 +04:00
|
|
|
perf_tp_event(addr, count, raw_data, size, regs, head, rctx, task);
|
2010-01-28 09:32:29 +08:00
|
|
|
}
|
2009-10-15 11:21:42 +08:00
|
|
|
#endif
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
#endif /* _LINUX_TRACE_EVENT_H */
|