2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
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;
|
2020-01-09 18:53:48 -05:00
|
|
|
struct array_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
|
|
|
|
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
|
2017-02-22 15:39:47 -08:00
|
|
|
const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
|
|
|
|
|
unsigned long long flags,
|
|
|
|
|
const struct trace_print_flags_u64 *flag_array);
|
|
|
|
|
|
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,
|
2017-01-25 02:28:16 +01:00
|
|
|
const unsigned char *buf, int len,
|
2017-02-02 17:09:54 +01:00
|
|
|
bool concatenate);
|
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);
|
|
|
|
|
|
2019-11-07 13:45:38 +01:00
|
|
|
const char *
|
|
|
|
|
trace_print_hex_dump_seq(struct trace_seq *p, const char *prefix_str,
|
|
|
|
|
int prefix_type, int rowsize, int groupsize,
|
|
|
|
|
const void *buf, size_t len, bool ascii);
|
|
|
|
|
|
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);
|
2020-10-15 23:55:07 +09:00
|
|
|
extern __printf(2, 3)
|
|
|
|
|
void trace_event_printf(struct trace_iterator *iter, const char *fmt, ...);
|
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;
|
2020-01-09 18:53:48 -05:00
|
|
|
struct array_buffer *array_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;
|
2020-03-17 17:32:23 -04:00
|
|
|
void *temp; /* temp holder */
|
|
|
|
|
unsigned int temp_size;
|
2020-10-15 23:55:07 +09:00
|
|
|
char *fmt; /* modified format holder */
|
|
|
|
|
unsigned int fmt_size;
|
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 */
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-16 11:01:06 -04:00
|
|
|
enum print_line_t trace_handle_return(struct trace_seq *s);
|
2014-11-12 10:29:54 -05:00
|
|
|
|
2021-01-25 20:45:08 +01:00
|
|
|
static inline void tracing_generic_entry_update(struct trace_entry *entry,
|
|
|
|
|
unsigned short type,
|
|
|
|
|
unsigned int trace_ctx)
|
|
|
|
|
{
|
|
|
|
|
entry->preempt_count = trace_ctx & 0xff;
|
2021-01-25 20:45:11 +01:00
|
|
|
entry->pid = current->pid;
|
2021-01-25 20:45:08 +01:00
|
|
|
entry->type = type;
|
|
|
|
|
entry->flags = trace_ctx >> 16;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 20:45:09 +01:00
|
|
|
unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status);
|
|
|
|
|
|
|
|
|
|
enum trace_flag_type {
|
|
|
|
|
TRACE_FLAG_IRQS_OFF = 0x01,
|
|
|
|
|
TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
|
|
|
|
|
TRACE_FLAG_NEED_RESCHED = 0x04,
|
|
|
|
|
TRACE_FLAG_HARDIRQ = 0x08,
|
|
|
|
|
TRACE_FLAG_SOFTIRQ = 0x10,
|
|
|
|
|
TRACE_FLAG_PREEMPT_RESCHED = 0x20,
|
|
|
|
|
TRACE_FLAG_NMI = 0x40,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
|
|
|
|
|
static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
|
|
|
|
|
{
|
|
|
|
|
unsigned int irq_status = irqs_disabled_flags(irqflags) ?
|
|
|
|
|
TRACE_FLAG_IRQS_OFF : 0;
|
|
|
|
|
return tracing_gen_ctx_irq_test(irq_status);
|
|
|
|
|
}
|
|
|
|
|
static inline unsigned int tracing_gen_ctx(void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long irqflags;
|
|
|
|
|
|
|
|
|
|
local_save_flags(irqflags);
|
|
|
|
|
return tracing_gen_ctx_flags(irqflags);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
static inline unsigned int tracing_gen_ctx_flags(unsigned long irqflags)
|
|
|
|
|
{
|
|
|
|
|
return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
|
|
|
|
|
}
|
|
|
|
|
static inline unsigned int tracing_gen_ctx(void)
|
|
|
|
|
{
|
|
|
|
|
return tracing_gen_ctx_irq_test(TRACE_FLAG_IRQS_NOSUPPORT);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static inline unsigned int tracing_gen_ctx_dec(void)
|
|
|
|
|
{
|
|
|
|
|
unsigned int trace_ctx;
|
|
|
|
|
|
|
|
|
|
trace_ctx = tracing_gen_ctx();
|
|
|
|
|
/*
|
2021-03-23 18:49:35 +01:00
|
|
|
* Subtract one from the preemption counter if preemption is enabled,
|
2021-01-25 20:45:09 +01:00
|
|
|
* see trace_event_buffer_reserve()for details.
|
|
|
|
|
*/
|
|
|
|
|
if (IS_ENABLED(CONFIG_PREEMPTION))
|
|
|
|
|
trace_ctx--;
|
|
|
|
|
return trace_ctx;
|
|
|
|
|
}
|
2021-01-25 20:45:08 +01:00
|
|
|
|
2015-05-05 10:09:53 -04:00
|
|
|
struct trace_event_file;
|
2012-08-02 10:32:10 -04:00
|
|
|
|
|
|
|
|
struct ring_buffer_event *
|
2019-12-13 13:58:57 -05:00
|
|
|
trace_event_buffer_lock_reserve(struct trace_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,
|
2021-01-25 20:45:08 +01:00
|
|
|
unsigned int trace_ctx);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
2017-06-26 19:01:55 -07:00
|
|
|
#define TRACE_RECORD_CMDLINE BIT(0)
|
|
|
|
|
#define TRACE_RECORD_TGID BIT(1)
|
|
|
|
|
|
|
|
|
|
void tracing_record_taskinfo(struct task_struct *task, int flags);
|
|
|
|
|
void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
|
|
|
|
|
struct task_struct *next, int flags);
|
|
|
|
|
|
|
|
|
|
void tracing_record_cmdline(struct task_struct *task);
|
|
|
|
|
void tracing_record_tgid(struct task_struct *task);
|
2009-04-13 11:20:49 -04:00
|
|
|
|
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,
|
2017-10-10 17:15:47 +02:00
|
|
|
/*
|
|
|
|
|
* These (ADD/DEL) use a 'boolean' return value, where 1 (true) means a
|
|
|
|
|
* custom action was taken and the default action is not to be
|
|
|
|
|
* performed.
|
|
|
|
|
*/
|
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
|
|
|
|
2019-10-24 22:26:59 +02:00
|
|
|
#define TRACE_FUNCTION_TYPE ((const char *)~0UL)
|
|
|
|
|
|
|
|
|
|
struct trace_event_fields {
|
|
|
|
|
const char *type;
|
|
|
|
|
union {
|
|
|
|
|
struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
const int size;
|
|
|
|
|
const int align;
|
|
|
|
|
const int is_signed;
|
|
|
|
|
const int filter_type;
|
|
|
|
|
};
|
|
|
|
|
int (*define_fields)(struct trace_event_call *);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
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);
|
2019-10-24 22:26:59 +02:00
|
|
|
struct trace_event_fields *fields_array;
|
2015-05-05 11:45:27 -04:00
|
|
|
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 {
|
2019-12-13 13:58:57 -05:00
|
|
|
struct trace_buffer *buffer;
|
2012-08-09 22:42:57 -04:00
|
|
|
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;
|
2021-01-25 20:45:08 +01:00
|
|
|
unsigned int trace_ctx;
|
2020-01-11 01:05:31 +09:00
|
|
|
struct pt_regs *regs;
|
2012-08-09 22:42:57 -04:00
|
|
|
};
|
|
|
|
|
|
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,
|
2014-04-08 17:26:21 -04:00
|
|
|
TRACE_EVENT_FL_TRACEPOINT_BIT,
|
2021-08-16 23:42:56 -04:00
|
|
|
TRACE_EVENT_FL_DYNAMIC_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
|
2014-04-08 17:26:21 -04:00
|
|
|
* TRACEPOINT - Event is a tracepoint
|
2021-08-16 23:42:56 -04:00
|
|
|
* DYNAMIC - Event is a dynamic event (created at run time)
|
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),
|
2014-04-08 17:26:21 -04:00
|
|
|
TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
|
2021-08-16 23:42:56 -04:00
|
|
|
TRACE_EVENT_FL_DYNAMIC = (1 << TRACE_EVENT_FL_DYNAMIC_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;
|
2021-08-16 23:42:57 -04:00
|
|
|
/*
|
|
|
|
|
* Static events can disappear with modules,
|
|
|
|
|
* where as dynamic ones need their own ref count.
|
|
|
|
|
*/
|
|
|
|
|
union {
|
|
|
|
|
void *module;
|
|
|
|
|
atomic_t refcnt;
|
|
|
|
|
};
|
2009-08-10 16:52:44 -04:00
|
|
|
void *data;
|
2021-02-26 14:09:15 -05:00
|
|
|
|
|
|
|
|
/* See the TRACE_EVENT_FL_* flags above */
|
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;
|
2017-10-23 23:53:08 -07:00
|
|
|
struct bpf_prog_array __rcu *prog_array;
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-16 23:42:57 -04:00
|
|
|
#ifdef CONFIG_DYNAMIC_EVENTS
|
|
|
|
|
bool trace_event_dyn_try_get_ref(struct trace_event_call *call);
|
|
|
|
|
void trace_event_dyn_put_ref(struct trace_event_call *call);
|
|
|
|
|
bool trace_event_dyn_busy(struct trace_event_call *call);
|
|
|
|
|
#else
|
|
|
|
|
static inline bool trace_event_dyn_try_get_ref(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
/* Without DYNAMIC_EVENTS configured, nothing should be calling this */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
static inline void trace_event_dyn_put_ref(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
static inline bool trace_event_dyn_busy(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
/* Nothing should call this without DYNAIMIC_EVENTS configured. */
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static inline bool trace_event_try_get_ref(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
if (call->flags & TRACE_EVENT_FL_DYNAMIC)
|
|
|
|
|
return trace_event_dyn_try_get_ref(call);
|
|
|
|
|
else
|
|
|
|
|
return try_module_get(call->module);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void trace_event_put_ref(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
if (call->flags & TRACE_EVENT_FL_DYNAMIC)
|
|
|
|
|
trace_event_dyn_put_ref(call);
|
|
|
|
|
else
|
|
|
|
|
module_put(call->module);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-23 23:53:08 -07:00
|
|
|
#ifdef CONFIG_PERF_EVENTS
|
|
|
|
|
static inline bool bpf_prog_array_valid(struct trace_event_call *call)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* This inline function checks whether call->prog_array
|
|
|
|
|
* is valid or not. The function is called in various places,
|
|
|
|
|
* outside rcu_read_lock/unlock, as a heuristic to speed up execution.
|
|
|
|
|
*
|
|
|
|
|
* If this function returns true, and later call->prog_array
|
|
|
|
|
* becomes false inside rcu_read_lock/unlock region,
|
|
|
|
|
* we bail out then. If this function return false,
|
|
|
|
|
* there is a risk that we might miss a few events if the checking
|
|
|
|
|
* were delayed until inside rcu_read_lock/unlock region and
|
|
|
|
|
* call->prog_array happened to become non-NULL then.
|
|
|
|
|
*
|
|
|
|
|
* Here, READ_ONCE() is used instead of rcu_access_pointer().
|
|
|
|
|
* rcu_access_pointer() requires the actual definition of
|
|
|
|
|
* "struct bpf_prog_array" while READ_ONCE() only needs
|
|
|
|
|
* a declaration of the same type.
|
|
|
|
|
*/
|
|
|
|
|
return !!READ_ONCE(call->prog_array);
|
|
|
|
|
}
|
|
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-25 09:58:01 -07:00
|
|
|
static inline struct list_head *
|
|
|
|
|
trace_get_fields(struct trace_event_call *event_call)
|
|
|
|
|
{
|
|
|
|
|
if (!event_call->class->get_fields)
|
|
|
|
|
return &event_call->class->fields;
|
|
|
|
|
return event_call->class->get_fields(event_call);
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
2017-06-26 19:01:55 -07:00
|
|
|
EVENT_FILE_FL_RECORDED_TGID_BIT,
|
2015-05-13 15:12:33 -04:00
|
|
|
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,
|
2017-08-31 17:03:47 -04:00
|
|
|
EVENT_FILE_FL_WAS_ENABLED_BIT,
|
2012-05-03 23:09:03 -04:00
|
|
|
};
|
|
|
|
|
|
2020-01-29 12:59:22 -06:00
|
|
|
extern struct trace_event_file *trace_get_event_file(const char *instance,
|
|
|
|
|
const char *system,
|
|
|
|
|
const char *event);
|
|
|
|
|
extern void trace_put_event_file(struct trace_event_file *file);
|
|
|
|
|
|
2020-01-29 12:59:24 -06:00
|
|
|
#define MAX_DYNEVENT_CMD_LEN (2048)
|
|
|
|
|
|
|
|
|
|
enum dynevent_type {
|
2020-01-29 12:59:25 -06:00
|
|
|
DYNEVENT_TYPE_SYNTH = 1,
|
2020-01-29 12:59:29 -06:00
|
|
|
DYNEVENT_TYPE_KPROBE,
|
2020-01-29 12:59:24 -06:00
|
|
|
DYNEVENT_TYPE_NONE,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct dynevent_cmd;
|
|
|
|
|
|
|
|
|
|
typedef int (*dynevent_create_fn_t)(struct dynevent_cmd *cmd);
|
|
|
|
|
|
|
|
|
|
struct dynevent_cmd {
|
2020-01-31 15:55:34 -06:00
|
|
|
struct seq_buf seq;
|
2020-01-29 12:59:24 -06:00
|
|
|
const char *event_name;
|
|
|
|
|
unsigned int n_fields;
|
|
|
|
|
enum dynevent_type type;
|
|
|
|
|
dynevent_create_fn_t run_command;
|
|
|
|
|
void *private_data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern int dynevent_create(struct dynevent_cmd *cmd);
|
|
|
|
|
|
2020-01-29 12:59:23 -06:00
|
|
|
extern int synth_event_delete(const char *name);
|
|
|
|
|
|
2020-01-29 12:59:25 -06:00
|
|
|
extern void synth_event_cmd_init(struct dynevent_cmd *cmd,
|
|
|
|
|
char *buf, int maxlen);
|
|
|
|
|
|
|
|
|
|
extern int __synth_event_gen_cmd_start(struct dynevent_cmd *cmd,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct module *mod, ...);
|
|
|
|
|
|
|
|
|
|
#define synth_event_gen_cmd_start(cmd, name, mod, ...) \
|
|
|
|
|
__synth_event_gen_cmd_start(cmd, name, mod, ## __VA_ARGS__, NULL)
|
|
|
|
|
|
|
|
|
|
struct synth_field_desc {
|
|
|
|
|
const char *type;
|
|
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern int synth_event_gen_cmd_array_start(struct dynevent_cmd *cmd,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct module *mod,
|
|
|
|
|
struct synth_field_desc *fields,
|
|
|
|
|
unsigned int n_fields);
|
|
|
|
|
extern int synth_event_create(const char *name,
|
|
|
|
|
struct synth_field_desc *fields,
|
|
|
|
|
unsigned int n_fields, struct module *mod);
|
|
|
|
|
|
|
|
|
|
extern int synth_event_add_field(struct dynevent_cmd *cmd,
|
|
|
|
|
const char *type,
|
|
|
|
|
const char *name);
|
|
|
|
|
extern int synth_event_add_field_str(struct dynevent_cmd *cmd,
|
|
|
|
|
const char *type_name);
|
|
|
|
|
extern int synth_event_add_fields(struct dynevent_cmd *cmd,
|
|
|
|
|
struct synth_field_desc *fields,
|
|
|
|
|
unsigned int n_fields);
|
|
|
|
|
|
|
|
|
|
#define synth_event_gen_cmd_end(cmd) \
|
|
|
|
|
dynevent_create(cmd)
|
|
|
|
|
|
2020-01-29 12:59:27 -06:00
|
|
|
struct synth_event;
|
|
|
|
|
|
|
|
|
|
struct synth_event_trace_state {
|
|
|
|
|
struct trace_event_buffer fbuffer;
|
|
|
|
|
struct synth_trace_event *entry;
|
|
|
|
|
struct trace_buffer *buffer;
|
|
|
|
|
struct synth_event *event;
|
|
|
|
|
unsigned int cur_field;
|
|
|
|
|
unsigned int n_u64;
|
2020-02-10 17:06:50 -06:00
|
|
|
bool disabled;
|
2020-01-29 12:59:27 -06:00
|
|
|
bool add_next;
|
|
|
|
|
bool add_name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern int synth_event_trace(struct trace_event_file *file,
|
|
|
|
|
unsigned int n_vals, ...);
|
|
|
|
|
extern int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
|
|
|
|
|
unsigned int n_vals);
|
|
|
|
|
extern int synth_event_trace_start(struct trace_event_file *file,
|
|
|
|
|
struct synth_event_trace_state *trace_state);
|
|
|
|
|
extern int synth_event_add_next_val(u64 val,
|
|
|
|
|
struct synth_event_trace_state *trace_state);
|
|
|
|
|
extern int synth_event_add_val(const char *field_name, u64 val,
|
|
|
|
|
struct synth_event_trace_state *trace_state);
|
|
|
|
|
extern int synth_event_trace_end(struct synth_event_trace_state *trace_state);
|
|
|
|
|
|
2020-01-29 12:59:29 -06:00
|
|
|
extern int kprobe_event_delete(const char *name);
|
|
|
|
|
|
|
|
|
|
extern void kprobe_event_cmd_init(struct dynevent_cmd *cmd,
|
|
|
|
|
char *buf, int maxlen);
|
|
|
|
|
|
|
|
|
|
#define kprobe_event_gen_cmd_start(cmd, name, loc, ...) \
|
|
|
|
|
__kprobe_event_gen_cmd_start(cmd, false, name, loc, ## __VA_ARGS__, NULL)
|
|
|
|
|
|
|
|
|
|
#define kretprobe_event_gen_cmd_start(cmd, name, loc, ...) \
|
|
|
|
|
__kprobe_event_gen_cmd_start(cmd, true, name, loc, ## __VA_ARGS__, NULL)
|
|
|
|
|
|
|
|
|
|
extern int __kprobe_event_gen_cmd_start(struct dynevent_cmd *cmd,
|
|
|
|
|
bool kretprobe,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *loc, ...);
|
|
|
|
|
|
|
|
|
|
#define kprobe_event_add_fields(cmd, ...) \
|
|
|
|
|
__kprobe_event_add_fields(cmd, ## __VA_ARGS__, NULL)
|
|
|
|
|
|
|
|
|
|
#define kprobe_event_add_field(cmd, field) \
|
|
|
|
|
__kprobe_event_add_fields(cmd, field, NULL)
|
|
|
|
|
|
|
|
|
|
extern int __kprobe_event_add_fields(struct dynevent_cmd *cmd, ...);
|
|
|
|
|
|
|
|
|
|
#define kprobe_event_gen_cmd_end(cmd) \
|
|
|
|
|
dynevent_create(cmd)
|
|
|
|
|
|
|
|
|
|
#define kretprobe_event_gen_cmd_end(cmd) \
|
|
|
|
|
dynevent_create(cmd)
|
|
|
|
|
|
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
|
2017-06-26 19:01:55 -07:00
|
|
|
* RECORDED_TGID - The tgids 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
|
2017-08-31 17:03:47 -04:00
|
|
|
* WAS_ENABLED - Set when enabled to know to clear trace on module removal
|
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),
|
2017-06-26 19:01:55 -07:00
|
|
|
EVENT_FILE_FL_RECORDED_TGID = (1 << EVENT_FILE_FL_RECORDED_TGID_BIT),
|
2015-05-13 15:12:33 -04:00
|
|
|
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),
|
2017-08-31 17:03:47 -04:00
|
|
|
EVENT_FILE_FL_WAS_ENABLED = (1 << EVENT_FILE_FL_WAS_ENABLED_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;
|
2017-06-07 16:12:51 +08:00
|
|
|
struct event_filter __rcu *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),
|
2016-03-03 12:54:42 -06:00
|
|
|
ETT_EVENT_HIST = (1 << 4),
|
2016-03-03 12:54:55 -06:00
|
|
|
ETT_HIST_ENABLE = (1 << 5),
|
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
|
|
|
|
2018-01-15 20:51:42 -06:00
|
|
|
extern enum event_trigger_type
|
2021-03-16 12:41:03 -04:00
|
|
|
event_triggers_call(struct trace_event_file *file,
|
|
|
|
|
struct trace_buffer *buffer, void *rec,
|
2018-01-15 20:51:42 -06:00
|
|
|
struct ring_buffer_event *event);
|
|
|
|
|
extern void
|
|
|
|
|
event_triggers_post_call(struct trace_event_file *file,
|
2018-05-07 16:02:14 -04: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)
|
2021-03-16 12:41:03 -04:00
|
|
|
event_triggers_call(file, NULL, NULL, 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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 02:13:49 +00:00
|
|
|
#ifdef CONFIG_BPF_EVENTS
|
2017-10-23 23:53:08 -07:00
|
|
|
unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx);
|
|
|
|
|
int perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog);
|
|
|
|
|
void perf_event_detach_bpf_prog(struct perf_event *event);
|
2017-12-13 10:35:37 -08:00
|
|
|
int perf_event_query_prog_array(struct perf_event *event, void __user *info);
|
2018-03-28 12:05:37 -07:00
|
|
|
int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *prog);
|
|
|
|
|
int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf_prog *prog);
|
2018-12-12 16:42:37 -08:00
|
|
|
struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name);
|
|
|
|
|
void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp);
|
2018-05-24 11:21:09 -07:00
|
|
|
int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
|
|
|
|
|
u32 *fd_type, const char **buf,
|
|
|
|
|
u64 *probe_offset, u64 *probe_addr);
|
2015-03-25 12:49:20 -07:00
|
|
|
#else
|
2017-10-23 23:53:08 -07:00
|
|
|
static inline unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx)
|
2015-03-25 12:49:20 -07:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2017-10-23 23:53:08 -07:00
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
|
perf_event_attach_bpf_prog(struct perf_event *event, struct bpf_prog *prog)
|
|
|
|
|
{
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void perf_event_detach_bpf_prog(struct perf_event *event) { }
|
|
|
|
|
|
2017-12-13 10:35:37 -08:00
|
|
|
static inline int
|
|
|
|
|
perf_event_query_prog_array(struct perf_event *event, void __user *info)
|
|
|
|
|
{
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
2018-03-28 12:05:37 -07:00
|
|
|
static inline int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *p)
|
|
|
|
|
{
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
static inline int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf_prog *p)
|
|
|
|
|
{
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
2018-12-12 16:42:37 -08:00
|
|
|
static inline struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name)
|
2018-03-28 12:05:37 -07:00
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-12-12 16:42:37 -08:00
|
|
|
static inline void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-05-24 11:21:09 -07:00
|
|
|
static inline int bpf_get_perf_event_info(const struct perf_event *event,
|
|
|
|
|
u32 *prog_id, u32 *fd_type,
|
|
|
|
|
const char **buf, u64 *probe_offset,
|
|
|
|
|
u64 *probe_addr)
|
|
|
|
|
{
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
2015-03-25 12:49:20 -07:00
|
|
|
#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,
|
2016-03-03 17:18:20 -05:00
|
|
|
FILTER_COMM,
|
|
|
|
|
FILTER_CPU,
|
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);
|
2016-04-06 18:43:28 -07:00
|
|
|
extern int trace_event_get_offsets(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
|
|
|
|
2019-07-04 20:21:10 +03:00
|
|
|
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
|
2009-05-08 16:27:41 -04:00
|
|
|
int trace_set_clr_event(const char *system, const char *event, int set);
|
2019-11-20 11:08:38 -08:00
|
|
|
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
|
|
|
|
|
const char *event, bool enable);
|
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 \
|
2020-10-21 19:36:07 -07:00
|
|
|
__section("__trace_printk_fmt") = \
|
2009-04-13 11:20:49 -04:00
|
|
|
__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);
|
2017-12-11 11:36:48 -05:00
|
|
|
DECLARE_PER_CPU(int, bpf_kprobe_override);
|
2010-03-03 07:16:16 +01:00
|
|
|
|
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);
|
2017-12-06 14:45:15 -08:00
|
|
|
#ifdef CONFIG_KPROBE_EVENTS
|
|
|
|
|
extern int perf_kprobe_init(struct perf_event *event, bool is_retprobe);
|
|
|
|
|
extern void perf_kprobe_destroy(struct perf_event *event);
|
2018-05-24 11:21:09 -07:00
|
|
|
extern int bpf_get_kprobe_info(const struct perf_event *event,
|
|
|
|
|
u32 *fd_type, const char **symbol,
|
|
|
|
|
u64 *probe_offset, u64 *probe_addr,
|
|
|
|
|
bool perf_type_tracepoint);
|
2017-12-06 14:45:15 -08:00
|
|
|
#endif
|
2017-12-06 14:45:16 -08:00
|
|
|
#ifdef CONFIG_UPROBE_EVENTS
|
2018-10-01 22:36:36 -07:00
|
|
|
extern int perf_uprobe_init(struct perf_event *event,
|
|
|
|
|
unsigned long ref_ctr_offset, bool is_retprobe);
|
2017-12-06 14:45:16 -08:00
|
|
|
extern void perf_uprobe_destroy(struct perf_event *event);
|
2018-05-24 11:21:09 -07:00
|
|
|
extern int bpf_get_uprobe_info(const struct perf_event *event,
|
|
|
|
|
u32 *fd_type, const char **filename,
|
|
|
|
|
u64 *probe_offset, bool perf_type_tracepoint);
|
2017-12-06 14:45:16 -08:00
|
|
|
#endif
|
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);
|
2016-04-06 18:43:24 -07:00
|
|
|
void perf_trace_buf_update(void *record, u16 type);
|
|
|
|
|
void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int *rctxp);
|
2010-01-28 09:32:29 +08:00
|
|
|
|
2018-03-28 12:05:37 -07:00
|
|
|
void bpf_trace_run1(struct bpf_prog *prog, u64 arg1);
|
|
|
|
|
void bpf_trace_run2(struct bpf_prog *prog, u64 arg1, u64 arg2);
|
|
|
|
|
void bpf_trace_run3(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3);
|
|
|
|
|
void bpf_trace_run4(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4);
|
|
|
|
|
void bpf_trace_run5(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5);
|
|
|
|
|
void bpf_trace_run6(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6);
|
|
|
|
|
void bpf_trace_run7(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7);
|
|
|
|
|
void bpf_trace_run8(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
|
|
|
|
|
u64 arg8);
|
|
|
|
|
void bpf_trace_run9(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
|
|
|
|
|
u64 arg8, u64 arg9);
|
|
|
|
|
void bpf_trace_run10(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
|
|
|
|
|
u64 arg8, u64 arg9, u64 arg10);
|
|
|
|
|
void bpf_trace_run11(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
|
|
|
|
|
u64 arg8, u64 arg9, u64 arg10, u64 arg11);
|
|
|
|
|
void bpf_trace_run12(struct bpf_prog *prog, u64 arg1, u64 arg2,
|
|
|
|
|
u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7,
|
|
|
|
|
u64 arg8, u64 arg9, u64 arg10, u64 arg11, u64 arg12);
|
2016-04-18 20:11:50 -07:00
|
|
|
void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
|
|
|
|
|
struct trace_event_call *call, u64 count,
|
|
|
|
|
struct pt_regs *regs, struct hlist_head *head,
|
|
|
|
|
struct task_struct *task);
|
|
|
|
|
|
2010-01-28 09:32:29 +08:00
|
|
|
static inline void
|
2016-04-06 18:43:24 -07:00
|
|
|
perf_trace_buf_submit(void *raw_data, int size, int rctx, u16 type,
|
2012-07-11 18:14:58 +04:00
|
|
|
u64 count, struct pt_regs *regs, void *head,
|
2017-10-11 09:45:29 +02:00
|
|
|
struct task_struct *task)
|
2010-01-28 09:32:29 +08:00
|
|
|
{
|
2017-10-11 09:45:29 +02:00
|
|
|
perf_tp_event(type, count, raw_data, size, regs, head, rctx, task);
|
2010-01-28 09:32:29 +08:00
|
|
|
}
|
2017-10-23 23:53:08 -07:00
|
|
|
|
2009-10-15 11:21:42 +08:00
|
|
|
#endif
|
|
|
|
|
|
2015-05-05 11:45:27 -04:00
|
|
|
#endif /* _LINUX_TRACE_EVENT_H */
|