Skip to content

Commit

Permalink
trace_syscalls: Simplify syscall profile
Browse files Browse the repository at this point in the history
use only one prof_sysenter_enable() instead of
prof_sysenter_enable_##sname()

use only one prof_sysenter_disable() instead of
prof_sysenter_disable_##sname()

use only one prof_sysexit_enable() instead of
prof_sysexit_enable_##sname()

use only one prof_sysexit_disable() instead of
prof_sysexit_disable_##sname()

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Jason Baron <jbaron@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <4B14D2A1.8060304@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Lai Jiangshan authored and Ingo Molnar committed Dec 1, 2009
1 parent a1301da commit 3bbe84e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 47 deletions.
31 changes: 4 additions & 27 deletions include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,37 +99,16 @@ struct perf_event_attr;
#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)

#ifdef CONFIG_EVENT_PROFILE
#define TRACE_SYS_ENTER_PROFILE(sname) \
static int prof_sysenter_enable_##sname(struct ftrace_event_call *unused) \
{ \
return reg_prof_syscall_enter("sys"#sname); \
} \
\
static void prof_sysenter_disable_##sname(struct ftrace_event_call *unused) \
{ \
unreg_prof_syscall_enter("sys"#sname); \
}

#define TRACE_SYS_EXIT_PROFILE(sname) \
static int prof_sysexit_enable_##sname(struct ftrace_event_call *unused) \
{ \
return reg_prof_syscall_exit("sys"#sname); \
} \
\
static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
{ \
unreg_prof_syscall_exit("sys"#sname); \
}

#define TRACE_SYS_ENTER_PROFILE_INIT(sname) \
.profile_count = ATOMIC_INIT(-1), \
.profile_enable = prof_sysenter_enable_##sname, \
.profile_disable = prof_sysenter_disable_##sname,
.profile_enable = prof_sysenter_enable, \
.profile_disable = prof_sysenter_disable,

#define TRACE_SYS_EXIT_PROFILE_INIT(sname) \
.profile_count = ATOMIC_INIT(-1), \
.profile_enable = prof_sysexit_enable_##sname, \
.profile_disable = prof_sysexit_disable_##sname,
.profile_enable = prof_sysexit_enable, \
.profile_disable = prof_sysexit_disable,
#else
#define TRACE_SYS_ENTER_PROFILE(sname)
#define TRACE_SYS_ENTER_PROFILE_INIT(sname)
Expand Down Expand Up @@ -158,7 +137,6 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
struct trace_event enter_syscall_print_##sname = { \
.trace = print_syscall_enter, \
}; \
TRACE_SYS_ENTER_PROFILE(sname); \
static struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) \
Expand All @@ -181,7 +159,6 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
struct trace_event exit_syscall_print_##sname = { \
.trace = print_syscall_exit, \
}; \
TRACE_SYS_EXIT_PROFILE(sname); \
static struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) \
Expand Down
8 changes: 4 additions & 4 deletions include/trace/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ 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
#ifdef CONFIG_EVENT_PROFILE
int reg_prof_syscall_enter(char *name);
void unreg_prof_syscall_enter(char *name);
int reg_prof_syscall_exit(char *name);
void unreg_prof_syscall_exit(char *name);
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);

#endif

Expand Down
24 changes: 8 additions & 16 deletions kernel/trace/trace_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,12 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
local_irq_restore(flags);
}

int reg_prof_syscall_enter(char *name)
int prof_sysenter_enable(struct ftrace_event_call *call)
{
int ret = 0;
int num;

num = syscall_name_to_nr(name);
if (num < 0 || num >= NR_syscalls)
return -ENOSYS;
num = ((struct syscall_metadata *)call->data)->syscall_nr;

mutex_lock(&syscall_trace_lock);
if (!sys_prof_refcount_enter)
Expand All @@ -543,13 +541,11 @@ int reg_prof_syscall_enter(char *name)
return ret;
}

void unreg_prof_syscall_enter(char *name)
void prof_sysenter_disable(struct ftrace_event_call *call)
{
int num;

num = syscall_name_to_nr(name);
if (num < 0 || num >= NR_syscalls)
return;
num = ((struct syscall_metadata *)call->data)->syscall_nr;

mutex_lock(&syscall_trace_lock);
sys_prof_refcount_enter--;
Expand Down Expand Up @@ -625,14 +621,12 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
local_irq_restore(flags);
}

int reg_prof_syscall_exit(char *name)
int prof_sysexit_enable(struct ftrace_event_call *call)
{
int ret = 0;
int num;

num = syscall_name_to_nr(name);
if (num < 0 || num >= NR_syscalls)
return -ENOSYS;
num = ((struct syscall_metadata *)call->data)->syscall_nr;

mutex_lock(&syscall_trace_lock);
if (!sys_prof_refcount_exit)
Expand All @@ -648,13 +642,11 @@ int reg_prof_syscall_exit(char *name)
return ret;
}

void unreg_prof_syscall_exit(char *name)
void prof_sysexit_disable(struct ftrace_event_call *call)
{
int num;

num = syscall_name_to_nr(name);
if (num < 0 || num >= NR_syscalls)
return;
num = ((struct syscall_metadata *)call->data)->syscall_nr;

mutex_lock(&syscall_trace_lock);
sys_prof_refcount_exit--;
Expand Down

0 comments on commit 3bbe84e

Please sign in to comment.