trace.c (2d8ad8719591fa803b0d589ed057fa46f49b7155) | trace.c (750912fa366312e9c5bc83eab352898a26750401) |
---|---|
1/* 2 * ring buffer based function tracer 3 * 4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com> 6 * 7 * Originally taken from the RT patch by: 8 * Arnaldo Carvalho de Melo <acme@redhat.com> --- 27 unchanged lines hidden (view full) --- 36#include <linux/ctype.h> 37#include <linux/init.h> 38#include <linux/poll.h> 39#include <linux/fs.h> 40 41#include "trace.h" 42#include "trace_output.h" 43 | 1/* 2 * ring buffer based function tracer 3 * 4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com> 6 * 7 * Originally taken from the RT patch by: 8 * Arnaldo Carvalho de Melo <acme@redhat.com> --- 27 unchanged lines hidden (view full) --- 36#include <linux/ctype.h> 37#include <linux/init.h> 38#include <linux/poll.h> 39#include <linux/fs.h> 40 41#include "trace.h" 42#include "trace_output.h" 43 |
44#define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) 45 | |
46/* 47 * On boot up, the ring buffer is set to the minimum size, so that 48 * we do not waste memory on systems that are not using tracing. 49 */ 50int ring_buffer_expanded; 51 52/* 53 * We need to change this state when a selftest is running. --- 281 unchanged lines hidden (view full) --- 335#endif 336 337/* trace_wait is a waitqueue for tasks blocked on trace_poll */ 338static DECLARE_WAIT_QUEUE_HEAD(trace_wait); 339 340/* trace_flags holds trace_options default values */ 341unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | 342 TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | | 44/* 45 * On boot up, the ring buffer is set to the minimum size, so that 46 * we do not waste memory on systems that are not using tracing. 47 */ 48int ring_buffer_expanded; 49 50/* 51 * We need to change this state when a selftest is running. --- 281 unchanged lines hidden (view full) --- 333#endif 334 335/* trace_wait is a waitqueue for tasks blocked on trace_poll */ 336static DECLARE_WAIT_QUEUE_HEAD(trace_wait); 337 338/* trace_flags holds trace_options default values */ 339unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | 340 TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | |
343 TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD; | 341 TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE; |
344 345static int trace_stop_count; 346static DEFINE_SPINLOCK(tracing_start_lock); 347 348/** 349 * trace_wake_up - wake up tasks waiting for trace input 350 * 351 * Simply wakes up any task that is blocked on the trace_wait --- 68 unchanged lines hidden (view full) --- 420 "userstacktrace", 421 "sym-userobj", 422 "printk-msg-only", 423 "context-info", 424 "latency-format", 425 "sleep-time", 426 "graph-time", 427 "record-cmd", | 342 343static int trace_stop_count; 344static DEFINE_SPINLOCK(tracing_start_lock); 345 346/** 347 * trace_wake_up - wake up tasks waiting for trace input 348 * 349 * Simply wakes up any task that is blocked on the trace_wait --- 68 unchanged lines hidden (view full) --- 418 "userstacktrace", 419 "sym-userobj", 420 "printk-msg-only", 421 "context-info", 422 "latency-format", 423 "sleep-time", 424 "graph-time", 425 "record-cmd", |
426 "overwrite", |
|
428 NULL 429}; 430 431static struct { 432 u64 (*func)(void); 433 const char *name; 434} trace_clocks[] = { 435 { trace_clock_local, "local" }, --- 2088 unchanged lines hidden (view full) --- 2524 2525 if (enabled) 2526 trace_flags |= mask; 2527 else 2528 trace_flags &= ~mask; 2529 2530 if (mask == TRACE_ITER_RECORD_CMD) 2531 trace_event_enable_cmd_record(enabled); | 427 NULL 428}; 429 430static struct { 431 u64 (*func)(void); 432 const char *name; 433} trace_clocks[] = { 434 { trace_clock_local, "local" }, --- 2088 unchanged lines hidden (view full) --- 2523 2524 if (enabled) 2525 trace_flags |= mask; 2526 else 2527 trace_flags &= ~mask; 2528 2529 if (mask == TRACE_ITER_RECORD_CMD) 2530 trace_event_enable_cmd_record(enabled); |
2531 2532 if (mask == TRACE_ITER_OVERWRITE) 2533 ring_buffer_change_overwrite(global_trace.buffer, enabled); |
|
2532} 2533 2534static ssize_t 2535tracing_trace_options_write(struct file *filp, const char __user *ubuf, 2536 size_t cnt, loff_t *ppos) 2537{ 2538 char buf[64]; 2539 char *cmp; --- 165 unchanged lines hidden (view full) --- 2705 ret = strict_strtoul(buf, 10, &val); 2706 if (ret < 0) 2707 return ret; 2708 2709 val = !!val; 2710 2711 mutex_lock(&trace_types_lock); 2712 if (tracer_enabled ^ val) { | 2534} 2535 2536static ssize_t 2537tracing_trace_options_write(struct file *filp, const char __user *ubuf, 2538 size_t cnt, loff_t *ppos) 2539{ 2540 char buf[64]; 2541 char *cmp; --- 165 unchanged lines hidden (view full) --- 2707 ret = strict_strtoul(buf, 10, &val); 2708 if (ret < 0) 2709 return ret; 2710 2711 val = !!val; 2712 2713 mutex_lock(&trace_types_lock); 2714 if (tracer_enabled ^ val) { |
2715 2716 /* Only need to warn if this is used to change the state */ 2717 WARN_ONCE(1, "tracing_enabled is deprecated. Use tracing_on"); 2718 |
|
2713 if (val) { 2714 tracer_enabled = 1; 2715 if (current_trace->start) 2716 current_trace->start(tr); 2717 tracing_start(); 2718 } else { 2719 tracer_enabled = 0; 2720 tracing_stop(); --- 1825 unchanged lines hidden (view full) --- 4546void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) 4547{ 4548 __ftrace_dump(true, oops_dump_mode); 4549} 4550 4551__init static int tracer_alloc_buffers(void) 4552{ 4553 int ring_buf_size; | 2719 if (val) { 2720 tracer_enabled = 1; 2721 if (current_trace->start) 2722 current_trace->start(tr); 2723 tracing_start(); 2724 } else { 2725 tracer_enabled = 0; 2726 tracing_stop(); --- 1825 unchanged lines hidden (view full) --- 4552void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) 4553{ 4554 __ftrace_dump(true, oops_dump_mode); 4555} 4556 4557__init static int tracer_alloc_buffers(void) 4558{ 4559 int ring_buf_size; |
4560 enum ring_buffer_flags rb_flags; |
|
4554 int i; 4555 int ret = -ENOMEM; 4556 | 4561 int i; 4562 int ret = -ENOMEM; 4563 |
4564 |
|
4557 if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) 4558 goto out; 4559 4560 if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL)) 4561 goto out_free_buffer_mask; 4562 4563 /* To save memory, keep the ring buffer size to its minimum */ 4564 if (ring_buffer_expanded) 4565 ring_buf_size = trace_buf_size; 4566 else 4567 ring_buf_size = 1; 4568 | 4565 if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) 4566 goto out; 4567 4568 if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL)) 4569 goto out_free_buffer_mask; 4570 4571 /* To save memory, keep the ring buffer size to its minimum */ 4572 if (ring_buffer_expanded) 4573 ring_buf_size = trace_buf_size; 4574 else 4575 ring_buf_size = 1; 4576 |
4577 rb_flags = trace_flags & TRACE_ITER_OVERWRITE ? RB_FL_OVERWRITE : 0; 4578 |
|
4569 cpumask_copy(tracing_buffer_mask, cpu_possible_mask); 4570 cpumask_copy(tracing_cpumask, cpu_all_mask); 4571 4572 /* TODO: make the number of buffers hot pluggable with CPUS */ | 4579 cpumask_copy(tracing_buffer_mask, cpu_possible_mask); 4580 cpumask_copy(tracing_cpumask, cpu_all_mask); 4581 4582 /* TODO: make the number of buffers hot pluggable with CPUS */ |
4573 global_trace.buffer = ring_buffer_alloc(ring_buf_size, 4574 TRACE_BUFFER_FLAGS); | 4583 global_trace.buffer = ring_buffer_alloc(ring_buf_size, rb_flags); |
4575 if (!global_trace.buffer) { 4576 printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); 4577 WARN_ON(1); 4578 goto out_free_cpumask; 4579 } 4580 global_trace.entries = ring_buffer_size(global_trace.buffer); 4581 4582 4583#ifdef CONFIG_TRACER_MAX_TRACE | 4584 if (!global_trace.buffer) { 4585 printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); 4586 WARN_ON(1); 4587 goto out_free_cpumask; 4588 } 4589 global_trace.entries = ring_buffer_size(global_trace.buffer); 4590 4591 4592#ifdef CONFIG_TRACER_MAX_TRACE |
4584 max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS); | 4593 max_tr.buffer = ring_buffer_alloc(1, rb_flags); |
4585 if (!max_tr.buffer) { 4586 printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); 4587 WARN_ON(1); 4588 ring_buffer_free(global_trace.buffer); 4589 goto out_free_cpumask; 4590 } 4591 max_tr.entries = 1; 4592#endif --- 51 unchanged lines hidden --- | 4594 if (!max_tr.buffer) { 4595 printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); 4596 WARN_ON(1); 4597 ring_buffer_free(global_trace.buffer); 4598 goto out_free_cpumask; 4599 } 4600 max_tr.entries = 1; 4601#endif --- 51 unchanged lines hidden --- |