diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-02-20 17:40:43 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-20 17:40:43 +0100 |
commit | 3b6f7b9beb553ea71a6d4d76ba82cf32eb6dadd2 (patch) | |
tree | 2cd8a8d61f350aa3b00e6b0afc998544923f183e /kernel/trace/trace_selftest.c | |
parent | 9be1b56a3e718aa998772019c57c398dbb19e258 (diff) | |
parent | 07a66d7c53a538e1a9759954a82bb6c07365eff9 (diff) | |
download | op-kernel-dev-3b6f7b9beb553ea71a6d4d76ba82cf32eb6dadd2.zip op-kernel-dev-3b6f7b9beb553ea71a6d4d76ba82cf32eb6dadd2.tar.gz |
Merge branch 'x86/urgent' into x86/core
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r-- | kernel/trace/trace_selftest.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 88c8eb7..bc8e80a 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c @@ -23,10 +23,20 @@ static int trace_test_buffer_cpu(struct trace_array *tr, int cpu) { struct ring_buffer_event *event; struct trace_entry *entry; + unsigned int loops = 0; while ((event = ring_buffer_consume(tr->buffer, cpu, NULL))) { entry = ring_buffer_event_data(event); + /* + * The ring buffer is a size of trace_buf_size, if + * we loop more than the size, there's something wrong + * with the ring buffer. + */ + if (loops++ > trace_buf_size) { + printk(KERN_CONT ".. bad ring buffer "); + goto failed; + } if (!trace_valid_entry(entry)) { printk(KERN_CONT ".. invalid entry %d ", entry->type); @@ -57,11 +67,20 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) cnt = ring_buffer_entries(tr->buffer); + /* + * The trace_test_buffer_cpu runs a while loop to consume all data. + * If the calling tracer is broken, and is constantly filling + * the buffer, this will run forever, and hard lock the box. + * We disable the ring buffer while we do this test to prevent + * a hard lock up. + */ + tracing_off(); for_each_possible_cpu(cpu) { ret = trace_test_buffer_cpu(tr, cpu); if (ret) break; } + tracing_on(); __raw_spin_unlock(&ftrace_max_lock); local_irq_restore(flags); |