Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-3.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing cleanups and bugfixes from Steven Rostedt:
"One bug fix that goes back to 3.10. Accessing a non existent buffer
if "possible cpus" is greater than actual CPUs (including offline
CPUs).

Namhyung Kim did some reviews of the patches I sent this merge window
and found a memory leak and had a few clean ups"

* tag 'trace-3.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing: Fix check of ftrace_trace_arrays list_empty() check
tracing: Fix leak of per cpu max data in instances
tracing: Cleanup saved_cmdlines_size changes
ring-buffer: Check if buffer exists before polling

+37 -21
+1 -1
include/linux/ring_buffer.h
··· 97 97 __ring_buffer_alloc((size), (flags), &__key); \ 98 98 }) 99 99 100 - void ring_buffer_wait(struct ring_buffer *buffer, int cpu); 100 + int ring_buffer_wait(struct ring_buffer *buffer, int cpu); 101 101 int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu, 102 102 struct file *filp, poll_table *poll_table); 103 103
+4 -1
kernel/trace/ring_buffer.c
··· 543 543 * as data is added to any of the @buffer's cpu buffers. Otherwise 544 544 * it will wait for data to be added to a specific cpu buffer. 545 545 */ 546 - void ring_buffer_wait(struct ring_buffer *buffer, int cpu) 546 + int ring_buffer_wait(struct ring_buffer *buffer, int cpu) 547 547 { 548 548 struct ring_buffer_per_cpu *cpu_buffer; 549 549 DEFINE_WAIT(wait); ··· 557 557 if (cpu == RING_BUFFER_ALL_CPUS) 558 558 work = &buffer->irq_work; 559 559 else { 560 + if (!cpumask_test_cpu(cpu, buffer->cpumask)) 561 + return -ENODEV; 560 562 cpu_buffer = buffer->buffers[cpu]; 561 563 work = &cpu_buffer->irq_work; 562 564 } ··· 593 591 schedule(); 594 592 595 593 finish_wait(&work->waiters, &wait); 594 + return 0; 596 595 } 597 596 598 597 /**
+31 -18
kernel/trace/trace.c
··· 1085 1085 } 1086 1086 #endif /* CONFIG_TRACER_MAX_TRACE */ 1087 1087 1088 - static void wait_on_pipe(struct trace_iterator *iter) 1088 + static int wait_on_pipe(struct trace_iterator *iter) 1089 1089 { 1090 1090 /* Iterators are static, they should be filled or empty */ 1091 1091 if (trace_buffer_iter(iter, iter->cpu_file)) 1092 - return; 1092 + return 0; 1093 1093 1094 - ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file); 1094 + return ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file); 1095 1095 } 1096 1096 1097 1097 #ifdef CONFIG_FTRACE_STARTUP_TEST ··· 1338 1338 { 1339 1339 int ret; 1340 1340 1341 - savedcmd = kmalloc(sizeof(struct saved_cmdlines_buffer), GFP_KERNEL); 1341 + savedcmd = kmalloc(sizeof(*savedcmd), GFP_KERNEL); 1342 1342 if (!savedcmd) 1343 1343 return -ENOMEM; 1344 1344 ··· 3840 3840 int r; 3841 3841 3842 3842 arch_spin_lock(&trace_cmdline_lock); 3843 - r = sprintf(buf, "%u\n", savedcmd->cmdline_num); 3843 + r = scnprintf(buf, sizeof(buf), "%u\n", savedcmd->cmdline_num); 3844 3844 arch_spin_unlock(&trace_cmdline_lock); 3845 3845 3846 3846 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); ··· 3857 3857 { 3858 3858 struct saved_cmdlines_buffer *s, *savedcmd_temp; 3859 3859 3860 - s = kmalloc(sizeof(struct saved_cmdlines_buffer), GFP_KERNEL); 3860 + s = kmalloc(sizeof(*s), GFP_KERNEL); 3861 3861 if (!s) 3862 3862 return -ENOMEM; 3863 3863 ··· 4378 4378 static int tracing_wait_pipe(struct file *filp) 4379 4379 { 4380 4380 struct trace_iterator *iter = filp->private_data; 4381 + int ret; 4381 4382 4382 4383 while (trace_empty(iter)) { 4383 4384 ··· 4400 4399 4401 4400 mutex_unlock(&iter->mutex); 4402 4401 4403 - wait_on_pipe(iter); 4402 + ret = wait_on_pipe(iter); 4404 4403 4405 4404 mutex_lock(&iter->mutex); 4405 + 4406 + if (ret) 4407 + return ret; 4406 4408 4407 4409 if (signal_pending(current)) 4408 4410 return -EINTR; ··· 5331 5327 goto out_unlock; 5332 5328 } 5333 5329 mutex_unlock(&trace_types_lock); 5334 - wait_on_pipe(iter); 5330 + ret = wait_on_pipe(iter); 5335 5331 mutex_lock(&trace_types_lock); 5332 + if (ret) { 5333 + size = ret; 5334 + goto out_unlock; 5335 + } 5336 5336 if (signal_pending(current)) { 5337 5337 size = -EINTR; 5338 5338 goto out_unlock; ··· 5546 5538 goto out; 5547 5539 } 5548 5540 mutex_unlock(&trace_types_lock); 5549 - wait_on_pipe(iter); 5541 + ret = wait_on_pipe(iter); 5550 5542 mutex_lock(&trace_types_lock); 5543 + if (ret) 5544 + goto out; 5551 5545 if (signal_pending(current)) { 5552 5546 ret = -EINTR; 5553 5547 goto out; ··· 6242 6232 return 0; 6243 6233 } 6244 6234 6235 + static void free_trace_buffer(struct trace_buffer *buf) 6236 + { 6237 + if (buf->buffer) { 6238 + ring_buffer_free(buf->buffer); 6239 + buf->buffer = NULL; 6240 + free_percpu(buf->data); 6241 + buf->data = NULL; 6242 + } 6243 + } 6244 + 6245 6245 static void free_trace_buffers(struct trace_array *tr) 6246 6246 { 6247 6247 if (!tr) 6248 6248 return; 6249 6249 6250 - if (tr->trace_buffer.buffer) { 6251 - ring_buffer_free(tr->trace_buffer.buffer); 6252 - tr->trace_buffer.buffer = NULL; 6253 - free_percpu(tr->trace_buffer.data); 6254 - } 6250 + free_trace_buffer(&tr->trace_buffer); 6255 6251 6256 6252 #ifdef CONFIG_TRACER_MAX_TRACE 6257 - if (tr->max_buffer.buffer) { 6258 - ring_buffer_free(tr->max_buffer.buffer); 6259 - tr->max_buffer.buffer = NULL; 6260 - } 6253 + free_trace_buffer(&tr->max_buffer); 6261 6254 #endif 6262 6255 } 6263 6256
+1 -1
kernel/trace/trace.h
··· 252 252 { 253 253 struct trace_array *tr; 254 254 255 - if (list_empty(ftrace_trace_arrays.prev)) 255 + if (list_empty(&ftrace_trace_arrays)) 256 256 return NULL; 257 257 258 258 tr = list_entry(ftrace_trace_arrays.prev,