diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-12-18 15:54:49 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-12-18 15:54:49 -0500 |
| commit | d110ec3a1e1f522e2e9dfceb9c36d6590c26d2d4 (patch) | |
| tree | 86b2f8f1d22b74b05239525c55bd42e3db6afc03 /kernel/trace | |
| parent | 343e9099c8152daff20e10d6269edec21da44fc0 (diff) | |
| parent | 55dac3a5553b13891f0ae4bbd11920619b5436d4 (diff) | |
Merge branch 'linus' into core/rcu
Diffstat (limited to 'kernel/trace')
| -rw-r--r-- | kernel/trace/Kconfig | 2 | ||||
| -rw-r--r-- | kernel/trace/ftrace.c | 147 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 176 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 61 | ||||
| -rw-r--r-- | kernel/trace/trace_mmiotrace.c | 16 | ||||
| -rw-r--r-- | kernel/trace/trace_stack.c | 24 |
6 files changed, 308 insertions, 118 deletions
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index b58f43bec36..33dbefd471e 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -25,7 +25,7 @@ config TRACING | |||
| 25 | bool | 25 | bool |
| 26 | select DEBUG_FS | 26 | select DEBUG_FS |
| 27 | select RING_BUFFER | 27 | select RING_BUFFER |
| 28 | select STACKTRACE | 28 | select STACKTRACE if STACKTRACE_SUPPORT |
| 29 | select TRACEPOINTS | 29 | select TRACEPOINTS |
| 30 | select NOP_TRACER | 30 | select NOP_TRACER |
| 31 | 31 | ||
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4a39d24568c..78db083390f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -185,7 +185,6 @@ enum { | |||
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | static int ftrace_filtered; | 187 | static int ftrace_filtered; |
| 188 | static int tracing_on; | ||
| 189 | 188 | ||
| 190 | static LIST_HEAD(ftrace_new_addrs); | 189 | static LIST_HEAD(ftrace_new_addrs); |
| 191 | 190 | ||
| @@ -327,96 +326,89 @@ ftrace_record_ip(unsigned long ip) | |||
| 327 | 326 | ||
| 328 | static int | 327 | static int |
| 329 | __ftrace_replace_code(struct dyn_ftrace *rec, | 328 | __ftrace_replace_code(struct dyn_ftrace *rec, |
| 330 | unsigned char *old, unsigned char *new, int enable) | 329 | unsigned char *nop, int enable) |
| 331 | { | 330 | { |
| 332 | unsigned long ip, fl; | 331 | unsigned long ip, fl; |
| 332 | unsigned char *call, *old, *new; | ||
| 333 | 333 | ||
| 334 | ip = rec->ip; | 334 | ip = rec->ip; |
| 335 | 335 | ||
| 336 | if (ftrace_filtered && enable) { | 336 | /* |
| 337 | * If this record is not to be traced and | ||
| 338 | * it is not enabled then do nothing. | ||
| 339 | * | ||
| 340 | * If this record is not to be traced and | ||
| 341 | * it is enabled then disabled it. | ||
| 342 | * | ||
| 343 | */ | ||
| 344 | if (rec->flags & FTRACE_FL_NOTRACE) { | ||
| 345 | if (rec->flags & FTRACE_FL_ENABLED) | ||
| 346 | rec->flags &= ~FTRACE_FL_ENABLED; | ||
| 347 | else | ||
| 348 | return 0; | ||
| 349 | |||
| 350 | } else if (ftrace_filtered && enable) { | ||
| 337 | /* | 351 | /* |
| 338 | * If filtering is on: | 352 | * Filtering is on: |
| 339 | * | ||
| 340 | * If this record is set to be filtered and | ||
| 341 | * is enabled then do nothing. | ||
| 342 | * | ||
| 343 | * If this record is set to be filtered and | ||
| 344 | * it is not enabled, enable it. | ||
| 345 | * | ||
| 346 | * If this record is not set to be filtered | ||
| 347 | * and it is not enabled do nothing. | ||
| 348 | * | ||
| 349 | * If this record is set not to trace then | ||
| 350 | * do nothing. | ||
| 351 | * | ||
| 352 | * If this record is set not to trace and | ||
| 353 | * it is enabled then disable it. | ||
| 354 | * | ||
| 355 | * If this record is not set to be filtered and | ||
| 356 | * it is enabled, disable it. | ||
| 357 | */ | 353 | */ |
| 358 | 354 | ||
| 359 | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE | | 355 | fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED); |
| 360 | FTRACE_FL_ENABLED); | ||
| 361 | 356 | ||
| 362 | if ((fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) || | 357 | /* Record is filtered and enabled, do nothing */ |
| 363 | (fl == (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) || | 358 | if (fl == (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) |
| 364 | !fl || (fl == FTRACE_FL_NOTRACE)) | ||
| 365 | return 0; | 359 | return 0; |
| 366 | 360 | ||
| 367 | /* | 361 | /* Record is not filtered and is not enabled do nothing */ |
| 368 | * If it is enabled disable it, | 362 | if (!fl) |
| 369 | * otherwise enable it! | 363 | return 0; |
| 370 | */ | 364 | |
| 371 | if (fl & FTRACE_FL_ENABLED) { | 365 | /* Record is not filtered but enabled, disable it */ |
| 372 | /* swap new and old */ | 366 | if (fl == FTRACE_FL_ENABLED) |
| 373 | new = old; | ||
| 374 | old = ftrace_call_replace(ip, FTRACE_ADDR); | ||
| 375 | rec->flags &= ~FTRACE_FL_ENABLED; | 367 | rec->flags &= ~FTRACE_FL_ENABLED; |
| 376 | } else { | 368 | else |
| 377 | new = ftrace_call_replace(ip, FTRACE_ADDR); | 369 | /* Otherwise record is filtered but not enabled, enable it */ |
| 378 | rec->flags |= FTRACE_FL_ENABLED; | 370 | rec->flags |= FTRACE_FL_ENABLED; |
| 379 | } | ||
| 380 | } else { | 371 | } else { |
| 372 | /* Disable or not filtered */ | ||
| 381 | 373 | ||
| 382 | if (enable) { | 374 | if (enable) { |
| 383 | /* | 375 | /* if record is enabled, do nothing */ |
| 384 | * If this record is set not to trace and is | ||
| 385 | * not enabled, do nothing. | ||
| 386 | */ | ||
| 387 | fl = rec->flags & (FTRACE_FL_NOTRACE | FTRACE_FL_ENABLED); | ||
| 388 | if (fl == FTRACE_FL_NOTRACE) | ||
| 389 | return 0; | ||
| 390 | |||
| 391 | new = ftrace_call_replace(ip, FTRACE_ADDR); | ||
| 392 | } else | ||
| 393 | old = ftrace_call_replace(ip, FTRACE_ADDR); | ||
| 394 | |||
| 395 | if (enable) { | ||
| 396 | if (rec->flags & FTRACE_FL_ENABLED) | 376 | if (rec->flags & FTRACE_FL_ENABLED) |
| 397 | return 0; | 377 | return 0; |
| 378 | |||
| 398 | rec->flags |= FTRACE_FL_ENABLED; | 379 | rec->flags |= FTRACE_FL_ENABLED; |
| 380 | |||
| 399 | } else { | 381 | } else { |
| 382 | |||
| 383 | /* if record is not enabled do nothing */ | ||
| 400 | if (!(rec->flags & FTRACE_FL_ENABLED)) | 384 | if (!(rec->flags & FTRACE_FL_ENABLED)) |
| 401 | return 0; | 385 | return 0; |
| 386 | |||
| 402 | rec->flags &= ~FTRACE_FL_ENABLED; | 387 | rec->flags &= ~FTRACE_FL_ENABLED; |
| 403 | } | 388 | } |
| 404 | } | 389 | } |
| 405 | 390 | ||
| 391 | call = ftrace_call_replace(ip, FTRACE_ADDR); | ||
| 392 | |||
| 393 | if (rec->flags & FTRACE_FL_ENABLED) { | ||
| 394 | old = nop; | ||
| 395 | new = call; | ||
| 396 | } else { | ||
| 397 | old = call; | ||
| 398 | new = nop; | ||
| 399 | } | ||
| 400 | |||
| 406 | return ftrace_modify_code(ip, old, new); | 401 | return ftrace_modify_code(ip, old, new); |
| 407 | } | 402 | } |
| 408 | 403 | ||
| 409 | static void ftrace_replace_code(int enable) | 404 | static void ftrace_replace_code(int enable) |
| 410 | { | 405 | { |
| 411 | int i, failed; | 406 | int i, failed; |
| 412 | unsigned char *new = NULL, *old = NULL; | 407 | unsigned char *nop = NULL; |
| 413 | struct dyn_ftrace *rec; | 408 | struct dyn_ftrace *rec; |
| 414 | struct ftrace_page *pg; | 409 | struct ftrace_page *pg; |
| 415 | 410 | ||
| 416 | if (enable) | 411 | nop = ftrace_nop_replace(); |
| 417 | old = ftrace_nop_replace(); | ||
| 418 | else | ||
| 419 | new = ftrace_nop_replace(); | ||
| 420 | 412 | ||
| 421 | for (pg = ftrace_pages_start; pg; pg = pg->next) { | 413 | for (pg = ftrace_pages_start; pg; pg = pg->next) { |
| 422 | for (i = 0; i < pg->index; i++) { | 414 | for (i = 0; i < pg->index; i++) { |
| @@ -434,7 +426,7 @@ static void ftrace_replace_code(int enable) | |||
| 434 | unfreeze_record(rec); | 426 | unfreeze_record(rec); |
| 435 | } | 427 | } |
| 436 | 428 | ||
| 437 | failed = __ftrace_replace_code(rec, old, new, enable); | 429 | failed = __ftrace_replace_code(rec, nop, enable); |
| 438 | if (failed && (rec->flags & FTRACE_FL_CONVERTED)) { | 430 | if (failed && (rec->flags & FTRACE_FL_CONVERTED)) { |
| 439 | rec->flags |= FTRACE_FL_FAILED; | 431 | rec->flags |= FTRACE_FL_FAILED; |
| 440 | if ((system_state == SYSTEM_BOOTING) || | 432 | if ((system_state == SYSTEM_BOOTING) || |
| @@ -506,13 +498,10 @@ static int __ftrace_modify_code(void *data) | |||
| 506 | { | 498 | { |
| 507 | int *command = data; | 499 | int *command = data; |
| 508 | 500 | ||
| 509 | if (*command & FTRACE_ENABLE_CALLS) { | 501 | if (*command & FTRACE_ENABLE_CALLS) |
| 510 | ftrace_replace_code(1); | 502 | ftrace_replace_code(1); |
| 511 | tracing_on = 1; | 503 | else if (*command & FTRACE_DISABLE_CALLS) |
| 512 | } else if (*command & FTRACE_DISABLE_CALLS) { | ||
| 513 | ftrace_replace_code(0); | 504 | ftrace_replace_code(0); |
| 514 | tracing_on = 0; | ||
| 515 | } | ||
| 516 | 505 | ||
| 517 | if (*command & FTRACE_UPDATE_TRACE_FUNC) | 506 | if (*command & FTRACE_UPDATE_TRACE_FUNC) |
| 518 | ftrace_update_ftrace_func(ftrace_trace_function); | 507 | ftrace_update_ftrace_func(ftrace_trace_function); |
| @@ -538,8 +527,7 @@ static void ftrace_startup(void) | |||
| 538 | 527 | ||
| 539 | mutex_lock(&ftrace_start_lock); | 528 | mutex_lock(&ftrace_start_lock); |
| 540 | ftrace_start++; | 529 | ftrace_start++; |
| 541 | if (ftrace_start == 1) | 530 | command |= FTRACE_ENABLE_CALLS; |
| 542 | command |= FTRACE_ENABLE_CALLS; | ||
| 543 | 531 | ||
| 544 | if (saved_ftrace_func != ftrace_trace_function) { | 532 | if (saved_ftrace_func != ftrace_trace_function) { |
| 545 | saved_ftrace_func = ftrace_trace_function; | 533 | saved_ftrace_func = ftrace_trace_function; |
| @@ -677,7 +665,7 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init) | |||
| 677 | 665 | ||
| 678 | cnt = num_to_init / ENTRIES_PER_PAGE; | 666 | cnt = num_to_init / ENTRIES_PER_PAGE; |
| 679 | pr_info("ftrace: allocating %ld entries in %d pages\n", | 667 | pr_info("ftrace: allocating %ld entries in %d pages\n", |
| 680 | num_to_init, cnt); | 668 | num_to_init, cnt + 1); |
| 681 | 669 | ||
| 682 | for (i = 0; i < cnt; i++) { | 670 | for (i = 0; i < cnt; i++) { |
| 683 | pg->next = (void *)get_zeroed_page(GFP_KERNEL); | 671 | pg->next = (void *)get_zeroed_page(GFP_KERNEL); |
| @@ -738,6 +726,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 738 | ((iter->flags & FTRACE_ITER_FAILURES) && | 726 | ((iter->flags & FTRACE_ITER_FAILURES) && |
| 739 | !(rec->flags & FTRACE_FL_FAILED)) || | 727 | !(rec->flags & FTRACE_FL_FAILED)) || |
| 740 | 728 | ||
| 729 | ((iter->flags & FTRACE_ITER_FILTER) && | ||
| 730 | !(rec->flags & FTRACE_FL_FILTER)) || | ||
| 731 | |||
| 741 | ((iter->flags & FTRACE_ITER_NOTRACE) && | 732 | ((iter->flags & FTRACE_ITER_NOTRACE) && |
| 742 | !(rec->flags & FTRACE_FL_NOTRACE))) { | 733 | !(rec->flags & FTRACE_FL_NOTRACE))) { |
| 743 | rec = NULL; | 734 | rec = NULL; |
| @@ -757,13 +748,11 @@ static void *t_start(struct seq_file *m, loff_t *pos) | |||
| 757 | void *p = NULL; | 748 | void *p = NULL; |
| 758 | loff_t l = -1; | 749 | loff_t l = -1; |
| 759 | 750 | ||
| 760 | if (*pos != iter->pos) { | 751 | if (*pos > iter->pos) |
| 761 | for (p = t_next(m, p, &l); p && l < *pos; p = t_next(m, p, &l)) | 752 | *pos = iter->pos; |
| 762 | ; | 753 | |
| 763 | } else { | 754 | l = *pos; |
| 764 | l = *pos; | 755 | p = t_next(m, p, &l); |
| 765 | p = t_next(m, p, &l); | ||
| 766 | } | ||
| 767 | 756 | ||
| 768 | return p; | 757 | return p; |
| 769 | } | 758 | } |
| @@ -774,15 +763,21 @@ static void t_stop(struct seq_file *m, void *p) | |||
| 774 | 763 | ||
| 775 | static int t_show(struct seq_file *m, void *v) | 764 | static int t_show(struct seq_file *m, void *v) |
| 776 | { | 765 | { |
| 766 | struct ftrace_iterator *iter = m->private; | ||
| 777 | struct dyn_ftrace *rec = v; | 767 | struct dyn_ftrace *rec = v; |
| 778 | char str[KSYM_SYMBOL_LEN]; | 768 | char str[KSYM_SYMBOL_LEN]; |
| 769 | int ret = 0; | ||
| 779 | 770 | ||
| 780 | if (!rec) | 771 | if (!rec) |
| 781 | return 0; | 772 | return 0; |
| 782 | 773 | ||
| 783 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); | 774 | kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); |
| 784 | 775 | ||
| 785 | seq_printf(m, "%s\n", str); | 776 | ret = seq_printf(m, "%s\n", str); |
| 777 | if (ret < 0) { | ||
| 778 | iter->pos--; | ||
| 779 | iter->idx--; | ||
| 780 | } | ||
| 786 | 781 | ||
| 787 | return 0; | 782 | return 0; |
| 788 | } | 783 | } |
| @@ -808,7 +803,7 @@ ftrace_avail_open(struct inode *inode, struct file *file) | |||
| 808 | return -ENOMEM; | 803 | return -ENOMEM; |
| 809 | 804 | ||
| 810 | iter->pg = ftrace_pages_start; | 805 | iter->pg = ftrace_pages_start; |
| 811 | iter->pos = -1; | 806 | iter->pos = 0; |
| 812 | 807 | ||
| 813 | ret = seq_open(file, &show_ftrace_seq_ops); | 808 | ret = seq_open(file, &show_ftrace_seq_ops); |
| 814 | if (!ret) { | 809 | if (!ret) { |
| @@ -895,7 +890,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable) | |||
| 895 | 890 | ||
| 896 | if (file->f_mode & FMODE_READ) { | 891 | if (file->f_mode & FMODE_READ) { |
| 897 | iter->pg = ftrace_pages_start; | 892 | iter->pg = ftrace_pages_start; |
| 898 | iter->pos = -1; | 893 | iter->pos = 0; |
| 899 | iter->flags = enable ? FTRACE_ITER_FILTER : | 894 | iter->flags = enable ? FTRACE_ITER_FILTER : |
| 900 | FTRACE_ITER_NOTRACE; | 895 | FTRACE_ITER_NOTRACE; |
| 901 | 896 | ||
| @@ -1186,7 +1181,7 @@ ftrace_regex_release(struct inode *inode, struct file *file, int enable) | |||
| 1186 | 1181 | ||
| 1187 | mutex_lock(&ftrace_sysctl_lock); | 1182 | mutex_lock(&ftrace_sysctl_lock); |
| 1188 | mutex_lock(&ftrace_start_lock); | 1183 | mutex_lock(&ftrace_start_lock); |
| 1189 | if (iter->filtered && ftrace_start && ftrace_enabled) | 1184 | if (ftrace_start && ftrace_enabled) |
| 1190 | ftrace_run_update_code(FTRACE_ENABLE_CALLS); | 1185 | ftrace_run_update_code(FTRACE_ENABLE_CALLS); |
| 1191 | mutex_unlock(&ftrace_start_lock); | 1186 | mutex_unlock(&ftrace_start_lock); |
| 1192 | mutex_unlock(&ftrace_sysctl_lock); | 1187 | mutex_unlock(&ftrace_sysctl_lock); |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index cedf4e26828..668bbb5ef2b 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -16,14 +16,49 @@ | |||
| 16 | #include <linux/list.h> | 16 | #include <linux/list.h> |
| 17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
| 18 | 18 | ||
| 19 | #include "trace.h" | ||
| 20 | |||
| 21 | /* Global flag to disable all recording to ring buffers */ | ||
| 22 | static int ring_buffers_off __read_mostly; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * tracing_on - enable all tracing buffers | ||
| 26 | * | ||
| 27 | * This function enables all tracing buffers that may have been | ||
| 28 | * disabled with tracing_off. | ||
| 29 | */ | ||
| 30 | void tracing_on(void) | ||
| 31 | { | ||
| 32 | ring_buffers_off = 0; | ||
| 33 | } | ||
| 34 | |||
| 35 | /** | ||
| 36 | * tracing_off - turn off all tracing buffers | ||
| 37 | * | ||
| 38 | * This function stops all tracing buffers from recording data. | ||
| 39 | * It does not disable any overhead the tracers themselves may | ||
| 40 | * be causing. This function simply causes all recording to | ||
| 41 | * the ring buffers to fail. | ||
| 42 | */ | ||
| 43 | void tracing_off(void) | ||
| 44 | { | ||
| 45 | ring_buffers_off = 1; | ||
| 46 | } | ||
| 47 | |||
| 19 | /* Up this if you want to test the TIME_EXTENTS and normalization */ | 48 | /* Up this if you want to test the TIME_EXTENTS and normalization */ |
| 20 | #define DEBUG_SHIFT 0 | 49 | #define DEBUG_SHIFT 0 |
| 21 | 50 | ||
| 22 | /* FIXME!!! */ | 51 | /* FIXME!!! */ |
| 23 | u64 ring_buffer_time_stamp(int cpu) | 52 | u64 ring_buffer_time_stamp(int cpu) |
| 24 | { | 53 | { |
| 54 | u64 time; | ||
| 55 | |||
| 56 | preempt_disable_notrace(); | ||
| 25 | /* shift to debug/test normalization and TIME_EXTENTS */ | 57 | /* shift to debug/test normalization and TIME_EXTENTS */ |
| 26 | return sched_clock() << DEBUG_SHIFT; | 58 | time = sched_clock() << DEBUG_SHIFT; |
| 59 | preempt_enable_notrace(); | ||
| 60 | |||
| 61 | return time; | ||
| 27 | } | 62 | } |
| 28 | 63 | ||
| 29 | void ring_buffer_normalize_time_stamp(int cpu, u64 *ts) | 64 | void ring_buffer_normalize_time_stamp(int cpu, u64 *ts) |
| @@ -503,6 +538,12 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 503 | LIST_HEAD(pages); | 538 | LIST_HEAD(pages); |
| 504 | int i, cpu; | 539 | int i, cpu; |
| 505 | 540 | ||
| 541 | /* | ||
| 542 | * Always succeed at resizing a non-existent buffer: | ||
| 543 | */ | ||
| 544 | if (!buffer) | ||
| 545 | return size; | ||
| 546 | |||
| 506 | size = DIV_ROUND_UP(size, BUF_PAGE_SIZE); | 547 | size = DIV_ROUND_UP(size, BUF_PAGE_SIZE); |
| 507 | size *= BUF_PAGE_SIZE; | 548 | size *= BUF_PAGE_SIZE; |
| 508 | buffer_size = buffer->pages * BUF_PAGE_SIZE; | 549 | buffer_size = buffer->pages * BUF_PAGE_SIZE; |
| @@ -576,6 +617,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 576 | list_del_init(&page->list); | 617 | list_del_init(&page->list); |
| 577 | free_buffer_page(page); | 618 | free_buffer_page(page); |
| 578 | } | 619 | } |
| 620 | mutex_unlock(&buffer->mutex); | ||
| 579 | return -ENOMEM; | 621 | return -ENOMEM; |
| 580 | } | 622 | } |
| 581 | 623 | ||
| @@ -1022,8 +1064,23 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1022 | struct ring_buffer_event *event; | 1064 | struct ring_buffer_event *event; |
| 1023 | u64 ts, delta; | 1065 | u64 ts, delta; |
| 1024 | int commit = 0; | 1066 | int commit = 0; |
| 1067 | int nr_loops = 0; | ||
| 1025 | 1068 | ||
| 1026 | again: | 1069 | again: |
| 1070 | /* | ||
| 1071 | * We allow for interrupts to reenter here and do a trace. | ||
| 1072 | * If one does, it will cause this original code to loop | ||
| 1073 | * back here. Even with heavy interrupts happening, this | ||
| 1074 | * should only happen a few times in a row. If this happens | ||
| 1075 | * 1000 times in a row, there must be either an interrupt | ||
| 1076 | * storm or we have something buggy. | ||
| 1077 | * Bail! | ||
| 1078 | */ | ||
| 1079 | if (unlikely(++nr_loops > 1000)) { | ||
| 1080 | RB_WARN_ON(cpu_buffer, 1); | ||
| 1081 | return NULL; | ||
| 1082 | } | ||
| 1083 | |||
| 1027 | ts = ring_buffer_time_stamp(cpu_buffer->cpu); | 1084 | ts = ring_buffer_time_stamp(cpu_buffer->cpu); |
| 1028 | 1085 | ||
| 1029 | /* | 1086 | /* |
| @@ -1045,7 +1102,7 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1045 | 1102 | ||
| 1046 | /* Did the write stamp get updated already? */ | 1103 | /* Did the write stamp get updated already? */ |
| 1047 | if (unlikely(ts < cpu_buffer->write_stamp)) | 1104 | if (unlikely(ts < cpu_buffer->write_stamp)) |
| 1048 | goto again; | 1105 | delta = 0; |
| 1049 | 1106 | ||
| 1050 | if (test_time_stamp(delta)) { | 1107 | if (test_time_stamp(delta)) { |
| 1051 | 1108 | ||
| @@ -1118,6 +1175,9 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, | |||
| 1118 | struct ring_buffer_event *event; | 1175 | struct ring_buffer_event *event; |
| 1119 | int cpu, resched; | 1176 | int cpu, resched; |
| 1120 | 1177 | ||
| 1178 | if (ring_buffers_off) | ||
| 1179 | return NULL; | ||
| 1180 | |||
| 1121 | if (atomic_read(&buffer->record_disabled)) | 1181 | if (atomic_read(&buffer->record_disabled)) |
| 1122 | return NULL; | 1182 | return NULL; |
| 1123 | 1183 | ||
| @@ -1155,7 +1215,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer, | |||
| 1155 | 1215 | ||
| 1156 | out: | 1216 | out: |
| 1157 | if (resched) | 1217 | if (resched) |
| 1158 | preempt_enable_notrace(); | 1218 | preempt_enable_no_resched_notrace(); |
| 1159 | else | 1219 | else |
| 1160 | preempt_enable_notrace(); | 1220 | preempt_enable_notrace(); |
| 1161 | return NULL; | 1221 | return NULL; |
| @@ -1234,6 +1294,9 @@ int ring_buffer_write(struct ring_buffer *buffer, | |||
| 1234 | int ret = -EBUSY; | 1294 | int ret = -EBUSY; |
| 1235 | int cpu, resched; | 1295 | int cpu, resched; |
| 1236 | 1296 | ||
| 1297 | if (ring_buffers_off) | ||
| 1298 | return -EBUSY; | ||
| 1299 | |||
| 1237 | if (atomic_read(&buffer->record_disabled)) | 1300 | if (atomic_read(&buffer->record_disabled)) |
| 1238 | return -EBUSY; | 1301 | return -EBUSY; |
| 1239 | 1302 | ||
| @@ -1532,10 +1595,23 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) | |||
| 1532 | { | 1595 | { |
| 1533 | struct buffer_page *reader = NULL; | 1596 | struct buffer_page *reader = NULL; |
| 1534 | unsigned long flags; | 1597 | unsigned long flags; |
| 1598 | int nr_loops = 0; | ||
| 1535 | 1599 | ||
| 1536 | spin_lock_irqsave(&cpu_buffer->lock, flags); | 1600 | spin_lock_irqsave(&cpu_buffer->lock, flags); |
| 1537 | 1601 | ||
| 1538 | again: | 1602 | again: |
| 1603 | /* | ||
| 1604 | * This should normally only loop twice. But because the | ||
| 1605 | * start of the reader inserts an empty page, it causes | ||
| 1606 | * a case where we will loop three times. There should be no | ||
| 1607 | * reason to loop four times (that I know of). | ||
| 1608 | */ | ||
| 1609 | if (unlikely(++nr_loops > 3)) { | ||
| 1610 | RB_WARN_ON(cpu_buffer, 1); | ||
| 1611 | reader = NULL; | ||
| 1612 | goto out; | ||
| 1613 | } | ||
| 1614 | |||
| 1539 | reader = cpu_buffer->reader_page; | 1615 | reader = cpu_buffer->reader_page; |
| 1540 | 1616 | ||
| 1541 | /* If there's more to read, return this page */ | 1617 | /* If there's more to read, return this page */ |
| @@ -1665,6 +1741,7 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts) | |||
| 1665 | struct ring_buffer_per_cpu *cpu_buffer; | 1741 | struct ring_buffer_per_cpu *cpu_buffer; |
| 1666 | struct ring_buffer_event *event; | 1742 | struct ring_buffer_event *event; |
| 1667 | struct buffer_page *reader; | 1743 | struct buffer_page *reader; |
| 1744 | int nr_loops = 0; | ||
| 1668 | 1745 | ||
| 1669 | if (!cpu_isset(cpu, buffer->cpumask)) | 1746 | if (!cpu_isset(cpu, buffer->cpumask)) |
| 1670 | return NULL; | 1747 | return NULL; |
| @@ -1672,6 +1749,19 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts) | |||
| 1672 | cpu_buffer = buffer->buffers[cpu]; | 1749 | cpu_buffer = buffer->buffers[cpu]; |
| 1673 | 1750 | ||
| 1674 | again: | 1751 | again: |
| 1752 | /* | ||
| 1753 | * We repeat when a timestamp is encountered. It is possible | ||
| 1754 | * to get multiple timestamps from an interrupt entering just | ||
| 1755 | * as one timestamp is about to be written. The max times | ||
| 1756 | * that this can happen is the number of nested interrupts we | ||
| 1757 | * can have. Nesting 10 deep of interrupts is clearly | ||
| 1758 | * an anomaly. | ||
| 1759 | */ | ||
| 1760 | if (unlikely(++nr_loops > 10)) { | ||
| 1761 | RB_WARN_ON(cpu_buffer, 1); | ||
| 1762 | return NULL; | ||
| 1763 | } | ||
| 1764 | |||
| 1675 | reader = rb_get_reader_page(cpu_buffer); | 1765 | reader = rb_get_reader_page(cpu_buffer); |
| 1676 | if (!reader) | 1766 | if (!reader) |
| 1677 | return NULL; | 1767 | return NULL; |
| @@ -1722,6 +1812,7 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts) | |||
| 1722 | struct ring_buffer *buffer; | 1812 | struct ring_buffer *buffer; |
| 1723 | struct ring_buffer_per_cpu *cpu_buffer; | 1813 | struct ring_buffer_per_cpu *cpu_buffer; |
| 1724 | struct ring_buffer_event *event; | 1814 | struct ring_buffer_event *event; |
| 1815 | int nr_loops = 0; | ||
| 1725 | 1816 | ||
| 1726 | if (ring_buffer_iter_empty(iter)) | 1817 | if (ring_buffer_iter_empty(iter)) |
| 1727 | return NULL; | 1818 | return NULL; |
| @@ -1730,6 +1821,19 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts) | |||
| 1730 | buffer = cpu_buffer->buffer; | 1821 | buffer = cpu_buffer->buffer; |
| 1731 | 1822 | ||
| 1732 | again: | 1823 | again: |
| 1824 | /* | ||
| 1825 | * We repeat when a timestamp is encountered. It is possible | ||
| 1826 | * to get multiple timestamps from an interrupt entering just | ||
| 1827 | * as one timestamp is about to be written. The max times | ||
| 1828 | * that this can happen is the number of nested interrupts we | ||
| 1829 | * can have. Nesting 10 deep of interrupts is clearly | ||
| 1830 | * an anomaly. | ||
| 1831 | */ | ||
| 1832 | if (unlikely(++nr_loops > 10)) { | ||
| 1833 | RB_WARN_ON(cpu_buffer, 1); | ||
| 1834 | return NULL; | ||
| 1835 | } | ||
| 1836 | |||
| 1733 | if (rb_per_cpu_empty(cpu_buffer)) | 1837 | if (rb_per_cpu_empty(cpu_buffer)) |
| 1734 | return NULL; | 1838 | return NULL; |
| 1735 | 1839 | ||
| @@ -2014,3 +2118,69 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a, | |||
| 2014 | return 0; | 2118 | return 0; |
| 2015 | } | 2119 | } |
| 2016 | 2120 | ||
| 2121 | static ssize_t | ||
| 2122 | rb_simple_read(struct file *filp, char __user *ubuf, | ||
| 2123 | size_t cnt, loff_t *ppos) | ||
| 2124 | { | ||
| 2125 | int *p = filp->private_data; | ||
| 2126 | char buf[64]; | ||
| 2127 | int r; | ||
| 2128 | |||
| 2129 | /* !ring_buffers_off == tracing_on */ | ||
| 2130 | r = sprintf(buf, "%d\n", !*p); | ||
| 2131 | |||
| 2132 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | ||
| 2133 | } | ||
| 2134 | |||
| 2135 | static ssize_t | ||
| 2136 | rb_simple_write(struct file *filp, const char __user *ubuf, | ||
| 2137 | size_t cnt, loff_t *ppos) | ||
| 2138 | { | ||
| 2139 | int *p = filp->private_data; | ||
| 2140 | char buf[64]; | ||
| 2141 | long val; | ||
| 2142 | int ret; | ||
| 2143 | |||
| 2144 | if (cnt >= sizeof(buf)) | ||
| 2145 | return -EINVAL; | ||
| 2146 | |||
| 2147 | if (copy_from_user(&buf, ubuf, cnt)) | ||
| 2148 | return -EFAULT; | ||
| 2149 | |||
| 2150 | buf[cnt] = 0; | ||
| 2151 | |||
| 2152 | ret = strict_strtoul(buf, 10, &val); | ||
| 2153 | if (ret < 0) | ||
| 2154 | return ret; | ||
| 2155 | |||
| 2156 | /* !ring_buffers_off == tracing_on */ | ||
| 2157 | *p = !val; | ||
| 2158 | |||
| 2159 | (*ppos)++; | ||
| 2160 | |||
| 2161 | return cnt; | ||
| 2162 | } | ||
| 2163 | |||
| 2164 | static struct file_operations rb_simple_fops = { | ||
| 2165 | .open = tracing_open_generic, | ||
| 2166 | .read = rb_simple_read, | ||
| 2167 | .write = rb_simple_write, | ||
| 2168 | }; | ||
| 2169 | |||
| 2170 | |||
| 2171 | static __init int rb_init_debugfs(void) | ||
| 2172 | { | ||
| 2173 | struct dentry *d_tracer; | ||
| 2174 | struct dentry *entry; | ||
| 2175 | |||
| 2176 | d_tracer = tracing_init_dentry(); | ||
| 2177 | |||
| 2178 | entry = debugfs_create_file("tracing_on", 0644, d_tracer, | ||
| 2179 | &ring_buffers_off, &rb_simple_fops); | ||
| 2180 | if (!entry) | ||
| 2181 | pr_warning("Could not create debugfs 'tracing_on' entry\n"); | ||
| 2182 | |||
| 2183 | return 0; | ||
| 2184 | } | ||
| 2185 | |||
| 2186 | fs_initcall(rb_init_debugfs); | ||
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8a499e2adae..d86e3252f30 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -705,6 +705,7 @@ static void ftrace_trace_stack(struct trace_array *tr, | |||
| 705 | unsigned long flags, | 705 | unsigned long flags, |
| 706 | int skip, int pc) | 706 | int skip, int pc) |
| 707 | { | 707 | { |
| 708 | #ifdef CONFIG_STACKTRACE | ||
| 708 | struct ring_buffer_event *event; | 709 | struct ring_buffer_event *event; |
| 709 | struct stack_entry *entry; | 710 | struct stack_entry *entry; |
| 710 | struct stack_trace trace; | 711 | struct stack_trace trace; |
| @@ -730,6 +731,7 @@ static void ftrace_trace_stack(struct trace_array *tr, | |||
| 730 | 731 | ||
| 731 | save_stack_trace(&trace); | 732 | save_stack_trace(&trace); |
| 732 | ring_buffer_unlock_commit(tr->buffer, event, irq_flags); | 733 | ring_buffer_unlock_commit(tr->buffer, event, irq_flags); |
| 734 | #endif | ||
| 733 | } | 735 | } |
| 734 | 736 | ||
| 735 | void __trace_stack(struct trace_array *tr, | 737 | void __trace_stack(struct trace_array *tr, |
| @@ -1086,17 +1088,20 @@ static void s_stop(struct seq_file *m, void *p) | |||
| 1086 | mutex_unlock(&trace_types_lock); | 1088 | mutex_unlock(&trace_types_lock); |
| 1087 | } | 1089 | } |
| 1088 | 1090 | ||
| 1089 | #define KRETPROBE_MSG "[unknown/kretprobe'd]" | ||
| 1090 | |||
| 1091 | #ifdef CONFIG_KRETPROBES | 1091 | #ifdef CONFIG_KRETPROBES |
| 1092 | static inline int kretprobed(unsigned long addr) | 1092 | static inline const char *kretprobed(const char *name) |
| 1093 | { | 1093 | { |
| 1094 | return addr == (unsigned long)kretprobe_trampoline; | 1094 | static const char tramp_name[] = "kretprobe_trampoline"; |
| 1095 | int size = sizeof(tramp_name); | ||
| 1096 | |||
| 1097 | if (strncmp(tramp_name, name, size) == 0) | ||
| 1098 | return "[unknown/kretprobe'd]"; | ||
| 1099 | return name; | ||
| 1095 | } | 1100 | } |
| 1096 | #else | 1101 | #else |
| 1097 | static inline int kretprobed(unsigned long addr) | 1102 | static inline const char *kretprobed(const char *name) |
| 1098 | { | 1103 | { |
| 1099 | return 0; | 1104 | return name; |
| 1100 | } | 1105 | } |
| 1101 | #endif /* CONFIG_KRETPROBES */ | 1106 | #endif /* CONFIG_KRETPROBES */ |
| 1102 | 1107 | ||
| @@ -1105,10 +1110,13 @@ seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) | |||
| 1105 | { | 1110 | { |
| 1106 | #ifdef CONFIG_KALLSYMS | 1111 | #ifdef CONFIG_KALLSYMS |
| 1107 | char str[KSYM_SYMBOL_LEN]; | 1112 | char str[KSYM_SYMBOL_LEN]; |
| 1113 | const char *name; | ||
| 1108 | 1114 | ||
| 1109 | kallsyms_lookup(address, NULL, NULL, NULL, str); | 1115 | kallsyms_lookup(address, NULL, NULL, NULL, str); |
| 1110 | 1116 | ||
| 1111 | return trace_seq_printf(s, fmt, str); | 1117 | name = kretprobed(str); |
| 1118 | |||
| 1119 | return trace_seq_printf(s, fmt, name); | ||
| 1112 | #endif | 1120 | #endif |
| 1113 | return 1; | 1121 | return 1; |
| 1114 | } | 1122 | } |
| @@ -1119,9 +1127,12 @@ seq_print_sym_offset(struct trace_seq *s, const char *fmt, | |||
| 1119 | { | 1127 | { |
| 1120 | #ifdef CONFIG_KALLSYMS | 1128 | #ifdef CONFIG_KALLSYMS |
| 1121 | char str[KSYM_SYMBOL_LEN]; | 1129 | char str[KSYM_SYMBOL_LEN]; |
| 1130 | const char *name; | ||
| 1122 | 1131 | ||
| 1123 | sprint_symbol(str, address); | 1132 | sprint_symbol(str, address); |
| 1124 | return trace_seq_printf(s, fmt, str); | 1133 | name = kretprobed(str); |
| 1134 | |||
| 1135 | return trace_seq_printf(s, fmt, name); | ||
| 1125 | #endif | 1136 | #endif |
| 1126 | return 1; | 1137 | return 1; |
| 1127 | } | 1138 | } |
| @@ -1375,10 +1386,7 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu) | |||
| 1375 | 1386 | ||
| 1376 | seq_print_ip_sym(s, field->ip, sym_flags); | 1387 | seq_print_ip_sym(s, field->ip, sym_flags); |
| 1377 | trace_seq_puts(s, " ("); | 1388 | trace_seq_puts(s, " ("); |
| 1378 | if (kretprobed(field->parent_ip)) | 1389 | seq_print_ip_sym(s, field->parent_ip, sym_flags); |
| 1379 | trace_seq_puts(s, KRETPROBE_MSG); | ||
| 1380 | else | ||
| 1381 | seq_print_ip_sym(s, field->parent_ip, sym_flags); | ||
| 1382 | trace_seq_puts(s, ")\n"); | 1390 | trace_seq_puts(s, ")\n"); |
| 1383 | break; | 1391 | break; |
| 1384 | } | 1392 | } |
| @@ -1494,12 +1502,9 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) | |||
| 1494 | ret = trace_seq_printf(s, " <-"); | 1502 | ret = trace_seq_printf(s, " <-"); |
| 1495 | if (!ret) | 1503 | if (!ret) |
| 1496 | return TRACE_TYPE_PARTIAL_LINE; | 1504 | return TRACE_TYPE_PARTIAL_LINE; |
| 1497 | if (kretprobed(field->parent_ip)) | 1505 | ret = seq_print_ip_sym(s, |
| 1498 | ret = trace_seq_puts(s, KRETPROBE_MSG); | 1506 | field->parent_ip, |
| 1499 | else | 1507 | sym_flags); |
| 1500 | ret = seq_print_ip_sym(s, | ||
| 1501 | field->parent_ip, | ||
| 1502 | sym_flags); | ||
| 1503 | if (!ret) | 1508 | if (!ret) |
| 1504 | return TRACE_TYPE_PARTIAL_LINE; | 1509 | return TRACE_TYPE_PARTIAL_LINE; |
| 1505 | } | 1510 | } |
| @@ -1750,7 +1755,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter) | |||
| 1750 | return TRACE_TYPE_HANDLED; | 1755 | return TRACE_TYPE_HANDLED; |
| 1751 | 1756 | ||
| 1752 | SEQ_PUT_FIELD_RET(s, entry->pid); | 1757 | SEQ_PUT_FIELD_RET(s, entry->pid); |
| 1753 | SEQ_PUT_FIELD_RET(s, iter->cpu); | 1758 | SEQ_PUT_FIELD_RET(s, entry->cpu); |
| 1754 | SEQ_PUT_FIELD_RET(s, iter->ts); | 1759 | SEQ_PUT_FIELD_RET(s, iter->ts); |
| 1755 | 1760 | ||
| 1756 | switch (entry->type) { | 1761 | switch (entry->type) { |
| @@ -1931,6 +1936,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
| 1931 | ring_buffer_read_finish(iter->buffer_iter[cpu]); | 1936 | ring_buffer_read_finish(iter->buffer_iter[cpu]); |
| 1932 | } | 1937 | } |
| 1933 | mutex_unlock(&trace_types_lock); | 1938 | mutex_unlock(&trace_types_lock); |
| 1939 | kfree(iter); | ||
| 1934 | 1940 | ||
| 1935 | return ERR_PTR(-ENOMEM); | 1941 | return ERR_PTR(-ENOMEM); |
| 1936 | } | 1942 | } |
| @@ -2671,7 +2677,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 2671 | { | 2677 | { |
| 2672 | unsigned long val; | 2678 | unsigned long val; |
| 2673 | char buf[64]; | 2679 | char buf[64]; |
| 2674 | int ret; | 2680 | int ret, cpu; |
| 2675 | struct trace_array *tr = filp->private_data; | 2681 | struct trace_array *tr = filp->private_data; |
| 2676 | 2682 | ||
| 2677 | if (cnt >= sizeof(buf)) | 2683 | if (cnt >= sizeof(buf)) |
| @@ -2699,6 +2705,14 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 2699 | goto out; | 2705 | goto out; |
| 2700 | } | 2706 | } |
| 2701 | 2707 | ||
| 2708 | /* disable all cpu buffers */ | ||
| 2709 | for_each_tracing_cpu(cpu) { | ||
| 2710 | if (global_trace.data[cpu]) | ||
| 2711 | atomic_inc(&global_trace.data[cpu]->disabled); | ||
| 2712 | if (max_tr.data[cpu]) | ||
| 2713 | atomic_inc(&max_tr.data[cpu]->disabled); | ||
| 2714 | } | ||
| 2715 | |||
| 2702 | if (val != global_trace.entries) { | 2716 | if (val != global_trace.entries) { |
| 2703 | ret = ring_buffer_resize(global_trace.buffer, val); | 2717 | ret = ring_buffer_resize(global_trace.buffer, val); |
| 2704 | if (ret < 0) { | 2718 | if (ret < 0) { |
| @@ -2730,6 +2744,13 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 2730 | if (tracing_disabled) | 2744 | if (tracing_disabled) |
| 2731 | cnt = -ENOMEM; | 2745 | cnt = -ENOMEM; |
| 2732 | out: | 2746 | out: |
| 2747 | for_each_tracing_cpu(cpu) { | ||
| 2748 | if (global_trace.data[cpu]) | ||
| 2749 | atomic_dec(&global_trace.data[cpu]->disabled); | ||
| 2750 | if (max_tr.data[cpu]) | ||
| 2751 | atomic_dec(&max_tr.data[cpu]->disabled); | ||
| 2752 | } | ||
| 2753 | |||
| 2733 | max_tr.entries = global_trace.entries; | 2754 | max_tr.entries = global_trace.entries; |
| 2734 | mutex_unlock(&trace_types_lock); | 2755 | mutex_unlock(&trace_types_lock); |
| 2735 | 2756 | ||
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index f28484618ff..e62cbf78eab 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c | |||
| @@ -18,12 +18,14 @@ struct header_iter { | |||
| 18 | 18 | ||
| 19 | static struct trace_array *mmio_trace_array; | 19 | static struct trace_array *mmio_trace_array; |
| 20 | static bool overrun_detected; | 20 | static bool overrun_detected; |
| 21 | static unsigned long prev_overruns; | ||
| 21 | 22 | ||
| 22 | static void mmio_reset_data(struct trace_array *tr) | 23 | static void mmio_reset_data(struct trace_array *tr) |
| 23 | { | 24 | { |
| 24 | int cpu; | 25 | int cpu; |
| 25 | 26 | ||
| 26 | overrun_detected = false; | 27 | overrun_detected = false; |
| 28 | prev_overruns = 0; | ||
| 27 | tr->time_start = ftrace_now(tr->cpu); | 29 | tr->time_start = ftrace_now(tr->cpu); |
| 28 | 30 | ||
| 29 | for_each_online_cpu(cpu) | 31 | for_each_online_cpu(cpu) |
| @@ -128,16 +130,12 @@ static void mmio_close(struct trace_iterator *iter) | |||
| 128 | 130 | ||
| 129 | static unsigned long count_overruns(struct trace_iterator *iter) | 131 | static unsigned long count_overruns(struct trace_iterator *iter) |
| 130 | { | 132 | { |
| 131 | int cpu; | ||
| 132 | unsigned long cnt = 0; | 133 | unsigned long cnt = 0; |
| 133 | /* FIXME: */ | 134 | unsigned long over = ring_buffer_overruns(iter->tr->buffer); |
| 134 | #if 0 | 135 | |
| 135 | for_each_online_cpu(cpu) { | 136 | if (over > prev_overruns) |
| 136 | cnt += iter->overrun[cpu]; | 137 | cnt = over - prev_overruns; |
| 137 | iter->overrun[cpu] = 0; | 138 | prev_overruns = over; |
| 138 | } | ||
| 139 | #endif | ||
| 140 | (void)cpu; | ||
| 141 | return cnt; | 139 | return cnt; |
| 142 | } | 140 | } |
| 143 | 141 | ||
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index be682b62fe5..3bdb44bde4b 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
| @@ -184,11 +184,16 @@ static struct file_operations stack_max_size_fops = { | |||
| 184 | static void * | 184 | static void * |
| 185 | t_next(struct seq_file *m, void *v, loff_t *pos) | 185 | t_next(struct seq_file *m, void *v, loff_t *pos) |
| 186 | { | 186 | { |
| 187 | long i = (long)m->private; | 187 | long i; |
| 188 | 188 | ||
| 189 | (*pos)++; | 189 | (*pos)++; |
| 190 | 190 | ||
| 191 | i++; | 191 | if (v == SEQ_START_TOKEN) |
| 192 | i = 0; | ||
| 193 | else { | ||
| 194 | i = *(long *)v; | ||
| 195 | i++; | ||
| 196 | } | ||
| 192 | 197 | ||
| 193 | if (i >= max_stack_trace.nr_entries || | 198 | if (i >= max_stack_trace.nr_entries || |
| 194 | stack_dump_trace[i] == ULONG_MAX) | 199 | stack_dump_trace[i] == ULONG_MAX) |
| @@ -201,12 +206,15 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 201 | 206 | ||
| 202 | static void *t_start(struct seq_file *m, loff_t *pos) | 207 | static void *t_start(struct seq_file *m, loff_t *pos) |
| 203 | { | 208 | { |
| 204 | void *t = &m->private; | 209 | void *t = SEQ_START_TOKEN; |
| 205 | loff_t l = 0; | 210 | loff_t l = 0; |
| 206 | 211 | ||
| 207 | local_irq_disable(); | 212 | local_irq_disable(); |
| 208 | __raw_spin_lock(&max_stack_lock); | 213 | __raw_spin_lock(&max_stack_lock); |
| 209 | 214 | ||
| 215 | if (*pos == 0) | ||
| 216 | return SEQ_START_TOKEN; | ||
| 217 | |||
| 210 | for (; t && l < *pos; t = t_next(m, t, &l)) | 218 | for (; t && l < *pos; t = t_next(m, t, &l)) |
| 211 | ; | 219 | ; |
| 212 | 220 | ||
| @@ -235,10 +243,10 @@ static int trace_lookup_stack(struct seq_file *m, long i) | |||
| 235 | 243 | ||
| 236 | static int t_show(struct seq_file *m, void *v) | 244 | static int t_show(struct seq_file *m, void *v) |
| 237 | { | 245 | { |
| 238 | long i = *(long *)v; | 246 | long i; |
| 239 | int size; | 247 | int size; |
| 240 | 248 | ||
| 241 | if (i < 0) { | 249 | if (v == SEQ_START_TOKEN) { |
| 242 | seq_printf(m, " Depth Size Location" | 250 | seq_printf(m, " Depth Size Location" |
| 243 | " (%d entries)\n" | 251 | " (%d entries)\n" |
| 244 | " ----- ---- --------\n", | 252 | " ----- ---- --------\n", |
| @@ -246,6 +254,8 @@ static int t_show(struct seq_file *m, void *v) | |||
| 246 | return 0; | 254 | return 0; |
| 247 | } | 255 | } |
| 248 | 256 | ||
| 257 | i = *(long *)v; | ||
| 258 | |||
| 249 | if (i >= max_stack_trace.nr_entries || | 259 | if (i >= max_stack_trace.nr_entries || |
| 250 | stack_dump_trace[i] == ULONG_MAX) | 260 | stack_dump_trace[i] == ULONG_MAX) |
| 251 | return 0; | 261 | return 0; |
| @@ -275,10 +285,6 @@ static int stack_trace_open(struct inode *inode, struct file *file) | |||
| 275 | int ret; | 285 | int ret; |
| 276 | 286 | ||
| 277 | ret = seq_open(file, &stack_trace_seq_ops); | 287 | ret = seq_open(file, &stack_trace_seq_ops); |
| 278 | if (!ret) { | ||
| 279 | struct seq_file *m = file->private_data; | ||
| 280 | m->private = (void *)-1; | ||
| 281 | } | ||
| 282 | 288 | ||
| 283 | return ret; | 289 | return ret; |
| 284 | } | 290 | } |
