diff options
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/ring_buffer.c | 11 | ||||
-rw-r--r-- | kernel/trace/trace.c | 17 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 |
3 files changed, 23 insertions, 6 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index bd1c35a4fbcc..269db80a961e 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -1429,6 +1429,17 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
1429 | } | 1429 | } |
1430 | EXPORT_SYMBOL_GPL(ring_buffer_resize); | 1430 | EXPORT_SYMBOL_GPL(ring_buffer_resize); |
1431 | 1431 | ||
1432 | void ring_buffer_change_overwrite(struct ring_buffer *buffer, int val) | ||
1433 | { | ||
1434 | mutex_lock(&buffer->mutex); | ||
1435 | if (val) | ||
1436 | buffer->flags |= RB_FL_OVERWRITE; | ||
1437 | else | ||
1438 | buffer->flags &= ~RB_FL_OVERWRITE; | ||
1439 | mutex_unlock(&buffer->mutex); | ||
1440 | } | ||
1441 | EXPORT_SYMBOL_GPL(ring_buffer_change_overwrite); | ||
1442 | |||
1432 | static inline void * | 1443 | static inline void * |
1433 | __rb_data_page_index(struct buffer_data_page *bpage, unsigned index) | 1444 | __rb_data_page_index(struct buffer_data_page *bpage, unsigned index) |
1434 | { | 1445 | { |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8dc8da6733f9..85e3ee1e474e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #include "trace.h" | 41 | #include "trace.h" |
42 | #include "trace_output.h" | 42 | #include "trace_output.h" |
43 | 43 | ||
44 | #define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) | ||
45 | |||
46 | /* | 44 | /* |
47 | * On boot up, the ring buffer is set to the minimum size, so that | 45 | * 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. | 46 | * we do not waste memory on systems that are not using tracing. |
@@ -340,7 +338,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait); | |||
340 | /* trace_flags holds trace_options default values */ | 338 | /* trace_flags holds trace_options default values */ |
341 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | | 339 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | |
342 | TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | | 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 | 342 | ||
345 | static int trace_stop_count; | 343 | static int trace_stop_count; |
346 | static DEFINE_SPINLOCK(tracing_start_lock); | 344 | static DEFINE_SPINLOCK(tracing_start_lock); |
@@ -425,6 +423,7 @@ static const char *trace_options[] = { | |||
425 | "sleep-time", | 423 | "sleep-time", |
426 | "graph-time", | 424 | "graph-time", |
427 | "record-cmd", | 425 | "record-cmd", |
426 | "overwrite", | ||
428 | NULL | 427 | NULL |
429 | }; | 428 | }; |
430 | 429 | ||
@@ -2529,6 +2528,9 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
2529 | 2528 | ||
2530 | if (mask == TRACE_ITER_RECORD_CMD) | 2529 | if (mask == TRACE_ITER_RECORD_CMD) |
2531 | trace_event_enable_cmd_record(enabled); | 2530 | trace_event_enable_cmd_record(enabled); |
2531 | |||
2532 | if (mask == TRACE_ITER_OVERWRITE) | ||
2533 | ring_buffer_change_overwrite(global_trace.buffer, enabled); | ||
2532 | } | 2534 | } |
2533 | 2535 | ||
2534 | static ssize_t | 2536 | static ssize_t |
@@ -4555,9 +4557,11 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) | |||
4555 | __init static int tracer_alloc_buffers(void) | 4557 | __init static int tracer_alloc_buffers(void) |
4556 | { | 4558 | { |
4557 | int ring_buf_size; | 4559 | int ring_buf_size; |
4560 | enum ring_buffer_flags rb_flags; | ||
4558 | int i; | 4561 | int i; |
4559 | int ret = -ENOMEM; | 4562 | int ret = -ENOMEM; |
4560 | 4563 | ||
4564 | |||
4561 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) | 4565 | if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) |
4562 | goto out; | 4566 | goto out; |
4563 | 4567 | ||
@@ -4570,12 +4574,13 @@ __init static int tracer_alloc_buffers(void) | |||
4570 | else | 4574 | else |
4571 | ring_buf_size = 1; | 4575 | ring_buf_size = 1; |
4572 | 4576 | ||
4577 | rb_flags = trace_flags & TRACE_ITER_OVERWRITE ? RB_FL_OVERWRITE : 0; | ||
4578 | |||
4573 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); | 4579 | cpumask_copy(tracing_buffer_mask, cpu_possible_mask); |
4574 | cpumask_copy(tracing_cpumask, cpu_all_mask); | 4580 | cpumask_copy(tracing_cpumask, cpu_all_mask); |
4575 | 4581 | ||
4576 | /* TODO: make the number of buffers hot pluggable with CPUS */ | 4582 | /* TODO: make the number of buffers hot pluggable with CPUS */ |
4577 | global_trace.buffer = ring_buffer_alloc(ring_buf_size, | 4583 | global_trace.buffer = ring_buffer_alloc(ring_buf_size, rb_flags); |
4578 | TRACE_BUFFER_FLAGS); | ||
4579 | if (!global_trace.buffer) { | 4584 | if (!global_trace.buffer) { |
4580 | printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); | 4585 | printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); |
4581 | WARN_ON(1); | 4586 | WARN_ON(1); |
@@ -4585,7 +4590,7 @@ __init static int tracer_alloc_buffers(void) | |||
4585 | 4590 | ||
4586 | 4591 | ||
4587 | #ifdef CONFIG_TRACER_MAX_TRACE | 4592 | #ifdef CONFIG_TRACER_MAX_TRACE |
4588 | max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS); | 4593 | max_tr.buffer = ring_buffer_alloc(1, rb_flags); |
4589 | if (!max_tr.buffer) { | 4594 | if (!max_tr.buffer) { |
4590 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); | 4595 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); |
4591 | WARN_ON(1); | 4596 | WARN_ON(1); |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 856e73cc1d3f..951d0b7e7062 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -606,6 +606,7 @@ enum trace_iterator_flags { | |||
606 | TRACE_ITER_SLEEP_TIME = 0x40000, | 606 | TRACE_ITER_SLEEP_TIME = 0x40000, |
607 | TRACE_ITER_GRAPH_TIME = 0x80000, | 607 | TRACE_ITER_GRAPH_TIME = 0x80000, |
608 | TRACE_ITER_RECORD_CMD = 0x100000, | 608 | TRACE_ITER_RECORD_CMD = 0x100000, |
609 | TRACE_ITER_OVERWRITE = 0x200000, | ||
609 | }; | 610 | }; |
610 | 611 | ||
611 | /* | 612 | /* |