Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158435
b: refs/heads/master
c: 19007a6
h: refs/heads/master
i:
  158433: 5f44a8d
  158431: 2457e4d
v: v3
  • Loading branch information
Frederic Weisbecker committed Aug 11, 2009
1 parent fabe448 commit 7185fc3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 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: dc4ddb4c0b7348f1c9759ae8a9e7d734dc1cda82
refs/heads/master: 19007a67a64f9b3cbbd7024f972654ebf14daade
39 changes: 37 additions & 2 deletions trunk/kernel/trace/trace_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,28 @@ struct trace_event event_syscall_exit = {
};

#ifdef CONFIG_EVENT_PROFILE

struct syscall_enter_record {
struct trace_entry entry;
unsigned long args[0];
};

struct syscall_exit_record {
struct trace_entry entry;
unsigned long ret;
};

static DECLARE_BITMAP(enabled_prof_enter_syscalls, FTRACE_SYSCALL_MAX);
static DECLARE_BITMAP(enabled_prof_exit_syscalls, FTRACE_SYSCALL_MAX);
static int sys_prof_refcount_enter;
static int sys_prof_refcount_exit;

static void prof_syscall_enter(struct pt_regs *regs, long id)
{
struct syscall_enter_record *rec;
struct syscall_metadata *sys_data;
int syscall_nr;
int size;

syscall_nr = syscall_get_nr(current, regs);
if (!test_bit(syscall_nr, enabled_prof_enter_syscalls))
Expand All @@ -319,7 +332,24 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
if (!sys_data)
return;

perf_tpcounter_event(sys_data->enter_id, 0, 1, NULL, 0);
/* get the size after alignment with the u32 buffer size field */
size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
size = ALIGN(size + sizeof(u32), sizeof(u64));
size -= sizeof(u32);

do {
char raw_data[size];

/* zero the dead bytes from align to not leak stack to user */
*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;

rec = (struct syscall_enter_record *) raw_data;
tracing_generic_entry_update(&rec->entry, 0, 0);
rec->entry.type = sys_data->enter_id;
syscall_get_arguments(current, regs, 0, sys_data->nb_args,
(unsigned long *)&rec->args);
perf_tpcounter_event(sys_data->enter_id, 0, 1, rec, size);
} while(0);
}

int reg_prof_syscall_enter(char *name)
Expand Down Expand Up @@ -364,6 +394,7 @@ void unreg_prof_syscall_enter(char *name)
static void prof_syscall_exit(struct pt_regs *regs, long ret)
{
struct syscall_metadata *sys_data;
struct syscall_exit_record rec;
int syscall_nr;

syscall_nr = syscall_get_nr(current, regs);
Expand All @@ -374,7 +405,11 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
if (!sys_data)
return;

perf_tpcounter_event(sys_data->exit_id, 0, 1, NULL, 0);
tracing_generic_entry_update(&rec.entry, 0, 0);
rec.entry.type = sys_data->exit_id;
rec.ret = syscall_get_return_value(current, regs);

perf_tpcounter_event(sys_data->exit_id, 0, 1, &rec, sizeof(rec));
}

int reg_prof_syscall_exit(char *name)
Expand Down

0 comments on commit 7185fc3

Please sign in to comment.