diff options
Diffstat (limited to 'arch/sh/kernel/ftrace.c')
| -rw-r--r-- | arch/sh/kernel/ftrace.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c index a3dcc6d5d253..2c48e267256e 100644 --- a/arch/sh/kernel/ftrace.c +++ b/arch/sh/kernel/ftrace.c | |||
| @@ -291,31 +291,48 @@ struct syscall_metadata *syscall_nr_to_meta(int nr) | |||
| 291 | return syscalls_metadata[nr]; | 291 | return syscalls_metadata[nr]; |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | void arch_init_ftrace_syscalls(void) | 294 | int syscall_name_to_nr(char *name) |
| 295 | { | ||
| 296 | int i; | ||
| 297 | |||
| 298 | if (!syscalls_metadata) | ||
| 299 | return -1; | ||
| 300 | for (i = 0; i < NR_syscalls; i++) | ||
| 301 | if (syscalls_metadata[i]) | ||
| 302 | if (!strcmp(syscalls_metadata[i]->name, name)) | ||
| 303 | return i; | ||
| 304 | return -1; | ||
| 305 | } | ||
| 306 | |||
| 307 | void set_syscall_enter_id(int num, int id) | ||
| 308 | { | ||
| 309 | syscalls_metadata[num]->enter_id = id; | ||
| 310 | } | ||
| 311 | |||
| 312 | void set_syscall_exit_id(int num, int id) | ||
| 313 | { | ||
| 314 | syscalls_metadata[num]->exit_id = id; | ||
| 315 | } | ||
| 316 | |||
| 317 | static int __init arch_init_ftrace_syscalls(void) | ||
| 295 | { | 318 | { |
| 296 | int i; | 319 | int i; |
| 297 | struct syscall_metadata *meta; | 320 | struct syscall_metadata *meta; |
| 298 | unsigned long **psys_syscall_table = &sys_call_table; | 321 | unsigned long **psys_syscall_table = &sys_call_table; |
| 299 | static atomic_t refs; | ||
| 300 | |||
| 301 | if (atomic_inc_return(&refs) != 1) | ||
| 302 | goto end; | ||
| 303 | 322 | ||
| 304 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * | 323 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * |
| 305 | FTRACE_SYSCALL_MAX, GFP_KERNEL); | 324 | FTRACE_SYSCALL_MAX, GFP_KERNEL); |
| 306 | if (!syscalls_metadata) { | 325 | if (!syscalls_metadata) { |
| 307 | WARN_ON(1); | 326 | WARN_ON(1); |
| 308 | return; | 327 | return -ENOMEM; |
| 309 | } | 328 | } |
| 310 | 329 | ||
| 311 | for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { | 330 | for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { |
| 312 | meta = find_syscall_meta(psys_syscall_table[i]); | 331 | meta = find_syscall_meta(psys_syscall_table[i]); |
| 313 | syscalls_metadata[i] = meta; | 332 | syscalls_metadata[i] = meta; |
| 314 | } | 333 | } |
| 315 | return; | ||
| 316 | 334 | ||
| 317 | /* Paranoid: avoid overflow */ | 335 | return 0; |
| 318 | end: | ||
| 319 | atomic_dec(&refs); | ||
| 320 | } | 336 | } |
| 337 | arch_initcall(arch_init_ftrace_syscalls); | ||
| 321 | #endif /* CONFIG_FTRACE_SYSCALLS */ | 338 | #endif /* CONFIG_FTRACE_SYSCALLS */ |
