You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (61 commits) tracing: Add __used annotation to event variable perf, trace: Fix !x86 build bug perf report: Support multiple events on the TUI perf annotate: Fix up usage of the build id cache x86/mmiotrace: Remove redundant instruction prefix checks perf annotate: Add TUI interface perf tui: Remove annotate from popup menu after failure perf report: Don't start the TUI if -D is used perf: Fix getline undeclared perf: Optimize perf_tp_event_match() perf: Remove more code from the fastpath perf: Optimize the !vmalloc backed buffer perf: Optimize perf_output_copy() perf: Fix wakeup storm for RO mmap()s perf-record: Share per-cpu buffers perf-record: Remove -M perf: Ensure that IOC_OUTPUT isn't used to create multi-writer buffers perf, trace: Optimize tracepoints by using per-tracepoint-per-cpu hlist to track events perf, trace: Optimize tracepoints by removing IRQ-disable from perf/tracepoint interaction perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig ...
This commit is contained in:
@@ -92,6 +92,8 @@ struct cpu_hw_events {
|
||||
|
||||
/* Enabled/disable state. */
|
||||
int enabled;
|
||||
|
||||
unsigned int group_flag;
|
||||
};
|
||||
DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, };
|
||||
|
||||
@@ -981,53 +983,6 @@ static int collect_events(struct perf_event *group, int max_count,
|
||||
return n;
|
||||
}
|
||||
|
||||
static void event_sched_in(struct perf_event *event)
|
||||
{
|
||||
event->state = PERF_EVENT_STATE_ACTIVE;
|
||||
event->oncpu = smp_processor_id();
|
||||
event->tstamp_running += event->ctx->time - event->tstamp_stopped;
|
||||
if (is_software_event(event))
|
||||
event->pmu->enable(event);
|
||||
}
|
||||
|
||||
int hw_perf_group_sched_in(struct perf_event *group_leader,
|
||||
struct perf_cpu_context *cpuctx,
|
||||
struct perf_event_context *ctx)
|
||||
{
|
||||
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
|
||||
struct perf_event *sub;
|
||||
int n0, n;
|
||||
|
||||
if (!sparc_pmu)
|
||||
return 0;
|
||||
|
||||
n0 = cpuc->n_events;
|
||||
n = collect_events(group_leader, perf_max_events - n0,
|
||||
&cpuc->event[n0], &cpuc->events[n0],
|
||||
&cpuc->current_idx[n0]);
|
||||
if (n < 0)
|
||||
return -EAGAIN;
|
||||
if (check_excludes(cpuc->event, n0, n))
|
||||
return -EINVAL;
|
||||
if (sparc_check_constraints(cpuc->event, cpuc->events, n + n0))
|
||||
return -EAGAIN;
|
||||
cpuc->n_events = n0 + n;
|
||||
cpuc->n_added += n;
|
||||
|
||||
cpuctx->active_oncpu += n;
|
||||
n = 1;
|
||||
event_sched_in(group_leader);
|
||||
list_for_each_entry(sub, &group_leader->sibling_list, group_entry) {
|
||||
if (sub->state != PERF_EVENT_STATE_OFF) {
|
||||
event_sched_in(sub);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
ctx->nr_active += n;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int sparc_pmu_enable(struct perf_event *event)
|
||||
{
|
||||
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
|
||||
@@ -1045,11 +1000,20 @@ static int sparc_pmu_enable(struct perf_event *event)
|
||||
cpuc->events[n0] = event->hw.event_base;
|
||||
cpuc->current_idx[n0] = PIC_NO_INDEX;
|
||||
|
||||
/*
|
||||
* If group events scheduling transaction was started,
|
||||
* skip the schedulability test here, it will be peformed
|
||||
* at commit time(->commit_txn) as a whole
|
||||
*/
|
||||
if (cpuc->group_flag & PERF_EVENT_TXN_STARTED)
|
||||
goto nocheck;
|
||||
|
||||
if (check_excludes(cpuc->event, n0, 1))
|
||||
goto out;
|
||||
if (sparc_check_constraints(cpuc->event, cpuc->events, n0 + 1))
|
||||
goto out;
|
||||
|
||||
nocheck:
|
||||
cpuc->n_events++;
|
||||
cpuc->n_added++;
|
||||
|
||||
@@ -1129,11 +1093,61 @@ static int __hw_perf_event_init(struct perf_event *event)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start group events scheduling transaction
|
||||
* Set the flag to make pmu::enable() not perform the
|
||||
* schedulability test, it will be performed at commit time
|
||||
*/
|
||||
static void sparc_pmu_start_txn(const struct pmu *pmu)
|
||||
{
|
||||
struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
|
||||
|
||||
cpuhw->group_flag |= PERF_EVENT_TXN_STARTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop group events scheduling transaction
|
||||
* Clear the flag and pmu::enable() will perform the
|
||||
* schedulability test.
|
||||
*/
|
||||
static void sparc_pmu_cancel_txn(const struct pmu *pmu)
|
||||
{
|
||||
struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
|
||||
|
||||
cpuhw->group_flag &= ~PERF_EVENT_TXN_STARTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Commit group events scheduling transaction
|
||||
* Perform the group schedulability test as a whole
|
||||
* Return 0 if success
|
||||
*/
|
||||
static int sparc_pmu_commit_txn(const struct pmu *pmu)
|
||||
{
|
||||
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
|
||||
int n;
|
||||
|
||||
if (!sparc_pmu)
|
||||
return -EINVAL;
|
||||
|
||||
cpuc = &__get_cpu_var(cpu_hw_events);
|
||||
n = cpuc->n_events;
|
||||
if (check_excludes(cpuc->event, 0, n))
|
||||
return -EINVAL;
|
||||
if (sparc_check_constraints(cpuc->event, cpuc->events, n))
|
||||
return -EAGAIN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pmu pmu = {
|
||||
.enable = sparc_pmu_enable,
|
||||
.disable = sparc_pmu_disable,
|
||||
.read = sparc_pmu_read,
|
||||
.unthrottle = sparc_pmu_unthrottle,
|
||||
.start_txn = sparc_pmu_start_txn,
|
||||
.cancel_txn = sparc_pmu_cancel_txn,
|
||||
.commit_txn = sparc_pmu_commit_txn,
|
||||
};
|
||||
|
||||
const struct pmu *hw_perf_event_init(struct perf_event *event)
|
||||
|
||||
@@ -89,7 +89,8 @@
|
||||
P4_CCCR_ENABLE)
|
||||
|
||||
/* HT mask */
|
||||
#define P4_CCCR_MASK_HT (P4_CCCR_MASK | P4_CCCR_THREAD_ANY)
|
||||
#define P4_CCCR_MASK_HT \
|
||||
(P4_CCCR_MASK | P4_CCCR_OVF_PMI_T1 | P4_CCCR_THREAD_ANY)
|
||||
|
||||
#define P4_GEN_ESCR_EMASK(class, name, bit) \
|
||||
class##__##name = ((1 << bit) << P4_ESCR_EVENTMASK_SHIFT)
|
||||
|
||||
@@ -1717,7 +1717,11 @@ void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int ski
|
||||
*/
|
||||
regs->bp = rewind_frame_pointer(skip + 1);
|
||||
regs->cs = __KERNEL_CS;
|
||||
local_save_flags(regs->flags);
|
||||
/*
|
||||
* We abuse bit 3 to pass exact information, see perf_misc_flags
|
||||
* and the comment with PERF_EFLAGS_EXACT.
|
||||
*/
|
||||
regs->flags = 0;
|
||||
}
|
||||
|
||||
unsigned long perf_instruction_pointer(struct pt_regs *regs)
|
||||
|
||||
@@ -465,15 +465,21 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline void p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc)
|
||||
static inline int p4_pmu_clear_cccr_ovf(struct hw_perf_event *hwc)
|
||||
{
|
||||
unsigned long dummy;
|
||||
int overflow = 0;
|
||||
u32 low, high;
|
||||
|
||||
rdmsrl(hwc->config_base + hwc->idx, dummy);
|
||||
if (dummy & P4_CCCR_OVF) {
|
||||
rdmsr(hwc->config_base + hwc->idx, low, high);
|
||||
|
||||
/* we need to check high bit for unflagged overflows */
|
||||
if ((low & P4_CCCR_OVF) || !(high & (1 << 31))) {
|
||||
overflow = 1;
|
||||
(void)checking_wrmsrl(hwc->config_base + hwc->idx,
|
||||
((u64)dummy) & ~P4_CCCR_OVF);
|
||||
((u64)low) & ~P4_CCCR_OVF);
|
||||
}
|
||||
|
||||
return overflow;
|
||||
}
|
||||
|
||||
static inline void p4_pmu_disable_event(struct perf_event *event)
|
||||
@@ -584,21 +590,15 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
|
||||
|
||||
WARN_ON_ONCE(hwc->idx != idx);
|
||||
|
||||
/*
|
||||
* FIXME: Redundant call, actually not needed
|
||||
* but just to check if we're screwed
|
||||
*/
|
||||
p4_pmu_clear_cccr_ovf(hwc);
|
||||
/* it might be unflagged overflow */
|
||||
handled = p4_pmu_clear_cccr_ovf(hwc);
|
||||
|
||||
val = x86_perf_event_update(event);
|
||||
if (val & (1ULL << (x86_pmu.cntval_bits - 1)))
|
||||
if (!handled && (val & (1ULL << (x86_pmu.cntval_bits - 1))))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* event overflow
|
||||
*/
|
||||
handled = 1;
|
||||
data.period = event->hw.last_period;
|
||||
/* event overflow for sure */
|
||||
data.period = event->hw.last_period;
|
||||
|
||||
if (!x86_perf_event_set_period(event))
|
||||
continue;
|
||||
@@ -670,7 +670,7 @@ static void p4_pmu_swap_config_ts(struct hw_perf_event *hwc, int cpu)
|
||||
|
||||
/*
|
||||
* ESCR address hashing is tricky, ESCRs are not sequential
|
||||
* in memory but all starts from MSR_P4_BSU_ESCR0 (0x03e0) and
|
||||
* in memory but all starts from MSR_P4_BSU_ESCR0 (0x03a0) and
|
||||
* the metric between any ESCRs is laid in range [0xa0,0xe1]
|
||||
*
|
||||
* so we make ~70% filled hashtable
|
||||
@@ -735,8 +735,9 @@ static int p4_get_escr_idx(unsigned int addr)
|
||||
{
|
||||
unsigned int idx = P4_ESCR_MSR_IDX(addr);
|
||||
|
||||
if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE ||
|
||||
!p4_escr_table[idx])) {
|
||||
if (unlikely(idx >= P4_ESCR_MSR_TABLE_SIZE ||
|
||||
!p4_escr_table[idx] ||
|
||||
p4_escr_table[idx] != addr)) {
|
||||
WARN_ONCE(1, "P4 PMU: Wrong address passed: %x\n", addr);
|
||||
return -1;
|
||||
}
|
||||
@@ -762,7 +763,7 @@ static int p4_pmu_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign
|
||||
{
|
||||
unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
|
||||
unsigned long escr_mask[BITS_TO_LONGS(P4_ESCR_MSR_TABLE_SIZE)];
|
||||
int cpu = raw_smp_processor_id();
|
||||
int cpu = smp_processor_id();
|
||||
struct hw_perf_event *hwc;
|
||||
struct p4_event_bind *bind;
|
||||
unsigned int i, thread, num;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
/* IA32 Manual 3, 2-1 */
|
||||
static unsigned char prefix_codes[] = {
|
||||
0xF0, 0xF2, 0xF3, 0x2E, 0x36, 0x3E, 0x26, 0x64,
|
||||
0x65, 0x2E, 0x3E, 0x66, 0x67
|
||||
0x65, 0x66, 0x67
|
||||
};
|
||||
/* IA32 Manual 3, 3-432*/
|
||||
static unsigned int reg_rop[] = {
|
||||
|
||||
@@ -73,18 +73,25 @@ struct trace_iterator {
|
||||
};
|
||||
|
||||
|
||||
struct trace_event;
|
||||
|
||||
typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
|
||||
int flags);
|
||||
struct trace_event {
|
||||
struct hlist_node node;
|
||||
struct list_head list;
|
||||
int type;
|
||||
int flags, struct trace_event *event);
|
||||
|
||||
struct trace_event_functions {
|
||||
trace_print_func trace;
|
||||
trace_print_func raw;
|
||||
trace_print_func hex;
|
||||
trace_print_func binary;
|
||||
};
|
||||
|
||||
struct trace_event {
|
||||
struct hlist_node node;
|
||||
struct list_head list;
|
||||
int type;
|
||||
struct trace_event_functions *funcs;
|
||||
};
|
||||
|
||||
extern int register_ftrace_event(struct trace_event *event);
|
||||
extern int unregister_ftrace_event(struct trace_event *event);
|
||||
|
||||
@@ -116,28 +123,70 @@ void tracing_record_cmdline(struct task_struct *tsk);
|
||||
|
||||
struct event_filter;
|
||||
|
||||
enum trace_reg {
|
||||
TRACE_REG_REGISTER,
|
||||
TRACE_REG_UNREGISTER,
|
||||
TRACE_REG_PERF_REGISTER,
|
||||
TRACE_REG_PERF_UNREGISTER,
|
||||
};
|
||||
|
||||
struct ftrace_event_call;
|
||||
|
||||
struct ftrace_event_class {
|
||||
char *system;
|
||||
void *probe;
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
void *perf_probe;
|
||||
#endif
|
||||
int (*reg)(struct ftrace_event_call *event,
|
||||
enum trace_reg type);
|
||||
int (*define_fields)(struct ftrace_event_call *);
|
||||
struct list_head *(*get_fields)(struct ftrace_event_call *);
|
||||
struct list_head fields;
|
||||
int (*raw_init)(struct ftrace_event_call *);
|
||||
};
|
||||
|
||||
enum {
|
||||
TRACE_EVENT_FL_ENABLED_BIT,
|
||||
TRACE_EVENT_FL_FILTERED_BIT,
|
||||
};
|
||||
|
||||
enum {
|
||||
TRACE_EVENT_FL_ENABLED = (1 << TRACE_EVENT_FL_ENABLED_BIT),
|
||||
TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
|
||||
};
|
||||
|
||||
struct ftrace_event_call {
|
||||
struct list_head list;
|
||||
struct ftrace_event_class *class;
|
||||
char *name;
|
||||
char *system;
|
||||
struct dentry *dir;
|
||||
struct trace_event *event;
|
||||
int enabled;
|
||||
int (*regfunc)(struct ftrace_event_call *);
|
||||
void (*unregfunc)(struct ftrace_event_call *);
|
||||
int id;
|
||||
struct trace_event event;
|
||||
const char *print_fmt;
|
||||
int (*raw_init)(struct ftrace_event_call *);
|
||||
int (*define_fields)(struct ftrace_event_call *);
|
||||
struct list_head fields;
|
||||
int filter_active;
|
||||
struct event_filter *filter;
|
||||
void *mod;
|
||||
void *data;
|
||||
|
||||
/*
|
||||
* 32 bit flags:
|
||||
* bit 1: enabled
|
||||
* bit 2: filter_active
|
||||
*
|
||||
* Changes to flags must hold the event_mutex.
|
||||
*
|
||||
* Note: Reads of flags do not hold the event_mutex since
|
||||
* they occur in critical sections. But the way flags
|
||||
* is currently used, these changes do no affect the code
|
||||
* except that when a change is made, it may have a slight
|
||||
* delay in propagating the changes to other CPUs due to
|
||||
* caching and such.
|
||||
*/
|
||||
unsigned int flags;
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
int perf_refcount;
|
||||
int (*perf_event_enable)(struct ftrace_event_call *);
|
||||
void (*perf_event_disable)(struct ftrace_event_call *);
|
||||
struct hlist_head *perf_events;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define PERF_MAX_TRACE_SIZE 2048
|
||||
@@ -194,24 +243,22 @@ struct perf_event;
|
||||
|
||||
DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
|
||||
|
||||
extern int perf_trace_enable(int event_id);
|
||||
extern void perf_trace_disable(int event_id);
|
||||
extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
|
||||
extern int perf_trace_init(struct perf_event *event);
|
||||
extern void perf_trace_destroy(struct perf_event *event);
|
||||
extern int perf_trace_enable(struct perf_event *event);
|
||||
extern void perf_trace_disable(struct perf_event *event);
|
||||
extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
|
||||
char *filter_str);
|
||||
extern void ftrace_profile_free_filter(struct perf_event *event);
|
||||
extern void *
|
||||
perf_trace_buf_prepare(int size, unsigned short type, int *rctxp,
|
||||
unsigned long *irq_flags);
|
||||
extern void *perf_trace_buf_prepare(int size, unsigned short type,
|
||||
struct pt_regs *regs, int *rctxp);
|
||||
|
||||
static inline void
|
||||
perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
|
||||
u64 count, unsigned long irq_flags, struct pt_regs *regs)
|
||||
u64 count, struct pt_regs *regs, void *head)
|
||||
{
|
||||
struct trace_entry *entry = raw_data;
|
||||
|
||||
perf_tp_event(entry->type, addr, count, raw_data, size, regs);
|
||||
perf_tp_event(addr, count, raw_data, size, regs, head);
|
||||
perf_swevent_put_recursion_context(rctx);
|
||||
local_irq_restore(irq_flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+15
-13
@@ -485,6 +485,7 @@ struct perf_guest_info_callbacks {
|
||||
#include <linux/ftrace.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/local.h>
|
||||
|
||||
#define PERF_MAX_STACK_DEPTH 255
|
||||
|
||||
@@ -587,21 +588,19 @@ struct perf_mmap_data {
|
||||
struct rcu_head rcu_head;
|
||||
#ifdef CONFIG_PERF_USE_VMALLOC
|
||||
struct work_struct work;
|
||||
int page_order; /* allocation order */
|
||||
#endif
|
||||
int data_order;
|
||||
int nr_pages; /* nr of data pages */
|
||||
int writable; /* are we writable */
|
||||
int nr_locked; /* nr pages mlocked */
|
||||
|
||||
atomic_t poll; /* POLL_ for wakeups */
|
||||
atomic_t events; /* event_id limit */
|
||||
|
||||
atomic_long_t head; /* write position */
|
||||
atomic_long_t done_head; /* completed head */
|
||||
|
||||
atomic_t lock; /* concurrent writes */
|
||||
atomic_t wakeup; /* needs a wakeup */
|
||||
atomic_t lost; /* nr records lost */
|
||||
local_t head; /* write position */
|
||||
local_t nest; /* nested writers */
|
||||
local_t events; /* event limit */
|
||||
local_t wakeup; /* wakeup stamp */
|
||||
local_t lost; /* nr records lost */
|
||||
|
||||
long watermark; /* wakeup watermark */
|
||||
|
||||
@@ -728,6 +727,7 @@ struct perf_event {
|
||||
perf_overflow_handler_t overflow_handler;
|
||||
|
||||
#ifdef CONFIG_EVENT_TRACING
|
||||
struct ftrace_event_call *tp_event;
|
||||
struct event_filter *filter;
|
||||
#endif
|
||||
|
||||
@@ -803,11 +803,12 @@ struct perf_cpu_context {
|
||||
struct perf_output_handle {
|
||||
struct perf_event *event;
|
||||
struct perf_mmap_data *data;
|
||||
unsigned long head;
|
||||
unsigned long offset;
|
||||
unsigned long wakeup;
|
||||
unsigned long size;
|
||||
void *addr;
|
||||
int page;
|
||||
int nmi;
|
||||
int sample;
|
||||
int locked;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
@@ -993,8 +994,9 @@ static inline bool perf_paranoid_kernel(void)
|
||||
}
|
||||
|
||||
extern void perf_event_init(void);
|
||||
extern void perf_tp_event(int event_id, u64 addr, u64 count, void *record,
|
||||
int entry_size, struct pt_regs *regs);
|
||||
extern void perf_tp_event(u64 addr, u64 count, void *record,
|
||||
int entry_size, struct pt_regs *regs,
|
||||
struct hlist_head *head);
|
||||
extern void perf_bp_event(struct perf_event *event, void *data);
|
||||
|
||||
#ifndef perf_misc_flags
|
||||
|
||||
+17
-40
@@ -103,22 +103,6 @@ struct perf_event_attr;
|
||||
#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
|
||||
#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
|
||||
#define TRACE_SYS_ENTER_PERF_INIT(sname) \
|
||||
.perf_event_enable = perf_sysenter_enable, \
|
||||
.perf_event_disable = perf_sysenter_disable,
|
||||
|
||||
#define TRACE_SYS_EXIT_PERF_INIT(sname) \
|
||||
.perf_event_enable = perf_sysexit_enable, \
|
||||
.perf_event_disable = perf_sysexit_disable,
|
||||
#else
|
||||
#define TRACE_SYS_ENTER_PERF(sname)
|
||||
#define TRACE_SYS_ENTER_PERF_INIT(sname)
|
||||
#define TRACE_SYS_EXIT_PERF(sname)
|
||||
#define TRACE_SYS_EXIT_PERF_INIT(sname)
|
||||
#endif /* CONFIG_PERF_EVENTS */
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
#define __SC_STR_ADECL1(t, a) #a
|
||||
#define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__)
|
||||
@@ -134,54 +118,43 @@ struct perf_event_attr;
|
||||
#define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__)
|
||||
#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__)
|
||||
|
||||
extern struct ftrace_event_class event_class_syscall_enter;
|
||||
extern struct ftrace_event_class event_class_syscall_exit;
|
||||
extern struct trace_event_functions enter_syscall_print_funcs;
|
||||
extern struct trace_event_functions exit_syscall_print_funcs;
|
||||
|
||||
#define SYSCALL_TRACE_ENTER_EVENT(sname) \
|
||||
static const struct syscall_metadata __syscall_meta_##sname; \
|
||||
static struct syscall_metadata __syscall_meta_##sname; \
|
||||
static struct ftrace_event_call \
|
||||
__attribute__((__aligned__(4))) event_enter_##sname; \
|
||||
static struct trace_event enter_syscall_print_##sname = { \
|
||||
.trace = print_syscall_enter, \
|
||||
}; \
|
||||
static struct ftrace_event_call __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("_ftrace_events"))) \
|
||||
event_enter_##sname = { \
|
||||
.name = "sys_enter"#sname, \
|
||||
.system = "syscalls", \
|
||||
.event = &enter_syscall_print_##sname, \
|
||||
.raw_init = init_syscall_trace, \
|
||||
.define_fields = syscall_enter_define_fields, \
|
||||
.regfunc = reg_event_syscall_enter, \
|
||||
.unregfunc = unreg_event_syscall_enter, \
|
||||
.class = &event_class_syscall_enter, \
|
||||
.event.funcs = &enter_syscall_print_funcs, \
|
||||
.data = (void *)&__syscall_meta_##sname,\
|
||||
TRACE_SYS_ENTER_PERF_INIT(sname) \
|
||||
}
|
||||
|
||||
#define SYSCALL_TRACE_EXIT_EVENT(sname) \
|
||||
static const struct syscall_metadata __syscall_meta_##sname; \
|
||||
static struct syscall_metadata __syscall_meta_##sname; \
|
||||
static struct ftrace_event_call \
|
||||
__attribute__((__aligned__(4))) event_exit_##sname; \
|
||||
static struct trace_event exit_syscall_print_##sname = { \
|
||||
.trace = print_syscall_exit, \
|
||||
}; \
|
||||
static struct ftrace_event_call __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("_ftrace_events"))) \
|
||||
event_exit_##sname = { \
|
||||
.name = "sys_exit"#sname, \
|
||||
.system = "syscalls", \
|
||||
.event = &exit_syscall_print_##sname, \
|
||||
.raw_init = init_syscall_trace, \
|
||||
.define_fields = syscall_exit_define_fields, \
|
||||
.regfunc = reg_event_syscall_exit, \
|
||||
.unregfunc = unreg_event_syscall_exit, \
|
||||
.class = &event_class_syscall_exit, \
|
||||
.event.funcs = &exit_syscall_print_funcs, \
|
||||
.data = (void *)&__syscall_meta_##sname,\
|
||||
TRACE_SYS_EXIT_PERF_INIT(sname) \
|
||||
}
|
||||
|
||||
#define SYSCALL_METADATA(sname, nb) \
|
||||
SYSCALL_TRACE_ENTER_EVENT(sname); \
|
||||
SYSCALL_TRACE_EXIT_EVENT(sname); \
|
||||
static const struct syscall_metadata __used \
|
||||
static struct syscall_metadata __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("__syscalls_metadata"))) \
|
||||
__syscall_meta_##sname = { \
|
||||
@@ -191,12 +164,14 @@ struct perf_event_attr;
|
||||
.args = args_##sname, \
|
||||
.enter_event = &event_enter_##sname, \
|
||||
.exit_event = &event_exit_##sname, \
|
||||
.enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
|
||||
.exit_fields = LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \
|
||||
};
|
||||
|
||||
#define SYSCALL_DEFINE0(sname) \
|
||||
SYSCALL_TRACE_ENTER_EVENT(_##sname); \
|
||||
SYSCALL_TRACE_EXIT_EVENT(_##sname); \
|
||||
static const struct syscall_metadata __used \
|
||||
static struct syscall_metadata __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("__syscalls_metadata"))) \
|
||||
__syscall_meta__##sname = { \
|
||||
@@ -204,6 +179,8 @@ struct perf_event_attr;
|
||||
.nb_args = 0, \
|
||||
.enter_event = &event_enter__##sname, \
|
||||
.exit_event = &event_exit__##sname, \
|
||||
.enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
|
||||
.exit_fields = LIST_HEAD_INIT(__syscall_meta__##sname.exit_fields), \
|
||||
}; \
|
||||
asmlinkage long sys_##sname(void)
|
||||
#else
|
||||
|
||||
+76
-22
@@ -20,12 +20,17 @@
|
||||
struct module;
|
||||
struct tracepoint;
|
||||
|
||||
struct tracepoint_func {
|
||||
void *func;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct tracepoint {
|
||||
const char *name; /* Tracepoint name */
|
||||
int state; /* State. */
|
||||
void (*regfunc)(void);
|
||||
void (*unregfunc)(void);
|
||||
void **funcs;
|
||||
struct tracepoint_func *funcs;
|
||||
} __attribute__((aligned(32))); /*
|
||||
* Aligned on 32 bytes because it is
|
||||
* globally visible and gcc happily
|
||||
@@ -37,16 +42,19 @@ struct tracepoint {
|
||||
* Connect a probe to a tracepoint.
|
||||
* Internal API, should not be used directly.
|
||||
*/
|
||||
extern int tracepoint_probe_register(const char *name, void *probe);
|
||||
extern int tracepoint_probe_register(const char *name, void *probe, void *data);
|
||||
|
||||
/*
|
||||
* Disconnect a probe from a tracepoint.
|
||||
* Internal API, should not be used directly.
|
||||
*/
|
||||
extern int tracepoint_probe_unregister(const char *name, void *probe);
|
||||
extern int
|
||||
tracepoint_probe_unregister(const char *name, void *probe, void *data);
|
||||
|
||||
extern int tracepoint_probe_register_noupdate(const char *name, void *probe);
|
||||
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe);
|
||||
extern int tracepoint_probe_register_noupdate(const char *name, void *probe,
|
||||
void *data);
|
||||
extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe,
|
||||
void *data);
|
||||
extern void tracepoint_probe_update_all(void);
|
||||
|
||||
struct tracepoint_iter {
|
||||
@@ -102,17 +110,27 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
|
||||
/*
|
||||
* it_func[0] is never NULL because there is at least one element in the array
|
||||
* when the array itself is non NULL.
|
||||
*
|
||||
* Note, the proto and args passed in includes "__data" as the first parameter.
|
||||
* The reason for this is to handle the "void" prototype. If a tracepoint
|
||||
* has a "void" prototype, then it is invalid to declare a function
|
||||
* as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
|
||||
* "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
|
||||
*/
|
||||
#define __DO_TRACE(tp, proto, args) \
|
||||
do { \
|
||||
void **it_func; \
|
||||
struct tracepoint_func *it_func_ptr; \
|
||||
void *it_func; \
|
||||
void *__data; \
|
||||
\
|
||||
rcu_read_lock_sched_notrace(); \
|
||||
it_func = rcu_dereference_sched((tp)->funcs); \
|
||||
if (it_func) { \
|
||||
it_func_ptr = rcu_dereference_sched((tp)->funcs); \
|
||||
if (it_func_ptr) { \
|
||||
do { \
|
||||
((void(*)(proto))(*it_func))(args); \
|
||||
} while (*(++it_func)); \
|
||||
it_func = (it_func_ptr)->func; \
|
||||
__data = (it_func_ptr)->data; \
|
||||
((void(*)(proto))(it_func))(args); \
|
||||
} while ((++it_func_ptr)->func); \
|
||||
} \
|
||||
rcu_read_unlock_sched_notrace(); \
|
||||
} while (0)
|
||||
@@ -122,24 +140,32 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
|
||||
* not add unwanted padding between the beginning of the section and the
|
||||
* structure. Force alignment to the same alignment as the section start.
|
||||
*/
|
||||
#define DECLARE_TRACE(name, proto, args) \
|
||||
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
|
||||
extern struct tracepoint __tracepoint_##name; \
|
||||
static inline void trace_##name(proto) \
|
||||
{ \
|
||||
if (unlikely(__tracepoint_##name.state)) \
|
||||
__DO_TRACE(&__tracepoint_##name, \
|
||||
TP_PROTO(proto), TP_ARGS(args)); \
|
||||
TP_PROTO(data_proto), \
|
||||
TP_ARGS(data_args)); \
|
||||
} \
|
||||
static inline int register_trace_##name(void (*probe)(proto)) \
|
||||
static inline int \
|
||||
register_trace_##name(void (*probe)(data_proto), void *data) \
|
||||
{ \
|
||||
return tracepoint_probe_register(#name, (void *)probe); \
|
||||
return tracepoint_probe_register(#name, (void *)probe, \
|
||||
data); \
|
||||
} \
|
||||
static inline int unregister_trace_##name(void (*probe)(proto)) \
|
||||
static inline int \
|
||||
unregister_trace_##name(void (*probe)(data_proto), void *data) \
|
||||
{ \
|
||||
return tracepoint_probe_unregister(#name, (void *)probe, \
|
||||
data); \
|
||||
} \
|
||||
static inline void \
|
||||
check_trace_callback_type_##name(void (*cb)(data_proto)) \
|
||||
{ \
|
||||
return tracepoint_probe_unregister(#name, (void *)probe);\
|
||||
}
|
||||
|
||||
|
||||
#define DEFINE_TRACE_FN(name, reg, unreg) \
|
||||
static const char __tpstrtab_##name[] \
|
||||
__attribute__((section("__tracepoints_strings"))) = #name; \
|
||||
@@ -156,18 +182,23 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
|
||||
EXPORT_SYMBOL(__tracepoint_##name)
|
||||
|
||||
#else /* !CONFIG_TRACEPOINTS */
|
||||
#define DECLARE_TRACE(name, proto, args) \
|
||||
static inline void _do_trace_##name(struct tracepoint *tp, proto) \
|
||||
{ } \
|
||||
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
|
||||
static inline void trace_##name(proto) \
|
||||
{ } \
|
||||
static inline int register_trace_##name(void (*probe)(proto)) \
|
||||
static inline int \
|
||||
register_trace_##name(void (*probe)(data_proto), \
|
||||
void *data) \
|
||||
{ \
|
||||
return -ENOSYS; \
|
||||
} \
|
||||
static inline int unregister_trace_##name(void (*probe)(proto)) \
|
||||
static inline int \
|
||||
unregister_trace_##name(void (*probe)(data_proto), \
|
||||
void *data) \
|
||||
{ \
|
||||
return -ENOSYS; \
|
||||
} \
|
||||
static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#define DEFINE_TRACE_FN(name, reg, unreg)
|
||||
@@ -176,6 +207,29 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
|
||||
#define EXPORT_TRACEPOINT_SYMBOL(name)
|
||||
|
||||
#endif /* CONFIG_TRACEPOINTS */
|
||||
|
||||
/*
|
||||
* The need for the DECLARE_TRACE_NOARGS() is to handle the prototype
|
||||
* (void). "void" is a special value in a function prototype and can
|
||||
* not be combined with other arguments. Since the DECLARE_TRACE()
|
||||
* macro adds a data element at the beginning of the prototype,
|
||||
* we need a way to differentiate "(void *data, proto)" from
|
||||
* "(void *data, void)". The second prototype is invalid.
|
||||
*
|
||||
* DECLARE_TRACE_NOARGS() passes "void" as the tracepoint prototype
|
||||
* and "void *__data" as the callback prototype.
|
||||
*
|
||||
* DECLARE_TRACE() passes "proto" as the tracepoint protoype and
|
||||
* "void *__data, proto" as the callback prototype.
|
||||
*/
|
||||
#define DECLARE_TRACE_NOARGS(name) \
|
||||
__DECLARE_TRACE(name, void, , void *__data, __data)
|
||||
|
||||
#define DECLARE_TRACE(name, proto, args) \
|
||||
__DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
|
||||
PARAMS(void *__data, proto), \
|
||||
PARAMS(__data, args))
|
||||
|
||||
#endif /* DECLARE_TRACE */
|
||||
|
||||
#ifndef TRACE_EVENT
|
||||
|
||||
+91
-158
@@ -62,10 +62,13 @@
|
||||
struct trace_entry ent; \
|
||||
tstruct \
|
||||
char __data[0]; \
|
||||
};
|
||||
}; \
|
||||
\
|
||||
static struct ftrace_event_class event_class_##name;
|
||||
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, name, proto, args) \
|
||||
static struct ftrace_event_call \
|
||||
static struct ftrace_event_call __used \
|
||||
__attribute__((__aligned__(4))) event_##name
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
@@ -147,7 +150,7 @@
|
||||
*
|
||||
* entry = iter->ent;
|
||||
*
|
||||
* if (entry->type != event_<call>.id) {
|
||||
* if (entry->type != event_<call>->event.type) {
|
||||
* WARN_ON_ONCE(1);
|
||||
* return TRACE_TYPE_UNHANDLED;
|
||||
* }
|
||||
@@ -206,18 +209,22 @@
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
static notrace enum print_line_t \
|
||||
ftrace_raw_output_id_##call(int event_id, const char *name, \
|
||||
struct trace_iterator *iter, int flags) \
|
||||
ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
|
||||
struct trace_event *trace_event) \
|
||||
{ \
|
||||
struct ftrace_event_call *event; \
|
||||
struct trace_seq *s = &iter->seq; \
|
||||
struct ftrace_raw_##call *field; \
|
||||
struct trace_entry *entry; \
|
||||
struct trace_seq *p; \
|
||||
int ret; \
|
||||
\
|
||||
event = container_of(trace_event, struct ftrace_event_call, \
|
||||
event); \
|
||||
\
|
||||
entry = iter->ent; \
|
||||
\
|
||||
if (entry->type != event_id) { \
|
||||
if (entry->type != event->event.type) { \
|
||||
WARN_ON_ONCE(1); \
|
||||
return TRACE_TYPE_UNHANDLED; \
|
||||
} \
|
||||
@@ -226,7 +233,7 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \
|
||||
\
|
||||
p = &get_cpu_var(ftrace_event_seq); \
|
||||
trace_seq_init(p); \
|
||||
ret = trace_seq_printf(s, "%s: ", name); \
|
||||
ret = trace_seq_printf(s, "%s: ", event->name); \
|
||||
if (ret) \
|
||||
ret = trace_seq_printf(s, print); \
|
||||
put_cpu(); \
|
||||
@@ -234,21 +241,16 @@ ftrace_raw_output_id_##call(int event_id, const char *name, \
|
||||
return TRACE_TYPE_PARTIAL_LINE; \
|
||||
\
|
||||
return TRACE_TYPE_HANDLED; \
|
||||
}
|
||||
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, name, proto, args) \
|
||||
static notrace enum print_line_t \
|
||||
ftrace_raw_output_##name(struct trace_iterator *iter, int flags) \
|
||||
{ \
|
||||
return ftrace_raw_output_id_##template(event_##name.id, \
|
||||
#name, iter, flags); \
|
||||
}
|
||||
} \
|
||||
static struct trace_event_functions ftrace_event_type_funcs_##call = { \
|
||||
.trace = ftrace_raw_output_##call, \
|
||||
};
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
|
||||
static notrace enum print_line_t \
|
||||
ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
|
||||
ftrace_raw_output_##call(struct trace_iterator *iter, int flags, \
|
||||
struct trace_event *event) \
|
||||
{ \
|
||||
struct trace_seq *s = &iter->seq; \
|
||||
struct ftrace_raw_##template *field; \
|
||||
@@ -258,7 +260,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
|
||||
\
|
||||
entry = iter->ent; \
|
||||
\
|
||||
if (entry->type != event_##call.id) { \
|
||||
if (entry->type != event_##call.event.type) { \
|
||||
WARN_ON_ONCE(1); \
|
||||
return TRACE_TYPE_UNHANDLED; \
|
||||
} \
|
||||
@@ -275,7 +277,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
|
||||
return TRACE_TYPE_PARTIAL_LINE; \
|
||||
\
|
||||
return TRACE_TYPE_HANDLED; \
|
||||
}
|
||||
} \
|
||||
static struct trace_event_functions ftrace_event_type_funcs_##call = { \
|
||||
.trace = ftrace_raw_output_##call, \
|
||||
};
|
||||
|
||||
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
||||
|
||||
@@ -381,80 +386,18 @@ static inline notrace int ftrace_get_offsets_##call( \
|
||||
|
||||
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
|
||||
/*
|
||||
* Generate the functions needed for tracepoint perf_event support.
|
||||
*
|
||||
* NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
|
||||
*
|
||||
* static int ftrace_profile_enable_<call>(void)
|
||||
* {
|
||||
* return register_trace_<call>(ftrace_profile_<call>);
|
||||
* }
|
||||
*
|
||||
* static void ftrace_profile_disable_<call>(void)
|
||||
* {
|
||||
* unregister_trace_<call>(ftrace_profile_<call>);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)
|
||||
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, name, proto, args) \
|
||||
\
|
||||
static void perf_trace_##name(proto); \
|
||||
\
|
||||
static notrace int \
|
||||
perf_trace_enable_##name(struct ftrace_event_call *unused) \
|
||||
{ \
|
||||
return register_trace_##name(perf_trace_##name); \
|
||||
} \
|
||||
\
|
||||
static notrace void \
|
||||
perf_trace_disable_##name(struct ftrace_event_call *unused) \
|
||||
{ \
|
||||
unregister_trace_##name(perf_trace_##name); \
|
||||
}
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
||||
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
|
||||
|
||||
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
||||
|
||||
#endif /* CONFIG_PERF_EVENTS */
|
||||
|
||||
/*
|
||||
* Stage 4 of the trace events.
|
||||
*
|
||||
* Override the macros in <trace/trace_events.h> to include the following:
|
||||
*
|
||||
* static void ftrace_event_<call>(proto)
|
||||
* {
|
||||
* event_trace_printk(_RET_IP_, "<call>: " <fmt>);
|
||||
* }
|
||||
*
|
||||
* static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
|
||||
* {
|
||||
* return register_trace_<call>(ftrace_event_<call>);
|
||||
* }
|
||||
*
|
||||
* static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
|
||||
* {
|
||||
* unregister_trace_<call>(ftrace_event_<call>);
|
||||
* }
|
||||
*
|
||||
*
|
||||
* For those macros defined with TRACE_EVENT:
|
||||
*
|
||||
* static struct ftrace_event_call event_<call>;
|
||||
*
|
||||
* static void ftrace_raw_event_<call>(proto)
|
||||
* static void ftrace_raw_event_<call>(void *__data, proto)
|
||||
* {
|
||||
* struct ftrace_event_call *event_call = __data;
|
||||
* struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
|
||||
* struct ring_buffer_event *event;
|
||||
* struct ftrace_raw_<call> *entry; <-- defined in stage 1
|
||||
@@ -469,7 +412,7 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \
|
||||
* __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
|
||||
*
|
||||
* event = trace_current_buffer_lock_reserve(&buffer,
|
||||
* event_<call>.id,
|
||||
* event_<call>->event.type,
|
||||
* sizeof(*entry) + __data_size,
|
||||
* irq_flags, pc);
|
||||
* if (!event)
|
||||
@@ -484,43 +427,42 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \
|
||||
* event, irq_flags, pc);
|
||||
* }
|
||||
*
|
||||
* static int ftrace_raw_reg_event_<call>(struct ftrace_event_call *unused)
|
||||
* {
|
||||
* return register_trace_<call>(ftrace_raw_event_<call>);
|
||||
* }
|
||||
*
|
||||
* static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
|
||||
* {
|
||||
* unregister_trace_<call>(ftrace_raw_event_<call>);
|
||||
* }
|
||||
*
|
||||
* static struct trace_event ftrace_event_type_<call> = {
|
||||
* .trace = ftrace_raw_output_<call>, <-- stage 2
|
||||
* };
|
||||
*
|
||||
* static const char print_fmt_<call>[] = <TP_printk>;
|
||||
*
|
||||
* static struct ftrace_event_class __used event_class_<template> = {
|
||||
* .system = "<system>",
|
||||
* .define_fields = ftrace_define_fields_<call>,
|
||||
* .fields = LIST_HEAD_INIT(event_class_##call.fields),
|
||||
* .raw_init = trace_event_raw_init,
|
||||
* .probe = ftrace_raw_event_##call,
|
||||
* };
|
||||
*
|
||||
* static struct ftrace_event_call __used
|
||||
* __attribute__((__aligned__(4)))
|
||||
* __attribute__((section("_ftrace_events"))) event_<call> = {
|
||||
* .name = "<call>",
|
||||
* .system = "<system>",
|
||||
* .raw_init = trace_event_raw_init,
|
||||
* .regfunc = ftrace_reg_event_<call>,
|
||||
* .unregfunc = ftrace_unreg_event_<call>,
|
||||
* .class = event_class_<template>,
|
||||
* .event = &ftrace_event_type_<call>,
|
||||
* .print_fmt = print_fmt_<call>,
|
||||
* .define_fields = ftrace_define_fields_<call>,
|
||||
* }
|
||||
* };
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
|
||||
#define _TRACE_PERF_PROTO(call, proto) \
|
||||
static notrace void \
|
||||
perf_trace_##call(void *__data, proto);
|
||||
|
||||
#define _TRACE_PERF_INIT(call) \
|
||||
.perf_event_enable = perf_trace_enable_##call, \
|
||||
.perf_event_disable = perf_trace_disable_##call,
|
||||
.perf_probe = perf_trace_##call,
|
||||
|
||||
#else
|
||||
#define _TRACE_PERF_PROTO(call, proto)
|
||||
#define _TRACE_PERF_INIT(call)
|
||||
#endif /* CONFIG_PERF_EVENTS */
|
||||
|
||||
@@ -554,9 +496,9 @@ perf_trace_disable_##name(struct ftrace_event_call *unused) \
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
\
|
||||
static notrace void \
|
||||
ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
|
||||
proto) \
|
||||
ftrace_raw_event_##call(void *__data, proto) \
|
||||
{ \
|
||||
struct ftrace_event_call *event_call = __data; \
|
||||
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
|
||||
struct ring_buffer_event *event; \
|
||||
struct ftrace_raw_##call *entry; \
|
||||
@@ -571,7 +513,7 @@ ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
|
||||
__data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
|
||||
\
|
||||
event = trace_current_buffer_lock_reserve(&buffer, \
|
||||
event_call->id, \
|
||||
event_call->event.type, \
|
||||
sizeof(*entry) + __data_size, \
|
||||
irq_flags, pc); \
|
||||
if (!event) \
|
||||
@@ -586,34 +528,21 @@ ftrace_raw_event_id_##call(struct ftrace_event_call *event_call, \
|
||||
trace_nowake_buffer_unlock_commit(buffer, \
|
||||
event, irq_flags, pc); \
|
||||
}
|
||||
/*
|
||||
* The ftrace_test_probe is compiled out, it is only here as a build time check
|
||||
* to make sure that if the tracepoint handling changes, the ftrace probe will
|
||||
* fail to compile unless it too is updated.
|
||||
*/
|
||||
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, call, proto, args) \
|
||||
\
|
||||
static notrace void ftrace_raw_event_##call(proto) \
|
||||
static inline void ftrace_test_probe_##call(void) \
|
||||
{ \
|
||||
ftrace_raw_event_id_##template(&event_##call, args); \
|
||||
} \
|
||||
\
|
||||
static notrace int \
|
||||
ftrace_raw_reg_event_##call(struct ftrace_event_call *unused) \
|
||||
{ \
|
||||
return register_trace_##call(ftrace_raw_event_##call); \
|
||||
} \
|
||||
\
|
||||
static notrace void \
|
||||
ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused) \
|
||||
{ \
|
||||
unregister_trace_##call(ftrace_raw_event_##call); \
|
||||
} \
|
||||
\
|
||||
static struct trace_event ftrace_event_type_##call = { \
|
||||
.trace = ftrace_raw_output_##call, \
|
||||
};
|
||||
check_trace_callback_type_##call(ftrace_raw_event_##template); \
|
||||
}
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
||||
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
|
||||
#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
|
||||
|
||||
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
||||
|
||||
@@ -630,7 +559,16 @@ static struct trace_event ftrace_event_type_##call = { \
|
||||
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
static const char print_fmt_##call[] = print;
|
||||
_TRACE_PERF_PROTO(call, PARAMS(proto)); \
|
||||
static const char print_fmt_##call[] = print; \
|
||||
static struct ftrace_event_class __used event_class_##call = { \
|
||||
.system = __stringify(TRACE_SYSTEM), \
|
||||
.define_fields = ftrace_define_fields_##call, \
|
||||
.fields = LIST_HEAD_INIT(event_class_##call.fields),\
|
||||
.raw_init = trace_event_raw_init, \
|
||||
.probe = ftrace_raw_event_##call, \
|
||||
_TRACE_PERF_INIT(call) \
|
||||
};
|
||||
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, call, proto, args) \
|
||||
@@ -639,15 +577,10 @@ static struct ftrace_event_call __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("_ftrace_events"))) event_##call = { \
|
||||
.name = #call, \
|
||||
.system = __stringify(TRACE_SYSTEM), \
|
||||
.event = &ftrace_event_type_##call, \
|
||||
.raw_init = trace_event_raw_init, \
|
||||
.regfunc = ftrace_raw_reg_event_##call, \
|
||||
.unregfunc = ftrace_raw_unreg_event_##call, \
|
||||
.class = &event_class_##template, \
|
||||
.event.funcs = &ftrace_event_type_funcs_##template, \
|
||||
.print_fmt = print_fmt_##template, \
|
||||
.define_fields = ftrace_define_fields_##template, \
|
||||
_TRACE_PERF_INIT(call) \
|
||||
}
|
||||
};
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
|
||||
@@ -658,14 +591,9 @@ static struct ftrace_event_call __used \
|
||||
__attribute__((__aligned__(4))) \
|
||||
__attribute__((section("_ftrace_events"))) event_##call = { \
|
||||
.name = #call, \
|
||||
.system = __stringify(TRACE_SYSTEM), \
|
||||
.event = &ftrace_event_type_##call, \
|
||||
.raw_init = trace_event_raw_init, \
|
||||
.regfunc = ftrace_raw_reg_event_##call, \
|
||||
.unregfunc = ftrace_raw_unreg_event_##call, \
|
||||
.class = &event_class_##template, \
|
||||
.event.funcs = &ftrace_event_type_funcs_##call, \
|
||||
.print_fmt = print_fmt_##call, \
|
||||
.define_fields = ftrace_define_fields_##template, \
|
||||
_TRACE_PERF_INIT(call) \
|
||||
}
|
||||
|
||||
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
||||
@@ -765,17 +693,20 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
|
||||
#undef DECLARE_EVENT_CLASS
|
||||
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
|
||||
static notrace void \
|
||||
perf_trace_templ_##call(struct ftrace_event_call *event_call, \
|
||||
struct pt_regs *__regs, proto) \
|
||||
perf_trace_##call(void *__data, proto) \
|
||||
{ \
|
||||
struct ftrace_event_call *event_call = __data; \
|
||||
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
|
||||
struct ftrace_raw_##call *entry; \
|
||||
struct pt_regs __regs; \
|
||||
u64 __addr = 0, __count = 1; \
|
||||
unsigned long irq_flags; \
|
||||
struct hlist_head *head; \
|
||||
int __entry_size; \
|
||||
int __data_size; \
|
||||
int rctx; \
|
||||
\
|
||||
perf_fetch_caller_regs(&__regs, 1); \
|
||||
\
|
||||
__data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
|
||||
__entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
|
||||
sizeof(u64)); \
|
||||
@@ -784,32 +715,34 @@ perf_trace_templ_##call(struct ftrace_event_call *event_call, \
|
||||
if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
|
||||
"profile buffer not large enough")) \
|
||||
return; \
|
||||
\
|
||||
entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
|
||||
__entry_size, event_call->id, &rctx, &irq_flags); \
|
||||
__entry_size, event_call->event.type, &__regs, &rctx); \
|
||||
if (!entry) \
|
||||
return; \
|
||||
\
|
||||
tstruct \
|
||||
\
|
||||
{ assign; } \
|
||||
\
|
||||
head = per_cpu_ptr(event_call->perf_events, smp_processor_id());\
|
||||
perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
|
||||
__count, irq_flags, __regs); \
|
||||
__count, &__regs, head); \
|
||||
}
|
||||
|
||||
/*
|
||||
* This part is compiled out, it is only here as a build time check
|
||||
* to make sure that if the tracepoint handling changes, the
|
||||
* perf probe will fail to compile unless it too is updated.
|
||||
*/
|
||||
#undef DEFINE_EVENT
|
||||
#define DEFINE_EVENT(template, call, proto, args) \
|
||||
static notrace void perf_trace_##call(proto) \
|
||||
static inline void perf_test_probe_##call(void) \
|
||||
{ \
|
||||
struct ftrace_event_call *event_call = &event_##call; \
|
||||
struct pt_regs *__regs = &get_cpu_var(perf_trace_regs); \
|
||||
\
|
||||
perf_fetch_caller_regs(__regs, 1); \
|
||||
\
|
||||
perf_trace_templ_##template(event_call, __regs, args); \
|
||||
\
|
||||
put_cpu_var(perf_trace_regs); \
|
||||
check_trace_callback_type_##call(perf_trace_##template); \
|
||||
}
|
||||
|
||||
|
||||
#undef DEFINE_EVENT_PRINT
|
||||
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
||||
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
|
||||
|
||||
@@ -25,6 +25,8 @@ struct syscall_metadata {
|
||||
int nb_args;
|
||||
const char **types;
|
||||
const char **args;
|
||||
struct list_head enter_fields;
|
||||
struct list_head exit_fields;
|
||||
|
||||
struct ftrace_event_call *enter_event;
|
||||
struct ftrace_event_call *exit_event;
|
||||
@@ -34,16 +36,16 @@ struct syscall_metadata {
|
||||
extern unsigned long arch_syscall_addr(int nr);
|
||||
extern int init_syscall_trace(struct ftrace_event_call *call);
|
||||
|
||||
extern int syscall_enter_define_fields(struct ftrace_event_call *call);
|
||||
extern int syscall_exit_define_fields(struct ftrace_event_call *call);
|
||||
extern int reg_event_syscall_enter(struct ftrace_event_call *call);
|
||||
extern void unreg_event_syscall_enter(struct ftrace_event_call *call);
|
||||
extern int reg_event_syscall_exit(struct ftrace_event_call *call);
|
||||
extern void unreg_event_syscall_exit(struct ftrace_event_call *call);
|
||||
extern int
|
||||
ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s);
|
||||
enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags);
|
||||
enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);
|
||||
enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event);
|
||||
enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
|
||||
+220
-175
File diff suppressed because it is too large
Load Diff
+79
-59
@@ -675,28 +675,33 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
|
||||
}
|
||||
}
|
||||
|
||||
static void blk_add_trace_rq_abort(struct request_queue *q, struct request *rq)
|
||||
static void blk_add_trace_rq_abort(void *ignore,
|
||||
struct request_queue *q, struct request *rq)
|
||||
{
|
||||
blk_add_trace_rq(q, rq, BLK_TA_ABORT);
|
||||
}
|
||||
|
||||
static void blk_add_trace_rq_insert(struct request_queue *q, struct request *rq)
|
||||
static void blk_add_trace_rq_insert(void *ignore,
|
||||
struct request_queue *q, struct request *rq)
|
||||
{
|
||||
blk_add_trace_rq(q, rq, BLK_TA_INSERT);
|
||||
}
|
||||
|
||||
static void blk_add_trace_rq_issue(struct request_queue *q, struct request *rq)
|
||||
static void blk_add_trace_rq_issue(void *ignore,
|
||||
struct request_queue *q, struct request *rq)
|
||||
{
|
||||
blk_add_trace_rq(q, rq, BLK_TA_ISSUE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_rq_requeue(struct request_queue *q,
|
||||
static void blk_add_trace_rq_requeue(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct request *rq)
|
||||
{
|
||||
blk_add_trace_rq(q, rq, BLK_TA_REQUEUE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_rq_complete(struct request_queue *q,
|
||||
static void blk_add_trace_rq_complete(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct request *rq)
|
||||
{
|
||||
blk_add_trace_rq(q, rq, BLK_TA_COMPLETE);
|
||||
@@ -724,34 +729,40 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio,
|
||||
!bio_flagged(bio, BIO_UPTODATE), 0, NULL);
|
||||
}
|
||||
|
||||
static void blk_add_trace_bio_bounce(struct request_queue *q, struct bio *bio)
|
||||
static void blk_add_trace_bio_bounce(void *ignore,
|
||||
struct request_queue *q, struct bio *bio)
|
||||
{
|
||||
blk_add_trace_bio(q, bio, BLK_TA_BOUNCE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_bio_complete(struct request_queue *q, struct bio *bio)
|
||||
static void blk_add_trace_bio_complete(void *ignore,
|
||||
struct request_queue *q, struct bio *bio)
|
||||
{
|
||||
blk_add_trace_bio(q, bio, BLK_TA_COMPLETE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_bio_backmerge(struct request_queue *q,
|
||||
static void blk_add_trace_bio_backmerge(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct bio *bio)
|
||||
{
|
||||
blk_add_trace_bio(q, bio, BLK_TA_BACKMERGE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_bio_frontmerge(struct request_queue *q,
|
||||
static void blk_add_trace_bio_frontmerge(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct bio *bio)
|
||||
{
|
||||
blk_add_trace_bio(q, bio, BLK_TA_FRONTMERGE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_bio_queue(struct request_queue *q, struct bio *bio)
|
||||
static void blk_add_trace_bio_queue(void *ignore,
|
||||
struct request_queue *q, struct bio *bio)
|
||||
{
|
||||
blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
|
||||
}
|
||||
|
||||
static void blk_add_trace_getrq(struct request_queue *q,
|
||||
static void blk_add_trace_getrq(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct bio *bio, int rw)
|
||||
{
|
||||
if (bio)
|
||||
@@ -765,7 +776,8 @@ static void blk_add_trace_getrq(struct request_queue *q,
|
||||
}
|
||||
|
||||
|
||||
static void blk_add_trace_sleeprq(struct request_queue *q,
|
||||
static void blk_add_trace_sleeprq(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct bio *bio, int rw)
|
||||
{
|
||||
if (bio)
|
||||
@@ -779,7 +791,7 @@ static void blk_add_trace_sleeprq(struct request_queue *q,
|
||||
}
|
||||
}
|
||||
|
||||
static void blk_add_trace_plug(struct request_queue *q)
|
||||
static void blk_add_trace_plug(void *ignore, struct request_queue *q)
|
||||
{
|
||||
struct blk_trace *bt = q->blk_trace;
|
||||
|
||||
@@ -787,7 +799,7 @@ static void blk_add_trace_plug(struct request_queue *q)
|
||||
__blk_add_trace(bt, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL);
|
||||
}
|
||||
|
||||
static void blk_add_trace_unplug_io(struct request_queue *q)
|
||||
static void blk_add_trace_unplug_io(void *ignore, struct request_queue *q)
|
||||
{
|
||||
struct blk_trace *bt = q->blk_trace;
|
||||
|
||||
@@ -800,7 +812,7 @@ static void blk_add_trace_unplug_io(struct request_queue *q)
|
||||
}
|
||||
}
|
||||
|
||||
static void blk_add_trace_unplug_timer(struct request_queue *q)
|
||||
static void blk_add_trace_unplug_timer(void *ignore, struct request_queue *q)
|
||||
{
|
||||
struct blk_trace *bt = q->blk_trace;
|
||||
|
||||
@@ -813,7 +825,8 @@ static void blk_add_trace_unplug_timer(struct request_queue *q)
|
||||
}
|
||||
}
|
||||
|
||||
static void blk_add_trace_split(struct request_queue *q, struct bio *bio,
|
||||
static void blk_add_trace_split(void *ignore,
|
||||
struct request_queue *q, struct bio *bio,
|
||||
unsigned int pdu)
|
||||
{
|
||||
struct blk_trace *bt = q->blk_trace;
|
||||
@@ -839,8 +852,9 @@ static void blk_add_trace_split(struct request_queue *q, struct bio *bio,
|
||||
* it spans a stripe (or similar). Add a trace for that action.
|
||||
*
|
||||
**/
|
||||
static void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
|
||||
dev_t dev, sector_t from)
|
||||
static void blk_add_trace_remap(void *ignore,
|
||||
struct request_queue *q, struct bio *bio,
|
||||
dev_t dev, sector_t from)
|
||||
{
|
||||
struct blk_trace *bt = q->blk_trace;
|
||||
struct blk_io_trace_remap r;
|
||||
@@ -869,7 +883,8 @@ static void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
|
||||
* Add a trace for that action.
|
||||
*
|
||||
**/
|
||||
static void blk_add_trace_rq_remap(struct request_queue *q,
|
||||
static void blk_add_trace_rq_remap(void *ignore,
|
||||
struct request_queue *q,
|
||||
struct request *rq, dev_t dev,
|
||||
sector_t from)
|
||||
{
|
||||
@@ -921,64 +936,64 @@ static void blk_register_tracepoints(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = register_trace_block_rq_abort(blk_add_trace_rq_abort);
|
||||
ret = register_trace_block_rq_abort(blk_add_trace_rq_abort, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_rq_insert(blk_add_trace_rq_insert);
|
||||
ret = register_trace_block_rq_insert(blk_add_trace_rq_insert, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_rq_issue(blk_add_trace_rq_issue);
|
||||
ret = register_trace_block_rq_issue(blk_add_trace_rq_issue, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_rq_requeue(blk_add_trace_rq_requeue);
|
||||
ret = register_trace_block_rq_requeue(blk_add_trace_rq_requeue, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_rq_complete(blk_add_trace_rq_complete);
|
||||
ret = register_trace_block_rq_complete(blk_add_trace_rq_complete, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_bio_bounce(blk_add_trace_bio_bounce);
|
||||
ret = register_trace_block_bio_bounce(blk_add_trace_bio_bounce, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_bio_complete(blk_add_trace_bio_complete);
|
||||
ret = register_trace_block_bio_complete(blk_add_trace_bio_complete, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_bio_backmerge(blk_add_trace_bio_backmerge);
|
||||
ret = register_trace_block_bio_backmerge(blk_add_trace_bio_backmerge, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge);
|
||||
ret = register_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_bio_queue(blk_add_trace_bio_queue);
|
||||
ret = register_trace_block_bio_queue(blk_add_trace_bio_queue, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_getrq(blk_add_trace_getrq);
|
||||
ret = register_trace_block_getrq(blk_add_trace_getrq, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_sleeprq(blk_add_trace_sleeprq);
|
||||
ret = register_trace_block_sleeprq(blk_add_trace_sleeprq, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_plug(blk_add_trace_plug);
|
||||
ret = register_trace_block_plug(blk_add_trace_plug, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_unplug_timer(blk_add_trace_unplug_timer);
|
||||
ret = register_trace_block_unplug_timer(blk_add_trace_unplug_timer, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_unplug_io(blk_add_trace_unplug_io);
|
||||
ret = register_trace_block_unplug_io(blk_add_trace_unplug_io, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_split(blk_add_trace_split);
|
||||
ret = register_trace_block_split(blk_add_trace_split, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_remap(blk_add_trace_remap);
|
||||
ret = register_trace_block_remap(blk_add_trace_remap, NULL);
|
||||
WARN_ON(ret);
|
||||
ret = register_trace_block_rq_remap(blk_add_trace_rq_remap);
|
||||
ret = register_trace_block_rq_remap(blk_add_trace_rq_remap, NULL);
|
||||
WARN_ON(ret);
|
||||
}
|
||||
|
||||
static void blk_unregister_tracepoints(void)
|
||||
{
|
||||
unregister_trace_block_rq_remap(blk_add_trace_rq_remap);
|
||||
unregister_trace_block_remap(blk_add_trace_remap);
|
||||
unregister_trace_block_split(blk_add_trace_split);
|
||||
unregister_trace_block_unplug_io(blk_add_trace_unplug_io);
|
||||
unregister_trace_block_unplug_timer(blk_add_trace_unplug_timer);
|
||||
unregister_trace_block_plug(blk_add_trace_plug);
|
||||
unregister_trace_block_sleeprq(blk_add_trace_sleeprq);
|
||||
unregister_trace_block_getrq(blk_add_trace_getrq);
|
||||
unregister_trace_block_bio_queue(blk_add_trace_bio_queue);
|
||||
unregister_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge);
|
||||
unregister_trace_block_bio_backmerge(blk_add_trace_bio_backmerge);
|
||||
unregister_trace_block_bio_complete(blk_add_trace_bio_complete);
|
||||
unregister_trace_block_bio_bounce(blk_add_trace_bio_bounce);
|
||||
unregister_trace_block_rq_complete(blk_add_trace_rq_complete);
|
||||
unregister_trace_block_rq_requeue(blk_add_trace_rq_requeue);
|
||||
unregister_trace_block_rq_issue(blk_add_trace_rq_issue);
|
||||
unregister_trace_block_rq_insert(blk_add_trace_rq_insert);
|
||||
unregister_trace_block_rq_abort(blk_add_trace_rq_abort);
|
||||
unregister_trace_block_rq_remap(blk_add_trace_rq_remap, NULL);
|
||||
unregister_trace_block_remap(blk_add_trace_remap, NULL);
|
||||
unregister_trace_block_split(blk_add_trace_split, NULL);
|
||||
unregister_trace_block_unplug_io(blk_add_trace_unplug_io, NULL);
|
||||
unregister_trace_block_unplug_timer(blk_add_trace_unplug_timer, NULL);
|
||||
unregister_trace_block_plug(blk_add_trace_plug, NULL);
|
||||
unregister_trace_block_sleeprq(blk_add_trace_sleeprq, NULL);
|
||||
unregister_trace_block_getrq(blk_add_trace_getrq, NULL);
|
||||
unregister_trace_block_bio_queue(blk_add_trace_bio_queue, NULL);
|
||||
unregister_trace_block_bio_frontmerge(blk_add_trace_bio_frontmerge, NULL);
|
||||
unregister_trace_block_bio_backmerge(blk_add_trace_bio_backmerge, NULL);
|
||||
unregister_trace_block_bio_complete(blk_add_trace_bio_complete, NULL);
|
||||
unregister_trace_block_bio_bounce(blk_add_trace_bio_bounce, NULL);
|
||||
unregister_trace_block_rq_complete(blk_add_trace_rq_complete, NULL);
|
||||
unregister_trace_block_rq_requeue(blk_add_trace_rq_requeue, NULL);
|
||||
unregister_trace_block_rq_issue(blk_add_trace_rq_issue, NULL);
|
||||
unregister_trace_block_rq_insert(blk_add_trace_rq_insert, NULL);
|
||||
unregister_trace_block_rq_abort(blk_add_trace_rq_abort, NULL);
|
||||
|
||||
tracepoint_synchronize_unregister();
|
||||
}
|
||||
@@ -1321,7 +1336,7 @@ out:
|
||||
}
|
||||
|
||||
static enum print_line_t blk_trace_event_print(struct trace_iterator *iter,
|
||||
int flags)
|
||||
int flags, struct trace_event *event)
|
||||
{
|
||||
return print_one_line(iter, false);
|
||||
}
|
||||
@@ -1343,7 +1358,8 @@ static int blk_trace_synthesize_old_trace(struct trace_iterator *iter)
|
||||
}
|
||||
|
||||
static enum print_line_t
|
||||
blk_trace_event_print_binary(struct trace_iterator *iter, int flags)
|
||||
blk_trace_event_print_binary(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event)
|
||||
{
|
||||
return blk_trace_synthesize_old_trace(iter) ?
|
||||
TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
||||
@@ -1381,12 +1397,16 @@ static struct tracer blk_tracer __read_mostly = {
|
||||
.set_flag = blk_tracer_set_flag,
|
||||
};
|
||||
|
||||
static struct trace_event trace_blk_event = {
|
||||
.type = TRACE_BLK,
|
||||
static struct trace_event_functions trace_blk_event_funcs = {
|
||||
.trace = blk_trace_event_print,
|
||||
.binary = blk_trace_event_print_binary,
|
||||
};
|
||||
|
||||
static struct trace_event trace_blk_event = {
|
||||
.type = TRACE_BLK,
|
||||
.funcs = &trace_blk_event_funcs,
|
||||
};
|
||||
|
||||
static int __init init_blk_tracer(void)
|
||||
{
|
||||
if (!register_ftrace_event(&trace_blk_event)) {
|
||||
|
||||
@@ -3234,7 +3234,8 @@ free:
|
||||
}
|
||||
|
||||
static void
|
||||
ftrace_graph_probe_sched_switch(struct task_struct *prev, struct task_struct *next)
|
||||
ftrace_graph_probe_sched_switch(void *ignore,
|
||||
struct task_struct *prev, struct task_struct *next)
|
||||
{
|
||||
unsigned long long timestamp;
|
||||
int index;
|
||||
@@ -3288,7 +3289,7 @@ static int start_graph_tracing(void)
|
||||
} while (ret == -EAGAIN);
|
||||
|
||||
if (!ret) {
|
||||
ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch);
|
||||
ret = register_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
|
||||
if (ret)
|
||||
pr_info("ftrace_graph: Couldn't activate tracepoint"
|
||||
" probe to kernel_sched_switch\n");
|
||||
@@ -3364,7 +3365,7 @@ void unregister_ftrace_graph(void)
|
||||
ftrace_graph_entry = ftrace_graph_entry_stub;
|
||||
ftrace_shutdown(FTRACE_STOP_FUNC_RET);
|
||||
unregister_pm_notifier(&ftrace_suspend_notifier);
|
||||
unregister_trace_sched_switch(ftrace_graph_probe_sched_switch);
|
||||
unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
|
||||
|
||||
out:
|
||||
mutex_unlock(&ftrace_lock);
|
||||
|
||||
+44
-26
@@ -95,7 +95,8 @@ static inline void kmemtrace_free(enum kmemtrace_type_id type_id,
|
||||
trace_wake_up();
|
||||
}
|
||||
|
||||
static void kmemtrace_kmalloc(unsigned long call_site,
|
||||
static void kmemtrace_kmalloc(void *ignore,
|
||||
unsigned long call_site,
|
||||
const void *ptr,
|
||||
size_t bytes_req,
|
||||
size_t bytes_alloc,
|
||||
@@ -105,7 +106,8 @@ static void kmemtrace_kmalloc(unsigned long call_site,
|
||||
bytes_req, bytes_alloc, gfp_flags, -1);
|
||||
}
|
||||
|
||||
static void kmemtrace_kmem_cache_alloc(unsigned long call_site,
|
||||
static void kmemtrace_kmem_cache_alloc(void *ignore,
|
||||
unsigned long call_site,
|
||||
const void *ptr,
|
||||
size_t bytes_req,
|
||||
size_t bytes_alloc,
|
||||
@@ -115,7 +117,8 @@ static void kmemtrace_kmem_cache_alloc(unsigned long call_site,
|
||||
bytes_req, bytes_alloc, gfp_flags, -1);
|
||||
}
|
||||
|
||||
static void kmemtrace_kmalloc_node(unsigned long call_site,
|
||||
static void kmemtrace_kmalloc_node(void *ignore,
|
||||
unsigned long call_site,
|
||||
const void *ptr,
|
||||
size_t bytes_req,
|
||||
size_t bytes_alloc,
|
||||
@@ -126,7 +129,8 @@ static void kmemtrace_kmalloc_node(unsigned long call_site,
|
||||
bytes_req, bytes_alloc, gfp_flags, node);
|
||||
}
|
||||
|
||||
static void kmemtrace_kmem_cache_alloc_node(unsigned long call_site,
|
||||
static void kmemtrace_kmem_cache_alloc_node(void *ignore,
|
||||
unsigned long call_site,
|
||||
const void *ptr,
|
||||
size_t bytes_req,
|
||||
size_t bytes_alloc,
|
||||
@@ -137,12 +141,14 @@ static void kmemtrace_kmem_cache_alloc_node(unsigned long call_site,
|
||||
bytes_req, bytes_alloc, gfp_flags, node);
|
||||
}
|
||||
|
||||
static void kmemtrace_kfree(unsigned long call_site, const void *ptr)
|
||||
static void
|
||||
kmemtrace_kfree(void *ignore, unsigned long call_site, const void *ptr)
|
||||
{
|
||||
kmemtrace_free(KMEMTRACE_TYPE_KMALLOC, call_site, ptr);
|
||||
}
|
||||
|
||||
static void kmemtrace_kmem_cache_free(unsigned long call_site, const void *ptr)
|
||||
static void kmemtrace_kmem_cache_free(void *ignore,
|
||||
unsigned long call_site, const void *ptr)
|
||||
{
|
||||
kmemtrace_free(KMEMTRACE_TYPE_CACHE, call_site, ptr);
|
||||
}
|
||||
@@ -151,34 +157,34 @@ static int kmemtrace_start_probes(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = register_trace_kmalloc(kmemtrace_kmalloc);
|
||||
err = register_trace_kmalloc(kmemtrace_kmalloc, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = register_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc);
|
||||
err = register_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = register_trace_kmalloc_node(kmemtrace_kmalloc_node);
|
||||
err = register_trace_kmalloc_node(kmemtrace_kmalloc_node, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = register_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node);
|
||||
err = register_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = register_trace_kfree(kmemtrace_kfree);
|
||||
err = register_trace_kfree(kmemtrace_kfree, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = register_trace_kmem_cache_free(kmemtrace_kmem_cache_free);
|
||||
err = register_trace_kmem_cache_free(kmemtrace_kmem_cache_free, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void kmemtrace_stop_probes(void)
|
||||
{
|
||||
unregister_trace_kmalloc(kmemtrace_kmalloc);
|
||||
unregister_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc);
|
||||
unregister_trace_kmalloc_node(kmemtrace_kmalloc_node);
|
||||
unregister_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node);
|
||||
unregister_trace_kfree(kmemtrace_kfree);
|
||||
unregister_trace_kmem_cache_free(kmemtrace_kmem_cache_free);
|
||||
unregister_trace_kmalloc(kmemtrace_kmalloc, NULL);
|
||||
unregister_trace_kmem_cache_alloc(kmemtrace_kmem_cache_alloc, NULL);
|
||||
unregister_trace_kmalloc_node(kmemtrace_kmalloc_node, NULL);
|
||||
unregister_trace_kmem_cache_alloc_node(kmemtrace_kmem_cache_alloc_node, NULL);
|
||||
unregister_trace_kfree(kmemtrace_kfree, NULL);
|
||||
unregister_trace_kmem_cache_free(kmemtrace_kmem_cache_free, NULL);
|
||||
}
|
||||
|
||||
static int kmem_trace_init(struct trace_array *tr)
|
||||
@@ -237,7 +243,8 @@ struct kmemtrace_user_event_alloc {
|
||||
};
|
||||
|
||||
static enum print_line_t
|
||||
kmemtrace_print_alloc(struct trace_iterator *iter, int flags)
|
||||
kmemtrace_print_alloc(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event)
|
||||
{
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct kmemtrace_alloc_entry *entry;
|
||||
@@ -257,7 +264,8 @@ kmemtrace_print_alloc(struct trace_iterator *iter, int flags)
|
||||
}
|
||||
|
||||
static enum print_line_t
|
||||
kmemtrace_print_free(struct trace_iterator *iter, int flags)
|
||||
kmemtrace_print_free(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event)
|
||||
{
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct kmemtrace_free_entry *entry;
|
||||
@@ -275,7 +283,8 @@ kmemtrace_print_free(struct trace_iterator *iter, int flags)
|
||||
}
|
||||
|
||||
static enum print_line_t
|
||||
kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags)
|
||||
kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event)
|
||||
{
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct kmemtrace_alloc_entry *entry;
|
||||
@@ -309,7 +318,8 @@ kmemtrace_print_alloc_user(struct trace_iterator *iter, int flags)
|
||||
}
|
||||
|
||||
static enum print_line_t
|
||||
kmemtrace_print_free_user(struct trace_iterator *iter, int flags)
|
||||
kmemtrace_print_free_user(struct trace_iterator *iter, int flags,
|
||||
struct trace_event *event)
|
||||
{
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct kmemtrace_free_entry *entry;
|
||||
@@ -463,18 +473,26 @@ static enum print_line_t kmemtrace_print_line(struct trace_iterator *iter)
|
||||
}
|
||||
}
|
||||
|
||||
static struct trace_event kmem_trace_alloc = {
|
||||
.type = TRACE_KMEM_ALLOC,
|
||||
static struct trace_event_functions kmem_trace_alloc_funcs = {
|
||||
.trace = kmemtrace_print_alloc,
|
||||
.binary = kmemtrace_print_alloc_user,
|
||||
};
|
||||
|
||||
static struct trace_event kmem_trace_free = {
|
||||
.type = TRACE_KMEM_FREE,
|
||||
static struct trace_event kmem_trace_alloc = {
|
||||
.type = TRACE_KMEM_ALLOC,
|
||||
.funcs = &kmem_trace_alloc_funcs,
|
||||
};
|
||||
|
||||
static struct trace_event_functions kmem_trace_free_funcs = {
|
||||
.trace = kmemtrace_print_free,
|
||||
.binary = kmemtrace_print_free_user,
|
||||
};
|
||||
|
||||
static struct trace_event kmem_trace_free = {
|
||||
.type = TRACE_KMEM_FREE,
|
||||
.funcs = &kmem_trace_free_funcs,
|
||||
};
|
||||
|
||||
static struct tracer kmem_tracer __read_mostly = {
|
||||
.name = "kmemtrace",
|
||||
.init = kmem_trace_init,
|
||||
|
||||
@@ -1936,7 +1936,7 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
|
||||
}
|
||||
|
||||
if (event)
|
||||
return event->trace(iter, sym_flags);
|
||||
return event->funcs->trace(iter, sym_flags, event);
|
||||
|
||||
if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
|
||||
goto partial;
|
||||
@@ -1962,7 +1962,7 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
|
||||
|
||||
event = ftrace_find_event(entry->type);
|
||||
if (event)
|
||||
return event->raw(iter, 0);
|
||||
return event->funcs->raw(iter, 0, event);
|
||||
|
||||
if (!trace_seq_printf(s, "%d ?\n", entry->type))
|
||||
goto partial;
|
||||
@@ -1989,7 +1989,7 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
|
||||
|
||||
event = ftrace_find_event(entry->type);
|
||||
if (event) {
|
||||
enum print_line_t ret = event->hex(iter, 0);
|
||||
enum print_line_t ret = event->funcs->hex(iter, 0, event);
|
||||
if (ret != TRACE_TYPE_HANDLED)
|
||||
return ret;
|
||||
}
|
||||
@@ -2014,7 +2014,8 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
|
||||
}
|
||||
|
||||
event = ftrace_find_event(entry->type);
|
||||
return event ? event->binary(iter, 0) : TRACE_TYPE_HANDLED;
|
||||
return event ? event->funcs->binary(iter, 0, event) :
|
||||
TRACE_TYPE_HANDLED;
|
||||
}
|
||||
|
||||
int trace_empty(struct trace_iterator *iter)
|
||||
|
||||
@@ -405,12 +405,12 @@ void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
|
||||
void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
|
||||
int pc);
|
||||
#else
|
||||
static inline void ftrace_trace_stack(struct trace_array *tr,
|
||||
static inline void ftrace_trace_stack(struct ring_buffer *buffer,
|
||||
unsigned long flags, int skip, int pc)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void ftrace_trace_userstack(struct trace_array *tr,
|
||||
static inline void ftrace_trace_userstack(struct ring_buffer *buffer,
|
||||
unsigned long flags, int pc)
|
||||
{
|
||||
}
|
||||
@@ -778,12 +778,15 @@ extern void print_subsystem_event_filter(struct event_subsystem *system,
|
||||
struct trace_seq *s);
|
||||
extern int filter_assign_type(const char *type);
|
||||
|
||||
struct list_head *
|
||||
trace_get_fields(struct ftrace_event_call *event_call);
|
||||
|
||||
static inline int
|
||||
filter_check_discard(struct ftrace_event_call *call, void *rec,
|
||||
struct ring_buffer *buffer,
|
||||
struct ring_buffer_event *event)
|
||||
{
|
||||
if (unlikely(call->filter_active) &&
|
||||
if (unlikely(call->flags & TRACE_EVENT_FL_FILTERED) &&
|
||||
!filter_match_preds(call->filter, rec)) {
|
||||
ring_buffer_discard_commit(buffer, event);
|
||||
return 1;
|
||||
|
||||
@@ -143,7 +143,7 @@ static void branch_trace_reset(struct trace_array *tr)
|
||||
}
|
||||
|
||||
static enum print_line_t trace_branch_print(struct trace_iterator *iter,
|
||||
int flags)
|
||||
int flags, struct trace_event *event)
|
||||
{
|
||||
struct trace_branch *field;
|
||||
|
||||
@@ -167,9 +167,13 @@ static void branch_print_header(struct seq_file *s)
|
||||
" |\n");
|
||||
}
|
||||
|
||||
static struct trace_event_functions trace_branch_funcs = {
|
||||
.trace = trace_branch_print,
|
||||
};
|
||||
|
||||
static struct trace_event trace_branch_event = {
|
||||
.type = TRACE_BRANCH,
|
||||
.trace = trace_branch_print,
|
||||
.funcs = &trace_branch_funcs,
|
||||
};
|
||||
|
||||
static struct tracer branch_trace __read_mostly =
|
||||
|
||||
@@ -9,13 +9,9 @@
|
||||
#include <linux/kprobes.h>
|
||||
#include "trace.h"
|
||||
|
||||
DEFINE_PER_CPU(struct pt_regs, perf_trace_regs);
|
||||
EXPORT_PER_CPU_SYMBOL_GPL(perf_trace_regs);
|
||||
|
||||
EXPORT_SYMBOL_GPL(perf_arch_fetch_caller_regs);
|
||||
|
||||
static char *perf_trace_buf;
|
||||
static char *perf_trace_buf_nmi;
|
||||
static char *perf_trace_buf[4];
|
||||
|
||||
/*
|
||||
* Force it to be aligned to unsigned long to avoid misaligned accesses
|
||||
@@ -27,57 +23,82 @@ typedef typeof(unsigned long [PERF_MAX_TRACE_SIZE / sizeof(unsigned long)])
|
||||
/* Count the events in use (per event id, not per instance) */
|
||||
static int total_ref_count;
|
||||
|
||||
static int perf_trace_event_enable(struct ftrace_event_call *event)
|
||||
static int perf_trace_event_init(struct ftrace_event_call *tp_event,
|
||||
struct perf_event *p_event)
|
||||
{
|
||||
char *buf;
|
||||
struct hlist_head *list;
|
||||
int ret = -ENOMEM;
|
||||
int cpu;
|
||||
|
||||
if (event->perf_refcount++ > 0)
|
||||
p_event->tp_event = tp_event;
|
||||
if (tp_event->perf_refcount++ > 0)
|
||||
return 0;
|
||||
|
||||
list = alloc_percpu(struct hlist_head);
|
||||
if (!list)
|
||||
goto fail;
|
||||
|
||||
for_each_possible_cpu(cpu)
|
||||
INIT_HLIST_HEAD(per_cpu_ptr(list, cpu));
|
||||
|
||||
tp_event->perf_events = list;
|
||||
|
||||
if (!total_ref_count) {
|
||||
buf = (char *)alloc_percpu(perf_trace_t);
|
||||
if (!buf)
|
||||
goto fail_buf;
|
||||
char *buf;
|
||||
int i;
|
||||
|
||||
rcu_assign_pointer(perf_trace_buf, buf);
|
||||
for (i = 0; i < 4; i++) {
|
||||
buf = (char *)alloc_percpu(perf_trace_t);
|
||||
if (!buf)
|
||||
goto fail;
|
||||
|
||||
buf = (char *)alloc_percpu(perf_trace_t);
|
||||
if (!buf)
|
||||
goto fail_buf_nmi;
|
||||
|
||||
rcu_assign_pointer(perf_trace_buf_nmi, buf);
|
||||
perf_trace_buf[i] = buf;
|
||||
}
|
||||
}
|
||||
|
||||
ret = event->perf_event_enable(event);
|
||||
if (!ret) {
|
||||
total_ref_count++;
|
||||
return 0;
|
||||
}
|
||||
if (tp_event->class->reg)
|
||||
ret = tp_event->class->reg(tp_event, TRACE_REG_PERF_REGISTER);
|
||||
else
|
||||
ret = tracepoint_probe_register(tp_event->name,
|
||||
tp_event->class->perf_probe,
|
||||
tp_event);
|
||||
|
||||
fail_buf_nmi:
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
total_ref_count++;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (!total_ref_count) {
|
||||
free_percpu(perf_trace_buf_nmi);
|
||||
free_percpu(perf_trace_buf);
|
||||
perf_trace_buf_nmi = NULL;
|
||||
perf_trace_buf = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
free_percpu(perf_trace_buf[i]);
|
||||
perf_trace_buf[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!--tp_event->perf_refcount) {
|
||||
free_percpu(tp_event->perf_events);
|
||||
tp_event->perf_events = NULL;
|
||||
}
|
||||
fail_buf:
|
||||
event->perf_refcount--;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int perf_trace_enable(int event_id)
|
||||
int perf_trace_init(struct perf_event *p_event)
|
||||
{
|
||||
struct ftrace_event_call *event;
|
||||
struct ftrace_event_call *tp_event;
|
||||
int event_id = p_event->attr.config;
|
||||
int ret = -EINVAL;
|
||||
|
||||
mutex_lock(&event_mutex);
|
||||
list_for_each_entry(event, &ftrace_events, list) {
|
||||
if (event->id == event_id && event->perf_event_enable &&
|
||||
try_module_get(event->mod)) {
|
||||
ret = perf_trace_event_enable(event);
|
||||
list_for_each_entry(tp_event, &ftrace_events, list) {
|
||||
if (tp_event->event.type == event_id &&
|
||||
tp_event->class && tp_event->class->perf_probe &&
|
||||
try_module_get(tp_event->mod)) {
|
||||
ret = perf_trace_event_init(tp_event, p_event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -86,90 +107,78 @@ int perf_trace_enable(int event_id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void perf_trace_event_disable(struct ftrace_event_call *event)
|
||||
int perf_trace_enable(struct perf_event *p_event)
|
||||
{
|
||||
char *buf, *nmi_buf;
|
||||
struct ftrace_event_call *tp_event = p_event->tp_event;
|
||||
struct hlist_head *list;
|
||||
|
||||
if (--event->perf_refcount > 0)
|
||||
return;
|
||||
list = tp_event->perf_events;
|
||||
if (WARN_ON_ONCE(!list))
|
||||
return -EINVAL;
|
||||
|
||||
event->perf_event_disable(event);
|
||||
list = per_cpu_ptr(list, smp_processor_id());
|
||||
hlist_add_head_rcu(&p_event->hlist_entry, list);
|
||||
|
||||
if (!--total_ref_count) {
|
||||
buf = perf_trace_buf;
|
||||
rcu_assign_pointer(perf_trace_buf, NULL);
|
||||
|
||||
nmi_buf = perf_trace_buf_nmi;
|
||||
rcu_assign_pointer(perf_trace_buf_nmi, NULL);
|
||||
|
||||
/*
|
||||
* Ensure every events in profiling have finished before
|
||||
* releasing the buffers
|
||||
*/
|
||||
synchronize_sched();
|
||||
|
||||
free_percpu(buf);
|
||||
free_percpu(nmi_buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void perf_trace_disable(int event_id)
|
||||
void perf_trace_disable(struct perf_event *p_event)
|
||||
{
|
||||
struct ftrace_event_call *event;
|
||||
hlist_del_rcu(&p_event->hlist_entry);
|
||||
}
|
||||
|
||||
mutex_lock(&event_mutex);
|
||||
list_for_each_entry(event, &ftrace_events, list) {
|
||||
if (event->id == event_id) {
|
||||
perf_trace_event_disable(event);
|
||||
module_put(event->mod);
|
||||
break;
|
||||
void perf_trace_destroy(struct perf_event *p_event)
|
||||
{
|
||||
struct ftrace_event_call *tp_event = p_event->tp_event;
|
||||
int i;
|
||||
|
||||
if (--tp_event->perf_refcount > 0)
|
||||
return;
|
||||
|
||||
if (tp_event->class->reg)
|
||||
tp_event->class->reg(tp_event, TRACE_REG_PERF_UNREGISTER);
|
||||
else
|
||||
tracepoint_probe_unregister(tp_event->name,
|
||||
tp_event->class->perf_probe,
|
||||
tp_event);
|
||||
|
||||
free_percpu(tp_event->perf_events);
|
||||
tp_event->perf_events = NULL;
|
||||
|
||||
if (!--total_ref_count) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
free_percpu(perf_trace_buf[i]);
|
||||
perf_trace_buf[i] = NULL;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&event_mutex);
|
||||
}
|
||||
|
||||
__kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
|
||||
int *rctxp, unsigned long *irq_flags)
|
||||
struct pt_regs *regs, int *rctxp)
|
||||
{
|
||||
struct trace_entry *entry;
|
||||
char *trace_buf, *raw_data;
|
||||
int pc, cpu;
|
||||
unsigned long flags;
|
||||
char *raw_data;
|
||||
int pc;
|
||||
|
||||
BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
|
||||
|
||||
pc = preempt_count();
|
||||
|
||||
/* Protect the per cpu buffer, begin the rcu read side */
|
||||
local_irq_save(*irq_flags);
|
||||
|
||||
*rctxp = perf_swevent_get_recursion_context();
|
||||
if (*rctxp < 0)
|
||||
goto err_recursion;
|
||||
return NULL;
|
||||
|
||||
cpu = smp_processor_id();
|
||||
|
||||
if (in_nmi())
|
||||
trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
|
||||
else
|
||||
trace_buf = rcu_dereference_sched(perf_trace_buf);
|
||||
|
||||
if (!trace_buf)
|
||||
goto err;
|
||||
|
||||
raw_data = per_cpu_ptr(trace_buf, cpu);
|
||||
raw_data = per_cpu_ptr(perf_trace_buf[*rctxp], smp_processor_id());
|
||||
|
||||
/* zero the dead bytes from align to not leak stack to user */
|
||||
memset(&raw_data[size - sizeof(u64)], 0, sizeof(u64));
|
||||
|
||||
entry = (struct trace_entry *)raw_data;
|
||||
tracing_generic_entry_update(entry, *irq_flags, pc);
|
||||
local_save_flags(flags);
|
||||
tracing_generic_entry_update(entry, flags, pc);
|
||||
entry->type = type;
|
||||
|
||||
return raw_data;
|
||||
err:
|
||||
perf_swevent_put_recursion_context(*rctxp);
|
||||
err_recursion:
|
||||
local_irq_restore(*irq_flags);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(perf_trace_buf_prepare);
|
||||
|
||||
+88
-51
@@ -29,11 +29,23 @@ DEFINE_MUTEX(event_mutex);
|
||||
|
||||
LIST_HEAD(ftrace_events);
|
||||
|
||||
struct list_head *
|
||||
trace_get_fields(struct ftrace_event_call *event_call)
|
||||
{
|
||||
if (!event_call->class->get_fields)
|
||||
return &event_call->class->fields;
|
||||
return event_call->class->get_fields(event_call);
|
||||
}
|
||||
|
||||
int trace_define_field(struct ftrace_event_call *call, const char *type,
|
||||
const char *name, int offset, int size, int is_signed,
|
||||
int filter_type)
|
||||
{
|
||||
struct ftrace_event_field *field;
|
||||
struct list_head *head;
|
||||
|
||||
if (WARN_ON(!call->class))
|
||||
return 0;
|
||||
|
||||
field = kzalloc(sizeof(*field), GFP_KERNEL);
|
||||
if (!field)
|
||||
@@ -56,7 +68,8 @@ int trace_define_field(struct ftrace_event_call *call, const char *type,
|
||||
field->size = size;
|
||||
field->is_signed = is_signed;
|
||||
|
||||
list_add(&field->link, &call->fields);
|
||||
head = trace_get_fields(call);
|
||||
list_add(&field->link, head);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -94,8 +107,10 @@ static int trace_define_common_fields(struct ftrace_event_call *call)
|
||||
void trace_destroy_fields(struct ftrace_event_call *call)
|
||||
{
|
||||
struct ftrace_event_field *field, *next;
|
||||
struct list_head *head;
|
||||
|
||||
list_for_each_entry_safe(field, next, &call->fields, link) {
|
||||
head = trace_get_fields(call);
|
||||
list_for_each_entry_safe(field, next, head, link) {
|
||||
list_del(&field->link);
|
||||
kfree(field->type);
|
||||
kfree(field->name);
|
||||
@@ -107,11 +122,9 @@ int trace_event_raw_init(struct ftrace_event_call *call)
|
||||
{
|
||||
int id;
|
||||
|
||||
id = register_ftrace_event(call->event);
|
||||
id = register_ftrace_event(&call->event);
|
||||
if (!id)
|
||||
return -ENODEV;
|
||||
call->id = id;
|
||||
INIT_LIST_HEAD(&call->fields);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -124,23 +137,33 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call,
|
||||
|
||||
switch (enable) {
|
||||
case 0:
|
||||
if (call->enabled) {
|
||||
call->enabled = 0;
|
||||
if (call->flags & TRACE_EVENT_FL_ENABLED) {
|
||||
call->flags &= ~TRACE_EVENT_FL_ENABLED;
|
||||
tracing_stop_cmdline_record();
|
||||
call->unregfunc(call);
|
||||
if (call->class->reg)
|
||||
call->class->reg(call, TRACE_REG_UNREGISTER);
|
||||
else
|
||||
tracepoint_probe_unregister(call->name,
|
||||
call->class->probe,
|
||||
call);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!call->enabled) {
|
||||
if (!(call->flags & TRACE_EVENT_FL_ENABLED)) {
|
||||
tracing_start_cmdline_record();
|
||||
ret = call->regfunc(call);
|
||||
if (call->class->reg)
|
||||
ret = call->class->reg(call, TRACE_REG_REGISTER);
|
||||
else
|
||||
ret = tracepoint_probe_register(call->name,
|
||||
call->class->probe,
|
||||
call);
|
||||
if (ret) {
|
||||
tracing_stop_cmdline_record();
|
||||
pr_info("event trace: Could not enable event "
|
||||
"%s\n", call->name);
|
||||
break;
|
||||
}
|
||||
call->enabled = 1;
|
||||
call->flags |= TRACE_EVENT_FL_ENABLED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -171,15 +194,16 @@ static int __ftrace_set_clr_event(const char *match, const char *sub,
|
||||
mutex_lock(&event_mutex);
|
||||
list_for_each_entry(call, &ftrace_events, list) {
|
||||
|
||||
if (!call->name || !call->regfunc)
|
||||
if (!call->name || !call->class ||
|
||||
(!call->class->probe && !call->class->reg))
|
||||
continue;
|
||||
|
||||
if (match &&
|
||||
strcmp(match, call->name) != 0 &&
|
||||
strcmp(match, call->system) != 0)
|
||||
strcmp(match, call->class->system) != 0)
|
||||
continue;
|
||||
|
||||
if (sub && strcmp(sub, call->system) != 0)
|
||||
if (sub && strcmp(sub, call->class->system) != 0)
|
||||
continue;
|
||||
|
||||
if (event && strcmp(event, call->name) != 0)
|
||||
@@ -297,7 +321,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
|
||||
* The ftrace subsystem is for showing formats only.
|
||||
* They can not be enabled or disabled via the event files.
|
||||
*/
|
||||
if (call->regfunc)
|
||||
if (call->class && (call->class->probe || call->class->reg))
|
||||
return call;
|
||||
}
|
||||
|
||||
@@ -328,7 +352,7 @@ s_next(struct seq_file *m, void *v, loff_t *pos)
|
||||
(*pos)++;
|
||||
|
||||
list_for_each_entry_continue(call, &ftrace_events, list) {
|
||||
if (call->enabled)
|
||||
if (call->flags & TRACE_EVENT_FL_ENABLED)
|
||||
return call;
|
||||
}
|
||||
|
||||
@@ -355,8 +379,8 @@ static int t_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct ftrace_event_call *call = v;
|
||||
|
||||
if (strcmp(call->system, TRACE_SYSTEM) != 0)
|
||||
seq_printf(m, "%s:", call->system);
|
||||
if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
|
||||
seq_printf(m, "%s:", call->class->system);
|
||||
seq_printf(m, "%s\n", call->name);
|
||||
|
||||
return 0;
|
||||
@@ -387,7 +411,7 @@ event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
|
||||
struct ftrace_event_call *call = filp->private_data;
|
||||
char *buf;
|
||||
|
||||
if (call->enabled)
|
||||
if (call->flags & TRACE_EVENT_FL_ENABLED)
|
||||
buf = "1\n";
|
||||
else
|
||||
buf = "0\n";
|
||||
@@ -450,10 +474,11 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
|
||||
|
||||
mutex_lock(&event_mutex);
|
||||
list_for_each_entry(call, &ftrace_events, list) {
|
||||
if (!call->name || !call->regfunc)
|
||||
if (!call->name || !call->class ||
|
||||
(!call->class->probe && !call->class->reg))
|
||||
continue;
|
||||
|
||||
if (system && strcmp(call->system, system) != 0)
|
||||
if (system && strcmp(call->class->system, system) != 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -461,7 +486,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
|
||||
* or if all events or cleared, or if we have
|
||||
* a mixture.
|
||||
*/
|
||||
set |= (1 << !!call->enabled);
|
||||
set |= (1 << !!(call->flags & TRACE_EVENT_FL_ENABLED));
|
||||
|
||||
/*
|
||||
* If we have a mixture, no need to look further.
|
||||
@@ -525,6 +550,7 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
|
||||
{
|
||||
struct ftrace_event_call *call = filp->private_data;
|
||||
struct ftrace_event_field *field;
|
||||
struct list_head *head;
|
||||
struct trace_seq *s;
|
||||
int common_field_count = 5;
|
||||
char *buf;
|
||||
@@ -540,10 +566,11 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
|
||||
trace_seq_init(s);
|
||||
|
||||
trace_seq_printf(s, "name: %s\n", call->name);
|
||||
trace_seq_printf(s, "ID: %d\n", call->id);
|
||||
trace_seq_printf(s, "ID: %d\n", call->event.type);
|
||||
trace_seq_printf(s, "format:\n");
|
||||
|
||||
list_for_each_entry_reverse(field, &call->fields, link) {
|
||||
head = trace_get_fields(call);
|
||||
list_for_each_entry_reverse(field, head, link) {
|
||||
/*
|
||||
* Smartly shows the array type(except dynamic array).
|
||||
* Normal:
|
||||
@@ -613,7 +640,7 @@ event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||
return -ENOMEM;
|
||||
|
||||
trace_seq_init(s);
|
||||
trace_seq_printf(s, "%d\n", call->id);
|
||||
trace_seq_printf(s, "%d\n", call->event.type);
|
||||
|
||||
r = simple_read_from_buffer(ubuf, cnt, ppos,
|
||||
s->buffer, s->len);
|
||||
@@ -919,14 +946,15 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
|
||||
const struct file_operations *filter,
|
||||
const struct file_operations *format)
|
||||
{
|
||||
struct list_head *head;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* If the trace point header did not define TRACE_SYSTEM
|
||||
* then the system would be called "TRACE_SYSTEM".
|
||||
*/
|
||||
if (strcmp(call->system, TRACE_SYSTEM) != 0)
|
||||
d_events = event_subsystem_dir(call->system, d_events);
|
||||
if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
|
||||
d_events = event_subsystem_dir(call->class->system, d_events);
|
||||
|
||||
call->dir = debugfs_create_dir(call->name, d_events);
|
||||
if (!call->dir) {
|
||||
@@ -935,22 +963,31 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (call->regfunc)
|
||||
if (call->class->probe || call->class->reg)
|
||||
trace_create_file("enable", 0644, call->dir, call,
|
||||
enable);
|
||||
|
||||
if (call->id && call->perf_event_enable)
|
||||
#ifdef CONFIG_PERF_EVENTS
|
||||
if (call->event.type && (call->class->perf_probe || call->class->reg))
|
||||
trace_create_file("id", 0444, call->dir, call,
|
||||
id);
|
||||
#endif
|
||||
|
||||
if (call->define_fields) {
|
||||
ret = trace_define_common_fields(call);
|
||||
if (!ret)
|
||||
ret = call->define_fields(call);
|
||||
if (ret < 0) {
|
||||
pr_warning("Could not initialize trace point"
|
||||
" events/%s\n", call->name);
|
||||
return ret;
|
||||
if (call->class->define_fields) {
|
||||
/*
|
||||
* Other events may have the same class. Only update
|
||||
* the fields if they are not already defined.
|
||||
*/
|
||||
head = trace_get_fields(call);
|
||||
if (list_empty(head)) {
|
||||
ret = trace_define_common_fields(call);
|
||||
if (!ret)
|
||||
ret = call->class->define_fields(call);
|
||||
if (ret < 0) {
|
||||
pr_warning("Could not initialize trace point"
|
||||
" events/%s\n", call->name);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
trace_create_file("filter", 0644, call->dir, call,
|
||||
filter);
|
||||
@@ -970,8 +1007,8 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
|
||||
if (!call->name)
|
||||
return -EINVAL;
|
||||
|
||||
if (call->raw_init) {
|
||||
ret = call->raw_init(call);
|
||||
if (call->class->raw_init) {
|
||||
ret = call->class->raw_init(call);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOSYS)
|
||||
pr_warning("Could not initialize trace "
|
||||
@@ -1035,13 +1072,13 @@ static void remove_subsystem_dir(const char *name)
|
||||
static void __trace_remove_event_call(struct ftrace_event_call *call)
|
||||
{
|
||||
ftrace_event_enable_disable(call, 0);
|
||||
if (call->event)
|
||||
__unregister_ftrace_event(call->event);
|
||||
if (call->event.funcs)
|
||||
__unregister_ftrace_event(&call->event);
|
||||
debugfs_remove_recursive(call->dir);
|
||||
list_del(&call->list);
|
||||
trace_destroy_fields(call);
|
||||
destroy_preds(call);
|
||||
remove_subsystem_dir(call->system);
|
||||
remove_subsystem_dir(call->class->system);
|
||||
}
|
||||
|
||||
/* Remove an event_call */
|
||||
@@ -1132,8 +1169,8 @@ static void trace_module_add_events(struct module *mod)
|
||||
/* The linker may leave blanks */
|
||||
if (!call->name)
|
||||
continue;
|
||||
if (call->raw_init) {
|
||||
ret = call->raw_init(call);
|
||||
if (call->class->raw_init) {
|
||||
ret = call->class->raw_init(call);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOSYS)
|
||||
pr_warning("Could not initialize trace "
|
||||
@@ -1286,8 +1323,8 @@ static __init int event_trace_init(void)
|
||||
/* The linker may leave blanks */
|
||||
if (!call->name)
|
||||
continue;
|
||||
if (call->raw_init) {
|
||||
ret = call->raw_init(call);
|
||||
if (call->class->raw_init) {
|
||||
ret = call->class->raw_init(call);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOSYS)
|
||||
pr_warning("Could not initialize trace "
|
||||
@@ -1388,8 +1425,8 @@ static __init void event_trace_self_tests(void)
|
||||
|
||||
list_for_each_entry(call, &ftrace_events, list) {
|
||||
|
||||
/* Only test those that have a regfunc */
|
||||
if (!call->regfunc)
|
||||
/* Only test those that have a probe */
|
||||
if (!call->class || !call->class->probe)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -1399,8 +1436,8 @@ static __init void event_trace_self_tests(void)
|
||||
* syscalls as we test.
|
||||
*/
|
||||
#ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS
|
||||
if (call->system &&
|
||||
strcmp(call->system, "syscalls") == 0)
|
||||
if (call->class->system &&
|
||||
strcmp(call->class->system, "syscalls") == 0)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
@@ -1410,7 +1447,7 @@ static __init void event_trace_self_tests(void)
|
||||
* If an event is already enabled, someone is using
|
||||
* it and the self test should not be on.
|
||||
*/
|
||||
if (call->enabled) {
|
||||
if (call->flags & TRACE_EVENT_FL_ENABLED) {
|
||||
pr_warning("Enabled event during self test!\n");
|
||||
WARN_ON_ONCE(1);
|
||||
continue;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user