Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158447
b: refs/heads/master
c: 540b7b8
h: refs/heads/master
i:
  158445: 32666e5
  158443: 99ee596
  158439: be7eb64
  158431: 2457e4d
v: v3
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Aug 19, 2009
1 parent 4936b17 commit b7959c4
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 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: e647d6b314266adb904d4b84973eda0afa856946
refs/heads/master: 540b7b8d65575c80162f2a0f38e1d313c92a6042
5 changes: 3 additions & 2 deletions trunk/include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ extern int filter_current_check_discard(struct ftrace_event_call *call,
void *rec,
struct ring_buffer_event *event);

extern int trace_define_field(struct ftrace_event_call *call, char *type,
char *name, int offset, int size, int is_signed);
extern int trace_define_field(struct ftrace_event_call *call,
const char *type, const char *name,
int offset, int size, int is_signed);
extern int trace_define_common_fields(struct ftrace_event_call *call);

#define is_signed_type(type) (((type)(-1)) < 0)
Expand Down
16 changes: 11 additions & 5 deletions trunk/include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
.event = &event_syscall_enter, \
.raw_init = init_enter_##sname, \
.show_format = syscall_enter_format, \
.define_fields = syscall_enter_define_fields, \
.regfunc = reg_event_syscall_enter, \
.unregfunc = unreg_event_syscall_enter, \
.data = "sys"#sname, \
Expand Down Expand Up @@ -226,13 +227,16 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
.event = &event_syscall_exit, \
.raw_init = init_exit_##sname, \
.show_format = syscall_exit_format, \
.define_fields = syscall_exit_define_fields, \
.regfunc = reg_event_syscall_exit, \
.unregfunc = unreg_event_syscall_exit, \
.data = "sys"#sname, \
TRACE_SYS_EXIT_PROFILE_INIT(sname) \
}

#define SYSCALL_METADATA(sname, nb) \
SYSCALL_TRACE_ENTER_EVENT(sname); \
SYSCALL_TRACE_EXIT_EVENT(sname); \
static const struct syscall_metadata __used \
__attribute__((__aligned__(4))) \
__attribute__((section("__syscalls_metadata"))) \
Expand All @@ -241,20 +245,22 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
.nb_args = nb, \
.types = types_##sname, \
.args = args_##sname, \
}; \
SYSCALL_TRACE_ENTER_EVENT(sname); \
SYSCALL_TRACE_EXIT_EVENT(sname);
.enter_event = &event_enter_##sname, \
.exit_event = &event_exit_##sname, \
};

#define SYSCALL_DEFINE0(sname) \
SYSCALL_TRACE_ENTER_EVENT(_##sname); \
SYSCALL_TRACE_EXIT_EVENT(_##sname); \
static const 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, \
}; \
SYSCALL_TRACE_ENTER_EVENT(_##sname); \
SYSCALL_TRACE_EXIT_EVENT(_##sname); \
asmlinkage long sys_##sname(void)
#else
#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/trace/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ DECLARE_TRACE_WITH_CALLBACK(syscall_exit,
* @args: list of args as strings (args[i] matches types[i])
* @enter_id: associated ftrace enter event id
* @exit_id: associated ftrace exit event id
* @enter_event: associated syscall_enter trace event
* @exit_event: associated syscall_exit trace event
*/
struct syscall_metadata {
const char *name;
Expand All @@ -42,6 +44,9 @@ struct syscall_metadata {
const char **args;
int enter_id;
int exit_id;

struct ftrace_event_call *enter_event;
struct ftrace_event_call *exit_event;
};

#ifdef CONFIG_FTRACE_SYSCALLS
Expand All @@ -59,6 +64,8 @@ extern int syscall_enter_format(struct ftrace_event_call *call,
struct trace_seq *s);
extern int syscall_exit_format(struct ftrace_event_call *call,
struct trace_seq *s);
extern int syscall_enter_define_fields(struct ftrace_event_call *call);
extern int syscall_exit_define_fields(struct ftrace_event_call *call);
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);
#endif
Expand Down
5 changes: 3 additions & 2 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ DEFINE_MUTEX(event_mutex);

LIST_HEAD(ftrace_events);

int trace_define_field(struct ftrace_event_call *call, char *type,
char *name, int offset, int size, int is_signed)
int trace_define_field(struct ftrace_event_call *call, const char *type,
const char *name, int offset, int size, int is_signed)
{
struct ftrace_event_field *field;

Expand Down Expand Up @@ -83,6 +83,7 @@ int trace_define_common_fields(struct ftrace_event_call *call)

return ret;
}
EXPORT_SYMBOL_GPL(trace_define_common_fields);

#ifdef CONFIG_MODULES

Expand Down
51 changes: 47 additions & 4 deletions trunk/kernel/trace/trace_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,49 @@ int syscall_exit_format(struct ftrace_event_call *call, struct trace_seq *s)
return trace_seq_printf(s, "\nprint fmt: \"0x%%lx\", REC->ret\n");
}

int syscall_enter_define_fields(struct ftrace_event_call *call)
{
struct syscall_trace_enter trace;
struct syscall_metadata *meta;
int ret;
int nr;
int i;
int offset = offsetof(typeof(trace), args);

nr = syscall_name_to_nr(call->data);
meta = syscall_nr_to_meta(nr);

if (!meta)
return 0;

ret = trace_define_common_fields(call);
if (ret)
return ret;

for (i = 0; i < meta->nb_args; i++) {
ret = trace_define_field(call, meta->types[i],
meta->args[i], offset,
sizeof(unsigned long), 0);
offset += sizeof(unsigned long);
}

return ret;
}

int syscall_exit_define_fields(struct ftrace_event_call *call)
{
struct syscall_trace_exit trace;
int ret;

ret = trace_define_common_fields(call);
if (ret)
return ret;

ret = trace_define_field(call, SYSCALL_FIELD(unsigned long, ret), 0);

return ret;
}

void ftrace_syscall_enter(struct pt_regs *regs, long id)
{
struct syscall_trace_enter *entry;
Expand Down Expand Up @@ -192,8 +235,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
entry->nr = syscall_nr;
syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);

trace_current_buffer_unlock_commit(event, 0, 0);
trace_wake_up();
if (!filter_current_check_discard(sys_data->enter_event, entry, event))
trace_current_buffer_unlock_commit(event, 0, 0);
}

void ftrace_syscall_exit(struct pt_regs *regs, long ret)
Expand All @@ -220,8 +263,8 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
entry->nr = syscall_nr;
entry->ret = syscall_get_return_value(current, regs);

trace_current_buffer_unlock_commit(event, 0, 0);
trace_wake_up();
if (!filter_current_check_discard(sys_data->exit_event, entry, event))
trace_current_buffer_unlock_commit(event, 0, 0);
}

int reg_event_syscall_enter(void *ptr)
Expand Down

0 comments on commit b7959c4

Please sign in to comment.