diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-03-09 11:11:53 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-03-09 11:11:53 -0500 |
commit | 548b84166917d6f5e2296123b85ad24aecd3801d (patch) | |
tree | 0ab0300e23a02df0fe3c0579627e4998bb122c00 /kernel/trace/ftrace.c | |
parent | cfb581bcd4f8c158c6f2b48bf5e232bb9e6855c0 (diff) | |
parent | 57d54889cd00db2752994b389ba714138652e60c (diff) |
Merge commit 'v2.6.34-rc1' into perf/urgent
Conflicts:
tools/perf/util/probe-event.c
Merge reason: Pick up -rc1 and resolve the conflict as well.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r-- | kernel/trace/ftrace.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 1904797f4a8a..83783579378f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -2402,6 +2402,7 @@ static const struct file_operations ftrace_notrace_fops = { | |||
2402 | static DEFINE_MUTEX(graph_lock); | 2402 | static DEFINE_MUTEX(graph_lock); |
2403 | 2403 | ||
2404 | int ftrace_graph_count; | 2404 | int ftrace_graph_count; |
2405 | int ftrace_graph_filter_enabled; | ||
2405 | unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly; | 2406 | unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly; |
2406 | 2407 | ||
2407 | static void * | 2408 | static void * |
@@ -2424,7 +2425,7 @@ static void *g_start(struct seq_file *m, loff_t *pos) | |||
2424 | mutex_lock(&graph_lock); | 2425 | mutex_lock(&graph_lock); |
2425 | 2426 | ||
2426 | /* Nothing, tell g_show to print all functions are enabled */ | 2427 | /* Nothing, tell g_show to print all functions are enabled */ |
2427 | if (!ftrace_graph_count && !*pos) | 2428 | if (!ftrace_graph_filter_enabled && !*pos) |
2428 | return (void *)1; | 2429 | return (void *)1; |
2429 | 2430 | ||
2430 | return __g_next(m, pos); | 2431 | return __g_next(m, pos); |
@@ -2470,6 +2471,7 @@ ftrace_graph_open(struct inode *inode, struct file *file) | |||
2470 | mutex_lock(&graph_lock); | 2471 | mutex_lock(&graph_lock); |
2471 | if ((file->f_mode & FMODE_WRITE) && | 2472 | if ((file->f_mode & FMODE_WRITE) && |
2472 | (file->f_flags & O_TRUNC)) { | 2473 | (file->f_flags & O_TRUNC)) { |
2474 | ftrace_graph_filter_enabled = 0; | ||
2473 | ftrace_graph_count = 0; | 2475 | ftrace_graph_count = 0; |
2474 | memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); | 2476 | memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); |
2475 | } | 2477 | } |
@@ -2495,7 +2497,7 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) | |||
2495 | struct dyn_ftrace *rec; | 2497 | struct dyn_ftrace *rec; |
2496 | struct ftrace_page *pg; | 2498 | struct ftrace_page *pg; |
2497 | int search_len; | 2499 | int search_len; |
2498 | int found = 0; | 2500 | int fail = 1; |
2499 | int type, not; | 2501 | int type, not; |
2500 | char *search; | 2502 | char *search; |
2501 | bool exists; | 2503 | bool exists; |
@@ -2506,37 +2508,51 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) | |||
2506 | 2508 | ||
2507 | /* decode regex */ | 2509 | /* decode regex */ |
2508 | type = filter_parse_regex(buffer, strlen(buffer), &search, ¬); | 2510 | type = filter_parse_regex(buffer, strlen(buffer), &search, ¬); |
2509 | if (not) | 2511 | if (!not && *idx >= FTRACE_GRAPH_MAX_FUNCS) |
2510 | return -EINVAL; | 2512 | return -EBUSY; |
2511 | 2513 | ||
2512 | search_len = strlen(search); | 2514 | search_len = strlen(search); |
2513 | 2515 | ||
2514 | mutex_lock(&ftrace_lock); | 2516 | mutex_lock(&ftrace_lock); |
2515 | do_for_each_ftrace_rec(pg, rec) { | 2517 | do_for_each_ftrace_rec(pg, rec) { |
2516 | 2518 | ||
2517 | if (*idx >= FTRACE_GRAPH_MAX_FUNCS) | ||
2518 | break; | ||
2519 | |||
2520 | if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE)) | 2519 | if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE)) |
2521 | continue; | 2520 | continue; |
2522 | 2521 | ||
2523 | if (ftrace_match_record(rec, search, search_len, type)) { | 2522 | if (ftrace_match_record(rec, search, search_len, type)) { |
2524 | /* ensure it is not already in the array */ | 2523 | /* if it is in the array */ |
2525 | exists = false; | 2524 | exists = false; |
2526 | for (i = 0; i < *idx; i++) | 2525 | for (i = 0; i < *idx; i++) { |
2527 | if (array[i] == rec->ip) { | 2526 | if (array[i] == rec->ip) { |
2528 | exists = true; | 2527 | exists = true; |
2529 | break; | 2528 | break; |
2530 | } | 2529 | } |
2531 | if (!exists) | 2530 | } |
2532 | array[(*idx)++] = rec->ip; | 2531 | |
2533 | found = 1; | 2532 | if (!not) { |
2533 | fail = 0; | ||
2534 | if (!exists) { | ||
2535 | array[(*idx)++] = rec->ip; | ||
2536 | if (*idx >= FTRACE_GRAPH_MAX_FUNCS) | ||
2537 | goto out; | ||
2538 | } | ||
2539 | } else { | ||
2540 | if (exists) { | ||
2541 | array[i] = array[--(*idx)]; | ||
2542 | array[*idx] = 0; | ||
2543 | fail = 0; | ||
2544 | } | ||
2545 | } | ||
2534 | } | 2546 | } |
2535 | } while_for_each_ftrace_rec(); | 2547 | } while_for_each_ftrace_rec(); |
2536 | 2548 | out: | |
2537 | mutex_unlock(&ftrace_lock); | 2549 | mutex_unlock(&ftrace_lock); |
2538 | 2550 | ||
2539 | return found ? 0 : -EINVAL; | 2551 | if (fail) |
2552 | return -EINVAL; | ||
2553 | |||
2554 | ftrace_graph_filter_enabled = 1; | ||
2555 | return 0; | ||
2540 | } | 2556 | } |
2541 | 2557 | ||
2542 | static ssize_t | 2558 | static ssize_t |
@@ -2546,16 +2562,11 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, | |||
2546 | struct trace_parser parser; | 2562 | struct trace_parser parser; |
2547 | ssize_t read, ret; | 2563 | ssize_t read, ret; |
2548 | 2564 | ||
2549 | if (!cnt || cnt < 0) | 2565 | if (!cnt) |
2550 | return 0; | 2566 | return 0; |
2551 | 2567 | ||
2552 | mutex_lock(&graph_lock); | 2568 | mutex_lock(&graph_lock); |
2553 | 2569 | ||
2554 | if (ftrace_graph_count >= FTRACE_GRAPH_MAX_FUNCS) { | ||
2555 | ret = -EBUSY; | ||
2556 | goto out_unlock; | ||
2557 | } | ||
2558 | |||
2559 | if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) { | 2570 | if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) { |
2560 | ret = -ENOMEM; | 2571 | ret = -ENOMEM; |
2561 | goto out_unlock; | 2572 | goto out_unlock; |