Skip to content

Commit

Permalink
perf: Drop the obsolete profile naming for trace events
Browse files Browse the repository at this point in the history
Drop the obsolete "profile" naming used by perf for trace events.
Perf can now do more than simple events counting, so generalize
the API naming.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
  • Loading branch information
Frederic Weisbecker committed Mar 10, 2010
1 parent c530665 commit 97d5a22
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 119 deletions.
16 changes: 8 additions & 8 deletions include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ struct ftrace_event_call {
void *mod;
void *data;

int profile_count;
int (*profile_enable)(struct ftrace_event_call *);
void (*profile_disable)(struct ftrace_event_call *);
int perf_refcount;
int (*perf_event_enable)(struct ftrace_event_call *);
void (*perf_event_disable)(struct ftrace_event_call *);
};

#define FTRACE_MAX_PROFILE_SIZE 2048
#define PERF_MAX_TRACE_SIZE 2048

#define MAX_FILTER_PRED 32
#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
Expand Down Expand Up @@ -190,17 +190,17 @@ struct perf_event;

DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);

extern int ftrace_profile_enable(int event_id);
extern void ftrace_profile_disable(int event_id);
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,
char *filter_str);
extern void ftrace_profile_free_filter(struct perf_event *event);
extern void *
ftrace_perf_buf_prepare(int size, unsigned short type, int *rctxp,
perf_trace_buf_prepare(int size, unsigned short type, int *rctxp,
unsigned long *irq_flags);

static inline void
ftrace_perf_buf_submit(void *raw_data, int size, int rctx, u64 addr,
perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
u64 count, unsigned long irq_flags, struct pt_regs *regs)
{
struct trace_entry *entry = raw_data;
Expand Down
24 changes: 12 additions & 12 deletions include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ struct perf_event_attr;

#ifdef CONFIG_PERF_EVENTS

#define TRACE_SYS_ENTER_PROFILE_INIT(sname) \
.profile_enable = prof_sysenter_enable, \
.profile_disable = prof_sysenter_disable,
#define TRACE_SYS_ENTER_PERF_INIT(sname) \
.perf_event_enable = perf_sysenter_enable, \
.perf_event_disable = perf_sysenter_disable,

#define TRACE_SYS_EXIT_PROFILE_INIT(sname) \
.profile_enable = prof_sysexit_enable, \
.profile_disable = prof_sysexit_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_PROFILE(sname)
#define TRACE_SYS_ENTER_PROFILE_INIT(sname)
#define TRACE_SYS_EXIT_PROFILE(sname)
#define TRACE_SYS_EXIT_PROFILE_INIT(sname)
#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
Expand Down Expand Up @@ -149,7 +149,7 @@ struct perf_event_attr;
.regfunc = reg_event_syscall_enter, \
.unregfunc = unreg_event_syscall_enter, \
.data = (void *)&__syscall_meta_##sname,\
TRACE_SYS_ENTER_PROFILE_INIT(sname) \
TRACE_SYS_ENTER_PERF_INIT(sname) \
}

#define SYSCALL_TRACE_EXIT_EVENT(sname) \
Expand All @@ -171,7 +171,7 @@ struct perf_event_attr;
.regfunc = reg_event_syscall_exit, \
.unregfunc = unreg_event_syscall_exit, \
.data = (void *)&__syscall_meta_##sname,\
TRACE_SYS_EXIT_PROFILE_INIT(sname) \
TRACE_SYS_EXIT_PERF_INIT(sname) \
}

#define SYSCALL_METADATA(sname, nb) \
Expand Down
38 changes: 19 additions & 19 deletions include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,18 +401,18 @@ static inline notrace int ftrace_get_offsets_##call( \
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
\
static void ftrace_profile_##name(proto); \
static void perf_trace_##name(proto); \
\
static notrace int \
ftrace_profile_enable_##name(struct ftrace_event_call *unused) \
perf_trace_enable_##name(struct ftrace_event_call *unused) \
{ \
return register_trace_##name(ftrace_profile_##name); \
return register_trace_##name(perf_trace_##name); \
} \
\
static notrace void \
ftrace_profile_disable_##name(struct ftrace_event_call *unused) \
perf_trace_disable_##name(struct ftrace_event_call *unused) \
{ \
unregister_trace_##name(ftrace_profile_##name); \
unregister_trace_##name(perf_trace_##name); \
}

#undef DEFINE_EVENT_PRINT
Expand Down Expand Up @@ -507,12 +507,12 @@ ftrace_profile_disable_##name(struct ftrace_event_call *unused) \

#ifdef CONFIG_PERF_EVENTS

#define _TRACE_PROFILE_INIT(call) \
.profile_enable = ftrace_profile_enable_##call, \
.profile_disable = ftrace_profile_disable_##call,
#define _TRACE_PERF_INIT(call) \
.perf_event_enable = perf_trace_enable_##call, \
.perf_event_disable = perf_trace_disable_##call,

#else
#define _TRACE_PROFILE_INIT(call)
#define _TRACE_PERF_INIT(call)
#endif /* CONFIG_PERF_EVENTS */

#undef __entry
Expand Down Expand Up @@ -638,7 +638,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.unregfunc = ftrace_raw_unreg_event_##call, \
.print_fmt = print_fmt_##template, \
.define_fields = ftrace_define_fields_##template, \
_TRACE_PROFILE_INIT(call) \
_TRACE_PERF_INIT(call) \
}

#undef DEFINE_EVENT_PRINT
Expand All @@ -657,18 +657,18 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.unregfunc = ftrace_raw_unreg_event_##call, \
.print_fmt = print_fmt_##call, \
.define_fields = ftrace_define_fields_##template, \
_TRACE_PROFILE_INIT(call) \
_TRACE_PERF_INIT(call) \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

/*
* Define the insertion callback to profile events
* Define the insertion callback to perf events
*
* The job is very similar to ftrace_raw_event_<call> except that we don't
* insert in the ring buffer but in a perf counter.
*
* static void ftrace_profile_<call>(proto)
* static void ftrace_perf_<call>(proto)
* {
* struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
* struct ftrace_event_call *event_call = &event_<call>;
Expand Down Expand Up @@ -757,7 +757,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
static notrace void \
ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \
perf_trace_templ_##call(struct ftrace_event_call *event_call, \
proto) \
{ \
struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
Expand All @@ -774,10 +774,10 @@ ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \
sizeof(u64)); \
__entry_size -= sizeof(u32); \
\
if (WARN_ONCE(__entry_size > FTRACE_MAX_PROFILE_SIZE, \
if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
"profile buffer not large enough")) \
return; \
entry = (struct ftrace_raw_##call *)ftrace_perf_buf_prepare( \
entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
__entry_size, event_call->id, &rctx, &irq_flags); \
if (!entry) \
return; \
Expand All @@ -788,17 +788,17 @@ ftrace_profile_templ_##call(struct ftrace_event_call *event_call, \
__regs = &__get_cpu_var(perf_trace_regs); \
perf_fetch_caller_regs(__regs, 2); \
\
ftrace_perf_buf_submit(entry, __entry_size, rctx, __addr, \
perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
__count, irq_flags, __regs); \
}

#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
static notrace void ftrace_profile_##call(proto) \
static notrace void perf_trace_##call(proto) \
{ \
struct ftrace_event_call *event_call = &event_##call; \
\
ftrace_profile_templ_##template(event_call, args); \
perf_trace_templ_##template(event_call, args); \
}

#undef DEFINE_EVENT_PRINT
Expand Down
8 changes: 4 additions & 4 deletions include/trace/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags);
#endif

#ifdef CONFIG_PERF_EVENTS
int prof_sysenter_enable(struct ftrace_event_call *call);
void prof_sysenter_disable(struct ftrace_event_call *call);
int prof_sysexit_enable(struct ftrace_event_call *call);
void prof_sysexit_disable(struct ftrace_event_call *call);
int perf_sysenter_enable(struct ftrace_event_call *call);
void perf_sysenter_disable(struct ftrace_event_call *call);
int perf_sysexit_enable(struct ftrace_event_call *call);
void perf_sysexit_disable(struct ftrace_event_call *call);
#endif

#endif /* _TRACE_SYSCALL_H */
4 changes: 2 additions & 2 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -4347,7 +4347,7 @@ static int perf_tp_event_match(struct perf_event *event,

static void tp_perf_event_destroy(struct perf_event *event)
{
ftrace_profile_disable(event->attr.config);
perf_trace_disable(event->attr.config);
}

static const struct pmu *tp_perf_event_init(struct perf_event *event)
Expand All @@ -4361,7 +4361,7 @@ static const struct pmu *tp_perf_event_init(struct perf_event *event)
!capable(CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);

if (ftrace_profile_enable(event->attr.config))
if (perf_trace_enable(event->attr.config))
return NULL;

event->destroy = tp_perf_event_destroy;
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ obj-$(CONFIG_EVENT_TRACING) += trace_events.o
obj-$(CONFIG_EVENT_TRACING) += trace_export.o
obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
ifeq ($(CONFIG_PERF_EVENTS),y)
obj-$(CONFIG_EVENT_TRACING) += trace_event_profile.o
obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o
endif
obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* trace event based perf counter profiling
* trace event based perf event profiling/tracing
*
* Copyright (C) 2009 Red Hat Inc, Peter Zijlstra <pzijlstr@redhat.com>
* Copyright (C) 2009-2010 Frederic Weisbecker <fweisbec@gmail.com>
Expand All @@ -14,20 +14,20 @@ DEFINE_PER_CPU(struct pt_regs, perf_trace_regs);
static char *perf_trace_buf;
static char *perf_trace_buf_nmi;

typedef typeof(char [FTRACE_MAX_PROFILE_SIZE]) perf_trace_t ;
typedef typeof(char [PERF_MAX_TRACE_SIZE]) perf_trace_t ;

/* Count the events in use (per event id, not per instance) */
static int total_profile_count;
static int total_ref_count;

static int ftrace_profile_enable_event(struct ftrace_event_call *event)
static int perf_trace_event_enable(struct ftrace_event_call *event)
{
char *buf;
int ret = -ENOMEM;

if (event->profile_count++ > 0)
if (event->perf_refcount++ > 0)
return 0;

if (!total_profile_count) {
if (!total_ref_count) {
buf = (char *)alloc_percpu(perf_trace_t);
if (!buf)
goto fail_buf;
Expand All @@ -41,35 +41,35 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
rcu_assign_pointer(perf_trace_buf_nmi, buf);
}

ret = event->profile_enable(event);
ret = event->perf_event_enable(event);
if (!ret) {
total_profile_count++;
total_ref_count++;
return 0;
}

fail_buf_nmi:
if (!total_profile_count) {
if (!total_ref_count) {
free_percpu(perf_trace_buf_nmi);
free_percpu(perf_trace_buf);
perf_trace_buf_nmi = NULL;
perf_trace_buf = NULL;
}
fail_buf:
event->profile_count--;
event->perf_refcount--;

return ret;
}

int ftrace_profile_enable(int event_id)
int perf_trace_enable(int event_id)
{
struct ftrace_event_call *event;
int ret = -EINVAL;

mutex_lock(&event_mutex);
list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id && event->profile_enable &&
if (event->id == event_id && event->perf_event_enable &&
try_module_get(event->mod)) {
ret = ftrace_profile_enable_event(event);
ret = perf_trace_event_enable(event);
break;
}
}
Expand All @@ -78,16 +78,16 @@ int ftrace_profile_enable(int event_id)
return ret;
}

static void ftrace_profile_disable_event(struct ftrace_event_call *event)
static void perf_trace_event_disable(struct ftrace_event_call *event)
{
char *buf, *nmi_buf;

if (--event->profile_count > 0)
if (--event->perf_refcount > 0)
return;

event->profile_disable(event);
event->perf_event_disable(event);

if (!--total_profile_count) {
if (!--total_ref_count) {
buf = perf_trace_buf;
rcu_assign_pointer(perf_trace_buf, NULL);

Expand All @@ -105,23 +105,23 @@ static void ftrace_profile_disable_event(struct ftrace_event_call *event)
}
}

void ftrace_profile_disable(int event_id)
void perf_trace_disable(int event_id)
{
struct ftrace_event_call *event;

mutex_lock(&event_mutex);
list_for_each_entry(event, &ftrace_events, list) {
if (event->id == event_id) {
ftrace_profile_disable_event(event);
perf_trace_event_disable(event);
module_put(event->mod);
break;
}
}
mutex_unlock(&event_mutex);
}

__kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type,
int *rctxp, unsigned long *irq_flags)
__kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
int *rctxp, unsigned long *irq_flags)
{
struct trace_entry *entry;
char *trace_buf, *raw_data;
Expand Down Expand Up @@ -162,4 +162,4 @@ __kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type,
local_irq_restore(*irq_flags);
return NULL;
}
EXPORT_SYMBOL_GPL(ftrace_perf_buf_prepare);
EXPORT_SYMBOL_GPL(perf_trace_buf_prepare);
2 changes: 1 addition & 1 deletion kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
trace_create_file("enable", 0644, call->dir, call,
enable);

if (call->id && call->profile_enable)
if (call->id && call->perf_event_enable)
trace_create_file("id", 0444, call->dir, call,
id);

Expand Down
Loading

0 comments on commit 97d5a22

Please sign in to comment.