trace_syscalls: Add syscall_nr field to struct syscall_metadata
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 1 Dec 2009 08:23:47 +0000 (16:23 +0800)
committerIngo Molnar <mingo@elte.hu>
Tue, 1 Dec 2009 16:33:29 +0000 (17:33 +0100)
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>
include/linux/syscalls.h
include/trace/syscall.h
kernel/trace/trace_syscalls.c

index b9af87560adb34203ea618b3a1186241356ea253..3c280d7ecb7656d50aff9a2f7ca1391ddac6b294 100644 (file)
@@ -161,7 +161,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused)     \
        static int init_enter_##sname(struct ftrace_event_call *call)   \
        {                                                               \
                int num, id;                                            \
-               num = syscall_name_to_nr("sys"#sname);                  \
+               num = __syscall_meta_##sname.syscall_nr;                \
                if (num < 0)                                            \
                        return -ENOSYS;                                 \
                id = register_ftrace_event(&enter_syscall_print_##sname);\
@@ -197,7 +197,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused)     \
        static int init_exit_##sname(struct ftrace_event_call *call)    \
        {                                                               \
                int num, id;                                            \
-               num = syscall_name_to_nr("sys"#sname);                  \
+               num = __syscall_meta_##sname.syscall_nr;                \
                if (num < 0)                                            \
                        return -ENOSYS;                                 \
                id = register_ftrace_event(&exit_syscall_print_##sname);\
index ca09561cd57873cd76ffb83e22e0c2880f796bd4..1531eef3071f8ddd10654fd32ce0a6abab83314b 100644 (file)
@@ -12,6 +12,7 @@
  * A syscall entry in the ftrace syscalls array.
  *
  * @name: name of the syscall
+ * @syscall_nr: number of the syscall
  * @nb_args: number of parameters it takes
  * @types: list of types as strings
  * @args: list of args as strings (args[i] matches types[i])
@@ -20,6 +21,7 @@
  */
 struct syscall_metadata {
        const char      *name;
+       int             syscall_nr;
        int             nb_args;
        const char      **types;
        const char      **args;
@@ -30,7 +32,6 @@ struct syscall_metadata {
 
 #ifdef CONFIG_FTRACE_SYSCALLS
 extern unsigned long arch_syscall_addr(int nr);
-extern int syscall_name_to_nr(const char *name);
 
 extern int syscall_enter_format(struct ftrace_event_call *call,
                                struct trace_seq *s);
index 27eb18d69222a7d3dafbb25f8bfef07145c3a0f7..144cc14d85519ed8de66d1968f3ee97ebbdbf893 100644 (file)
@@ -51,7 +51,7 @@ static struct syscall_metadata *syscall_nr_to_meta(int nr)
        return syscalls_metadata[nr];
 }
 
-int syscall_name_to_nr(const char *name)
+static int syscall_name_to_nr(const char *name)
 {
        int i;
 
@@ -342,10 +342,8 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 {
        int ret = 0;
        int num;
-       const char *name;
 
-       name = ((struct syscall_metadata *)call->data)->name;
-       num = syscall_name_to_nr(name);
+       num = ((struct syscall_metadata *)call->data)->syscall_nr;
        if (num < 0 || num >= NR_syscalls)
                return -ENOSYS;
        mutex_lock(&syscall_trace_lock);
@@ -365,10 +363,8 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 void unreg_event_syscall_enter(struct ftrace_event_call *call)
 {
        int num;
-       const char *name;
 
-       name = ((struct syscall_metadata *)call->data)->name;
-       num = syscall_name_to_nr(name);
+       num = ((struct syscall_metadata *)call->data)->syscall_nr;
        if (num < 0 || num >= NR_syscalls)
                return;
        mutex_lock(&syscall_trace_lock);
@@ -383,10 +379,8 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 {
        int ret = 0;
        int num;
-       const char *name;
 
-       name = ((struct syscall_metadata *)call->data)->name;
-       num = syscall_name_to_nr(name);
+       num = ((struct syscall_metadata *)call->data)->syscall_nr;
        if (num < 0 || num >= NR_syscalls)
                return -ENOSYS;
        mutex_lock(&syscall_trace_lock);
@@ -406,10 +400,8 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 void unreg_event_syscall_exit(struct ftrace_event_call *call)
 {
        int num;
-       const char *name;
 
-       name = ((struct syscall_metadata *)call->data)->name;
-       num = syscall_name_to_nr(name);
+       num = ((struct syscall_metadata *)call->data)->syscall_nr;
        if (num < 0 || num >= NR_syscalls)
                return;
        mutex_lock(&syscall_trace_lock);
@@ -436,6 +428,10 @@ int __init init_ftrace_syscalls(void)
        for (i = 0; i < NR_syscalls; i++) {
                addr = arch_syscall_addr(i);
                meta = find_syscall_meta(addr);
+               if (!meta)
+                       continue;
+
+               meta->syscall_nr = i;
                syscalls_metadata[i] = meta;
        }