diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2009-12-01 03:23:47 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-01 11:33:29 -0500 |
commit | c252f65793874b56d50395ab604db465ce688665 (patch) | |
tree | 30bc32361d2b368679910270ec4e99e841fa099b | |
parent | fcc19438dda38dacc8c144e2db3ebc6b9fd4f8b8 (diff) |
trace_syscalls: Add syscall_nr field to struct syscall_metadata
Add syscall_nr field to struct syscall_metadata,
it helps us to get syscall number easier.
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: <4B14D293.6090800@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/syscalls.h | 4 | ||||
-rw-r--r-- | include/trace/syscall.h | 3 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 22 |
3 files changed, 13 insertions, 16 deletions
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b9af87560adb..3c280d7ecb76 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -161,7 +161,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \ | |||
161 | static int init_enter_##sname(struct ftrace_event_call *call) \ | 161 | static int init_enter_##sname(struct ftrace_event_call *call) \ |
162 | { \ | 162 | { \ |
163 | int num, id; \ | 163 | int num, id; \ |
164 | num = syscall_name_to_nr("sys"#sname); \ | 164 | num = __syscall_meta_##sname.syscall_nr; \ |
165 | if (num < 0) \ | 165 | if (num < 0) \ |
166 | return -ENOSYS; \ | 166 | return -ENOSYS; \ |
167 | id = register_ftrace_event(&enter_syscall_print_##sname);\ | 167 | id = register_ftrace_event(&enter_syscall_print_##sname);\ |
@@ -197,7 +197,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \ | |||
197 | static int init_exit_##sname(struct ftrace_event_call *call) \ | 197 | static int init_exit_##sname(struct ftrace_event_call *call) \ |
198 | { \ | 198 | { \ |
199 | int num, id; \ | 199 | int num, id; \ |
200 | num = syscall_name_to_nr("sys"#sname); \ | 200 | num = __syscall_meta_##sname.syscall_nr; \ |
201 | if (num < 0) \ | 201 | if (num < 0) \ |
202 | return -ENOSYS; \ | 202 | return -ENOSYS; \ |
203 | id = register_ftrace_event(&exit_syscall_print_##sname);\ | 203 | id = register_ftrace_event(&exit_syscall_print_##sname);\ |
diff --git a/include/trace/syscall.h b/include/trace/syscall.h index ca09561cd578..1531eef3071f 100644 --- a/include/trace/syscall.h +++ b/include/trace/syscall.h | |||
@@ -12,6 +12,7 @@ | |||
12 | * A syscall entry in the ftrace syscalls array. | 12 | * A syscall entry in the ftrace syscalls array. |
13 | * | 13 | * |
14 | * @name: name of the syscall | 14 | * @name: name of the syscall |
15 | * @syscall_nr: number of the syscall | ||
15 | * @nb_args: number of parameters it takes | 16 | * @nb_args: number of parameters it takes |
16 | * @types: list of types as strings | 17 | * @types: list of types as strings |
17 | * @args: list of args as strings (args[i] matches types[i]) | 18 | * @args: list of args as strings (args[i] matches types[i]) |
@@ -20,6 +21,7 @@ | |||
20 | */ | 21 | */ |
21 | struct syscall_metadata { | 22 | struct syscall_metadata { |
22 | const char *name; | 23 | const char *name; |
24 | int syscall_nr; | ||
23 | int nb_args; | 25 | int nb_args; |
24 | const char **types; | 26 | const char **types; |
25 | const char **args; | 27 | const char **args; |
@@ -30,7 +32,6 @@ struct syscall_metadata { | |||
30 | 32 | ||
31 | #ifdef CONFIG_FTRACE_SYSCALLS | 33 | #ifdef CONFIG_FTRACE_SYSCALLS |
32 | extern unsigned long arch_syscall_addr(int nr); | 34 | extern unsigned long arch_syscall_addr(int nr); |
33 | extern int syscall_name_to_nr(const char *name); | ||
34 | 35 | ||
35 | extern int syscall_enter_format(struct ftrace_event_call *call, | 36 | extern int syscall_enter_format(struct ftrace_event_call *call, |
36 | struct trace_seq *s); | 37 | struct trace_seq *s); |
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 27eb18d69222..144cc14d8551 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -51,7 +51,7 @@ static struct syscall_metadata *syscall_nr_to_meta(int nr) | |||
51 | return syscalls_metadata[nr]; | 51 | return syscalls_metadata[nr]; |
52 | } | 52 | } |
53 | 53 | ||
54 | int syscall_name_to_nr(const char *name) | 54 | static int syscall_name_to_nr(const char *name) |
55 | { | 55 | { |
56 | int i; | 56 | int i; |
57 | 57 | ||
@@ -342,10 +342,8 @@ int reg_event_syscall_enter(struct ftrace_event_call *call) | |||
342 | { | 342 | { |
343 | int ret = 0; | 343 | int ret = 0; |
344 | int num; | 344 | int num; |
345 | const char *name; | ||
346 | 345 | ||
347 | name = ((struct syscall_metadata *)call->data)->name; | 346 | num = ((struct syscall_metadata *)call->data)->syscall_nr; |
348 | num = syscall_name_to_nr(name); | ||
349 | if (num < 0 || num >= NR_syscalls) | 347 | if (num < 0 || num >= NR_syscalls) |
350 | return -ENOSYS; | 348 | return -ENOSYS; |
351 | mutex_lock(&syscall_trace_lock); | 349 | mutex_lock(&syscall_trace_lock); |
@@ -365,10 +363,8 @@ int reg_event_syscall_enter(struct ftrace_event_call *call) | |||
365 | void unreg_event_syscall_enter(struct ftrace_event_call *call) | 363 | void unreg_event_syscall_enter(struct ftrace_event_call *call) |
366 | { | 364 | { |
367 | int num; | 365 | int num; |
368 | const char *name; | ||
369 | 366 | ||
370 | name = ((struct syscall_metadata *)call->data)->name; | 367 | num = ((struct syscall_metadata *)call->data)->syscall_nr; |
371 | num = syscall_name_to_nr(name); | ||
372 | if (num < 0 || num >= NR_syscalls) | 368 | if (num < 0 || num >= NR_syscalls) |
373 | return; | 369 | return; |
374 | mutex_lock(&syscall_trace_lock); | 370 | mutex_lock(&syscall_trace_lock); |
@@ -383,10 +379,8 @@ int reg_event_syscall_exit(struct ftrace_event_call *call) | |||
383 | { | 379 | { |
384 | int ret = 0; | 380 | int ret = 0; |
385 | int num; | 381 | int num; |
386 | const char *name; | ||
387 | 382 | ||
388 | name = ((struct syscall_metadata *)call->data)->name; | 383 | num = ((struct syscall_metadata *)call->data)->syscall_nr; |
389 | num = syscall_name_to_nr(name); | ||
390 | if (num < 0 || num >= NR_syscalls) | 384 | if (num < 0 || num >= NR_syscalls) |
391 | return -ENOSYS; | 385 | return -ENOSYS; |
392 | mutex_lock(&syscall_trace_lock); | 386 | mutex_lock(&syscall_trace_lock); |
@@ -406,10 +400,8 @@ int reg_event_syscall_exit(struct ftrace_event_call *call) | |||
406 | void unreg_event_syscall_exit(struct ftrace_event_call *call) | 400 | void unreg_event_syscall_exit(struct ftrace_event_call *call) |
407 | { | 401 | { |
408 | int num; | 402 | int num; |
409 | const char *name; | ||
410 | 403 | ||
411 | name = ((struct syscall_metadata *)call->data)->name; | 404 | num = ((struct syscall_metadata *)call->data)->syscall_nr; |
412 | num = syscall_name_to_nr(name); | ||
413 | if (num < 0 || num >= NR_syscalls) | 405 | if (num < 0 || num >= NR_syscalls) |
414 | return; | 406 | return; |
415 | mutex_lock(&syscall_trace_lock); | 407 | mutex_lock(&syscall_trace_lock); |
@@ -436,6 +428,10 @@ int __init init_ftrace_syscalls(void) | |||
436 | for (i = 0; i < NR_syscalls; i++) { | 428 | for (i = 0; i < NR_syscalls; i++) { |
437 | addr = arch_syscall_addr(i); | 429 | addr = arch_syscall_addr(i); |
438 | meta = find_syscall_meta(addr); | 430 | meta = find_syscall_meta(addr); |
431 | if (!meta) | ||
432 | continue; | ||
433 | |||
434 | meta->syscall_nr = i; | ||
439 | syscalls_metadata[i] = meta; | 435 | syscalls_metadata[i] = meta; |
440 | } | 436 | } |
441 | 437 | ||