diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-08-28 07:53:07 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-28 07:53:07 -0400 |
commit | 66c6e29f24a50173fc1e761c3e2483c8d64e3b1a (patch) | |
tree | 15b9d212d02d6e1bae8696d9c5da9a778455f9c0 | |
parent | 6c347d43eea29221a8ebab9ff9cbe7a00cddac98 (diff) | |
parent | 117226d15850387b55fd01675917ee4fcb9699e8 (diff) |
Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
-rw-r--r-- | arch/s390/kernel/ftrace.c | 36 | ||||
-rw-r--r-- | arch/x86/include/asm/ftrace.h | 7 | ||||
-rw-r--r-- | arch/x86/include/asm/unistd_32.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/unistd_64.h | 6 | ||||
-rw-r--r-- | arch/x86/kernel/asm-offsets_64.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/ftrace.c | 8 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 28 | ||||
-rw-r--r-- | kernel/tracepoint.c | 4 |
8 files changed, 59 insertions, 33 deletions
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index 3e298e64f0db..57bdcb1e3cdf 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c | |||
@@ -220,6 +220,29 @@ struct syscall_metadata *syscall_nr_to_meta(int nr) | |||
220 | return syscalls_metadata[nr]; | 220 | return syscalls_metadata[nr]; |
221 | } | 221 | } |
222 | 222 | ||
223 | int syscall_name_to_nr(char *name) | ||
224 | { | ||
225 | int i; | ||
226 | |||
227 | if (!syscalls_metadata) | ||
228 | return -1; | ||
229 | for (i = 0; i < NR_syscalls; i++) | ||
230 | if (syscalls_metadata[i]) | ||
231 | if (!strcmp(syscalls_metadata[i]->name, name)) | ||
232 | return i; | ||
233 | return -1; | ||
234 | } | ||
235 | |||
236 | void set_syscall_enter_id(int num, int id) | ||
237 | { | ||
238 | syscalls_metadata[num]->enter_id = id; | ||
239 | } | ||
240 | |||
241 | void set_syscall_exit_id(int num, int id) | ||
242 | { | ||
243 | syscalls_metadata[num]->exit_id = id; | ||
244 | } | ||
245 | |||
223 | static struct syscall_metadata *find_syscall_meta(unsigned long syscall) | 246 | static struct syscall_metadata *find_syscall_meta(unsigned long syscall) |
224 | { | 247 | { |
225 | struct syscall_metadata *start; | 248 | struct syscall_metadata *start; |
@@ -237,24 +260,19 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall) | |||
237 | return NULL; | 260 | return NULL; |
238 | } | 261 | } |
239 | 262 | ||
240 | void arch_init_ftrace_syscalls(void) | 263 | static int __init arch_init_ftrace_syscalls(void) |
241 | { | 264 | { |
242 | struct syscall_metadata *meta; | 265 | struct syscall_metadata *meta; |
243 | int i; | 266 | int i; |
244 | static atomic_t refs; | ||
245 | |||
246 | if (atomic_inc_return(&refs) != 1) | ||
247 | goto out; | ||
248 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls, | 267 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls, |
249 | GFP_KERNEL); | 268 | GFP_KERNEL); |
250 | if (!syscalls_metadata) | 269 | if (!syscalls_metadata) |
251 | goto out; | 270 | return -ENOMEM; |
252 | for (i = 0; i < NR_syscalls; i++) { | 271 | for (i = 0; i < NR_syscalls; i++) { |
253 | meta = find_syscall_meta((unsigned long)sys_call_table[i]); | 272 | meta = find_syscall_meta((unsigned long)sys_call_table[i]); |
254 | syscalls_metadata[i] = meta; | 273 | syscalls_metadata[i] = meta; |
255 | } | 274 | } |
256 | return; | 275 | return 0; |
257 | out: | ||
258 | atomic_dec(&refs); | ||
259 | } | 276 | } |
277 | arch_initcall(arch_init_ftrace_syscalls); | ||
260 | #endif | 278 | #endif |
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index 71136545187a..db24c2278be0 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h | |||
@@ -28,13 +28,6 @@ | |||
28 | 28 | ||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | /* FIXME: I don't want to stay hardcoded */ | ||
32 | #ifdef CONFIG_X86_64 | ||
33 | # define FTRACE_SYSCALL_MAX 299 | ||
34 | #else | ||
35 | # define FTRACE_SYSCALL_MAX 337 | ||
36 | #endif | ||
37 | |||
38 | #ifdef CONFIG_FUNCTION_TRACER | 31 | #ifdef CONFIG_FUNCTION_TRACER |
39 | #define MCOUNT_ADDR ((long)(mcount)) | 32 | #define MCOUNT_ADDR ((long)(mcount)) |
40 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ | 33 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ |
diff --git a/arch/x86/include/asm/unistd_32.h b/arch/x86/include/asm/unistd_32.h index 732a30706153..8deaada61bc8 100644 --- a/arch/x86/include/asm/unistd_32.h +++ b/arch/x86/include/asm/unistd_32.h | |||
@@ -345,6 +345,8 @@ | |||
345 | 345 | ||
346 | #ifdef __KERNEL__ | 346 | #ifdef __KERNEL__ |
347 | 347 | ||
348 | #define NR_syscalls 337 | ||
349 | |||
348 | #define __ARCH_WANT_IPC_PARSE_VERSION | 350 | #define __ARCH_WANT_IPC_PARSE_VERSION |
349 | #define __ARCH_WANT_OLD_READDIR | 351 | #define __ARCH_WANT_OLD_READDIR |
350 | #define __ARCH_WANT_OLD_STAT | 352 | #define __ARCH_WANT_OLD_STAT |
diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h index 900e1617e672..b9f3c60de5f7 100644 --- a/arch/x86/include/asm/unistd_64.h +++ b/arch/x86/include/asm/unistd_64.h | |||
@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open) | |||
688 | #endif /* __NO_STUBS */ | 688 | #endif /* __NO_STUBS */ |
689 | 689 | ||
690 | #ifdef __KERNEL__ | 690 | #ifdef __KERNEL__ |
691 | |||
692 | #ifndef COMPILE_OFFSETS | ||
693 | #include <asm/asm-offsets.h> | ||
694 | #define NR_syscalls (__NR_syscall_max + 1) | ||
695 | #endif | ||
696 | |||
691 | /* | 697 | /* |
692 | * "Conditional" syscalls | 698 | * "Conditional" syscalls |
693 | * | 699 | * |
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c index 898ecc47e129..4a6aeedcd965 100644 --- a/arch/x86/kernel/asm-offsets_64.c +++ b/arch/x86/kernel/asm-offsets_64.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * This code generates raw asm output which is post-processed to extract | 3 | * This code generates raw asm output which is post-processed to extract |
4 | * and format the required data. | 4 | * and format the required data. |
5 | */ | 5 | */ |
6 | #define COMPILE_OFFSETS | ||
6 | 7 | ||
7 | #include <linux/crypto.h> | 8 | #include <linux/crypto.h> |
8 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 3cff1214e176..9dbb527e1652 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -494,7 +494,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long *syscall) | |||
494 | 494 | ||
495 | struct syscall_metadata *syscall_nr_to_meta(int nr) | 495 | struct syscall_metadata *syscall_nr_to_meta(int nr) |
496 | { | 496 | { |
497 | if (!syscalls_metadata || nr >= FTRACE_SYSCALL_MAX || nr < 0) | 497 | if (!syscalls_metadata || nr >= NR_syscalls || nr < 0) |
498 | return NULL; | 498 | return NULL; |
499 | 499 | ||
500 | return syscalls_metadata[nr]; | 500 | return syscalls_metadata[nr]; |
@@ -507,7 +507,7 @@ int syscall_name_to_nr(char *name) | |||
507 | if (!syscalls_metadata) | 507 | if (!syscalls_metadata) |
508 | return -1; | 508 | return -1; |
509 | 509 | ||
510 | for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { | 510 | for (i = 0; i < NR_syscalls; i++) { |
511 | if (syscalls_metadata[i]) { | 511 | if (syscalls_metadata[i]) { |
512 | if (!strcmp(syscalls_metadata[i]->name, name)) | 512 | if (!strcmp(syscalls_metadata[i]->name, name)) |
513 | return i; | 513 | return i; |
@@ -533,13 +533,13 @@ static int __init arch_init_ftrace_syscalls(void) | |||
533 | unsigned long **psys_syscall_table = &sys_call_table; | 533 | unsigned long **psys_syscall_table = &sys_call_table; |
534 | 534 | ||
535 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * | 535 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * |
536 | FTRACE_SYSCALL_MAX, GFP_KERNEL); | 536 | NR_syscalls, GFP_KERNEL); |
537 | if (!syscalls_metadata) { | 537 | if (!syscalls_metadata) { |
538 | WARN_ON(1); | 538 | WARN_ON(1); |
539 | return -ENOMEM; | 539 | return -ENOMEM; |
540 | } | 540 | } |
541 | 541 | ||
542 | for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { | 542 | for (i = 0; i < NR_syscalls; i++) { |
543 | meta = find_syscall_meta(psys_syscall_table[i]); | 543 | meta = find_syscall_meta(psys_syscall_table[i]); |
544 | syscalls_metadata[i] = meta; | 544 | syscalls_metadata[i] = meta; |
545 | } | 545 | } |
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 85291c4de406..4f5fae6fad90 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -11,8 +11,8 @@ | |||
11 | static DEFINE_MUTEX(syscall_trace_lock); | 11 | static DEFINE_MUTEX(syscall_trace_lock); |
12 | static int sys_refcount_enter; | 12 | static int sys_refcount_enter; |
13 | static int sys_refcount_exit; | 13 | static int sys_refcount_exit; |
14 | static DECLARE_BITMAP(enabled_enter_syscalls, FTRACE_SYSCALL_MAX); | 14 | static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls); |
15 | static DECLARE_BITMAP(enabled_exit_syscalls, FTRACE_SYSCALL_MAX); | 15 | static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls); |
16 | 16 | ||
17 | enum print_line_t | 17 | enum print_line_t |
18 | print_syscall_enter(struct trace_iterator *iter, int flags) | 18 | print_syscall_enter(struct trace_iterator *iter, int flags) |
@@ -227,6 +227,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id) | |||
227 | int syscall_nr; | 227 | int syscall_nr; |
228 | 228 | ||
229 | syscall_nr = syscall_get_nr(current, regs); | 229 | syscall_nr = syscall_get_nr(current, regs); |
230 | if (syscall_nr < 0) | ||
231 | return; | ||
230 | if (!test_bit(syscall_nr, enabled_enter_syscalls)) | 232 | if (!test_bit(syscall_nr, enabled_enter_syscalls)) |
231 | return; | 233 | return; |
232 | 234 | ||
@@ -257,6 +259,8 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret) | |||
257 | int syscall_nr; | 259 | int syscall_nr; |
258 | 260 | ||
259 | syscall_nr = syscall_get_nr(current, regs); | 261 | syscall_nr = syscall_get_nr(current, regs); |
262 | if (syscall_nr < 0) | ||
263 | return; | ||
260 | if (!test_bit(syscall_nr, enabled_exit_syscalls)) | 264 | if (!test_bit(syscall_nr, enabled_exit_syscalls)) |
261 | return; | 265 | return; |
262 | 266 | ||
@@ -285,7 +289,7 @@ int reg_event_syscall_enter(void *ptr) | |||
285 | 289 | ||
286 | name = (char *)ptr; | 290 | name = (char *)ptr; |
287 | num = syscall_name_to_nr(name); | 291 | num = syscall_name_to_nr(name); |
288 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 292 | if (num < 0 || num >= NR_syscalls) |
289 | return -ENOSYS; | 293 | return -ENOSYS; |
290 | mutex_lock(&syscall_trace_lock); | 294 | mutex_lock(&syscall_trace_lock); |
291 | if (!sys_refcount_enter) | 295 | if (!sys_refcount_enter) |
@@ -308,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr) | |||
308 | 312 | ||
309 | name = (char *)ptr; | 313 | name = (char *)ptr; |
310 | num = syscall_name_to_nr(name); | 314 | num = syscall_name_to_nr(name); |
311 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 315 | if (num < 0 || num >= NR_syscalls) |
312 | return; | 316 | return; |
313 | mutex_lock(&syscall_trace_lock); | 317 | mutex_lock(&syscall_trace_lock); |
314 | sys_refcount_enter--; | 318 | sys_refcount_enter--; |
@@ -326,7 +330,7 @@ int reg_event_syscall_exit(void *ptr) | |||
326 | 330 | ||
327 | name = (char *)ptr; | 331 | name = (char *)ptr; |
328 | num = syscall_name_to_nr(name); | 332 | num = syscall_name_to_nr(name); |
329 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 333 | if (num < 0 || num >= NR_syscalls) |
330 | return -ENOSYS; | 334 | return -ENOSYS; |
331 | mutex_lock(&syscall_trace_lock); | 335 | mutex_lock(&syscall_trace_lock); |
332 | if (!sys_refcount_exit) | 336 | if (!sys_refcount_exit) |
@@ -349,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr) | |||
349 | 353 | ||
350 | name = (char *)ptr; | 354 | name = (char *)ptr; |
351 | num = syscall_name_to_nr(name); | 355 | num = syscall_name_to_nr(name); |
352 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 356 | if (num < 0 || num >= NR_syscalls) |
353 | return; | 357 | return; |
354 | mutex_lock(&syscall_trace_lock); | 358 | mutex_lock(&syscall_trace_lock); |
355 | sys_refcount_exit--; | 359 | sys_refcount_exit--; |
@@ -369,8 +373,8 @@ struct trace_event event_syscall_exit = { | |||
369 | 373 | ||
370 | #ifdef CONFIG_EVENT_PROFILE | 374 | #ifdef CONFIG_EVENT_PROFILE |
371 | 375 | ||
372 | static DECLARE_BITMAP(enabled_prof_enter_syscalls, FTRACE_SYSCALL_MAX); | 376 | static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls); |
373 | static DECLARE_BITMAP(enabled_prof_exit_syscalls, FTRACE_SYSCALL_MAX); | 377 | static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls); |
374 | static int sys_prof_refcount_enter; | 378 | static int sys_prof_refcount_enter; |
375 | static int sys_prof_refcount_exit; | 379 | static int sys_prof_refcount_exit; |
376 | 380 | ||
@@ -416,7 +420,7 @@ int reg_prof_syscall_enter(char *name) | |||
416 | int num; | 420 | int num; |
417 | 421 | ||
418 | num = syscall_name_to_nr(name); | 422 | num = syscall_name_to_nr(name); |
419 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 423 | if (num < 0 || num >= NR_syscalls) |
420 | return -ENOSYS; | 424 | return -ENOSYS; |
421 | 425 | ||
422 | mutex_lock(&syscall_trace_lock); | 426 | mutex_lock(&syscall_trace_lock); |
@@ -438,7 +442,7 @@ void unreg_prof_syscall_enter(char *name) | |||
438 | int num; | 442 | int num; |
439 | 443 | ||
440 | num = syscall_name_to_nr(name); | 444 | num = syscall_name_to_nr(name); |
441 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 445 | if (num < 0 || num >= NR_syscalls) |
442 | return; | 446 | return; |
443 | 447 | ||
444 | mutex_lock(&syscall_trace_lock); | 448 | mutex_lock(&syscall_trace_lock); |
@@ -477,7 +481,7 @@ int reg_prof_syscall_exit(char *name) | |||
477 | int num; | 481 | int num; |
478 | 482 | ||
479 | num = syscall_name_to_nr(name); | 483 | num = syscall_name_to_nr(name); |
480 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 484 | if (num < 0 || num >= NR_syscalls) |
481 | return -ENOSYS; | 485 | return -ENOSYS; |
482 | 486 | ||
483 | mutex_lock(&syscall_trace_lock); | 487 | mutex_lock(&syscall_trace_lock); |
@@ -499,7 +503,7 @@ void unreg_prof_syscall_exit(char *name) | |||
499 | int num; | 503 | int num; |
500 | 504 | ||
501 | num = syscall_name_to_nr(name); | 505 | num = syscall_name_to_nr(name); |
502 | if (num < 0 || num >= FTRACE_SYSCALL_MAX) | 506 | if (num < 0 || num >= NR_syscalls) |
503 | return; | 507 | return; |
504 | 508 | ||
505 | mutex_lock(&syscall_trace_lock); | 509 | mutex_lock(&syscall_trace_lock); |
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 1a6a453b7efb..9489a0a9b1be 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c | |||
@@ -597,7 +597,9 @@ void syscall_regfunc(void) | |||
597 | if (!sys_tracepoint_refcount) { | 597 | if (!sys_tracepoint_refcount) { |
598 | read_lock_irqsave(&tasklist_lock, flags); | 598 | read_lock_irqsave(&tasklist_lock, flags); |
599 | do_each_thread(g, t) { | 599 | do_each_thread(g, t) { |
600 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | 600 | /* Skip kernel threads. */ |
601 | if (t->mm) | ||
602 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | ||
601 | } while_each_thread(g, t); | 603 | } while_each_thread(g, t); |
602 | read_unlock_irqrestore(&tasklist_lock, flags); | 604 | read_unlock_irqrestore(&tasklist_lock, flags); |
603 | } | 605 | } |