Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199135
b: refs/heads/master
c: 2e33af0
h: refs/heads/master
i:
  199133: 9178b2d
  199131: 174845f
  199127: 697c202
  199119: eaae6ef
  199103: c9df853
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed May 14, 2010
1 parent d51b46f commit b944a85
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 47 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2239291aeb0379fe47980b0e560e0eb9fd7e82ec
refs/heads/master: 2e33af029556cb8bd22bf4f86f42d540249177ea
5 changes: 3 additions & 2 deletions trunk/include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ struct ftrace_event_class {
#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;
};

struct ftrace_event_call {
Expand All @@ -142,8 +145,6 @@ struct ftrace_event_call {
int id;
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;
Expand Down
14 changes: 8 additions & 6 deletions trunk/include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extern struct ftrace_event_class event_class_syscall_enter;
extern struct ftrace_event_class event_class_syscall_exit;

#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 = { \
Expand All @@ -136,12 +136,11 @@ extern struct ftrace_event_class event_class_syscall_exit;
.class = &event_class_syscall_enter, \
.event = &enter_syscall_print_##sname, \
.raw_init = init_syscall_trace, \
.define_fields = syscall_enter_define_fields, \
.data = (void *)&__syscall_meta_##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 = { \
Expand All @@ -155,14 +154,13 @@ extern struct ftrace_event_class event_class_syscall_exit;
.class = &event_class_syscall_exit, \
.event = &exit_syscall_print_##sname, \
.raw_init = init_syscall_trace, \
.define_fields = syscall_exit_define_fields, \
.data = (void *)&__syscall_meta_##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 = { \
Expand All @@ -172,19 +170,23 @@ extern struct ftrace_event_class event_class_syscall_exit;
.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 = { \
.name = "sys_"#sname, \
.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
Expand Down
11 changes: 6 additions & 5 deletions trunk/include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ static inline notrace int ftrace_get_offsets_##call( \
*
* 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), \
* .probe = ftrace_raw_event_##call, \
* };
*
* static struct ftrace_event_call __used
Expand All @@ -438,10 +441,8 @@ static inline notrace int ftrace_get_offsets_##call( \
* .name = "<call>",
* .class = event_class_<template>,
* .raw_init = trace_event_raw_init,
* .regfunc = ftrace_raw_reg_event_<call>,
* .unregfunc = ftrace_raw_unreg_event_<call>,
* .event = &ftrace_event_type_<call>,
* .print_fmt = print_fmt_<call>,
* .define_fields = ftrace_define_fields_<call>,
* };
*
*/
Expand Down Expand Up @@ -563,6 +564,8 @@ _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),\
.probe = ftrace_raw_event_##call, \
_TRACE_PERF_INIT(call) \
};
Expand All @@ -578,7 +581,6 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.event = &ftrace_event_type_##call, \
.raw_init = trace_event_raw_init, \
.print_fmt = print_fmt_##template, \
.define_fields = ftrace_define_fields_##template, \
};

#undef DEFINE_EVENT_PRINT
Expand All @@ -594,7 +596,6 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.event = &ftrace_event_type_##call, \
.raw_init = trace_event_raw_init, \
.print_fmt = print_fmt_##call, \
.define_fields = ftrace_define_fields_##template, \
}

#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/trace/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,8 +36,6 @@ 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);
Expand Down
3 changes: 3 additions & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,9 @@ 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,
Expand Down
48 changes: 36 additions & 12 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -111,7 +126,6 @@ int trace_event_raw_init(struct ftrace_event_call *call)
if (!id)
return -ENODEV;
call->id = id;
INIT_LIST_HEAD(&call->fields);

return 0;
}
Expand Down Expand Up @@ -537,6 +551,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;
Expand All @@ -555,7 +570,8 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
trace_seq_printf(s, "ID: %d\n", call->id);
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:
Expand Down Expand Up @@ -931,6 +947,7 @@ 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;

/*
Expand All @@ -957,14 +974,21 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
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);
Expand Down
10 changes: 6 additions & 4 deletions trunk/kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,10 @@ static struct ftrace_event_field *
find_event_field(struct ftrace_event_call *call, char *name)
{
struct ftrace_event_field *field;
struct list_head *head;

list_for_each_entry(field, &call->fields, link) {
head = trace_get_fields(call);
list_for_each_entry(field, head, link) {
if (!strcmp(field->name, name))
return field;
}
Expand Down Expand Up @@ -625,7 +627,7 @@ static int init_subsystem_preds(struct event_subsystem *system)
int err;

list_for_each_entry(call, &ftrace_events, list) {
if (!call->define_fields)
if (!call->class || !call->class->define_fields)
continue;

if (strcmp(call->class->system, system->name) != 0)
Expand All @@ -644,7 +646,7 @@ static void filter_free_subsystem_preds(struct event_subsystem *system)
struct ftrace_event_call *call;

list_for_each_entry(call, &ftrace_events, list) {
if (!call->define_fields)
if (!call->class || !call->class->define_fields)
continue;

if (strcmp(call->class->system, system->name) != 0)
Expand Down Expand Up @@ -1249,7 +1251,7 @@ static int replace_system_preds(struct event_subsystem *system,
list_for_each_entry(call, &ftrace_events, list) {
struct event_filter *filter = call->filter;

if (!call->define_fields)
if (!call->class || !call->class->define_fields)
continue;

if (strcmp(call->class->system, system->name) != 0)
Expand Down
14 changes: 7 additions & 7 deletions trunk/kernel/trace/trace_export.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
#undef TRACE_SYSTEM
#define TRACE_SYSTEM ftrace

struct ftrace_event_class event_class_ftrace = {
.system = __stringify(TRACE_SYSTEM),
};

/* not needed for this file */
#undef __field_struct
#define __field_struct(type, item)
Expand Down Expand Up @@ -131,7 +127,7 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \

static int ftrace_raw_init_event(struct ftrace_event_call *call)
{
INIT_LIST_HEAD(&call->fields);
INIT_LIST_HEAD(&call->class->fields);
return 0;
}

Expand Down Expand Up @@ -159,15 +155,19 @@ static int ftrace_raw_init_event(struct ftrace_event_call *call)
#undef FTRACE_ENTRY
#define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \
\
struct ftrace_event_class event_class_ftrace_##call = { \
.system = __stringify(TRACE_SYSTEM), \
.define_fields = ftrace_define_fields_##call, \
}; \
\
struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) event_##call = { \
.name = #call, \
.id = type, \
.class = &event_class_ftrace, \
.class = &event_class_ftrace_##call, \
.raw_init = ftrace_raw_init_event, \
.print_fmt = print, \
.define_fields = ftrace_define_fields_##call, \
}; \

#include "trace_entries.h"
8 changes: 4 additions & 4 deletions trunk/kernel/trace/trace_kprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,6 @@ static void probe_event_disable(struct ftrace_event_call *call)

static int probe_event_raw_init(struct ftrace_event_call *event_call)
{
INIT_LIST_HEAD(&event_call->fields);

return 0;
}

Expand Down Expand Up @@ -1362,11 +1360,13 @@ static int register_probe_event(struct trace_probe *tp)
if (probe_is_return(tp)) {
tp->event.trace = print_kretprobe_event;
call->raw_init = probe_event_raw_init;
call->define_fields = kretprobe_event_define_fields;
INIT_LIST_HEAD(&call->class->fields);
call->class->define_fields = kretprobe_event_define_fields;
} else {
tp->event.trace = print_kprobe_event;
call->raw_init = probe_event_raw_init;
call->define_fields = kprobe_event_define_fields;
INIT_LIST_HEAD(&call->class->fields);
call->class->define_fields = kprobe_event_define_fields;
}
if (set_print_fmt(tp) < 0)
return -ENOMEM;
Expand Down
Loading

0 comments on commit b944a85

Please sign in to comment.