Commit 404001dd authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-fixes-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Minor last minute fixes:

   - Fix a very tight race between the ring buffer readers and resizing
     the ring buffer

   - Correct some stale comments in the ring buffer code

   - Fix kernel-doc in the rv code

   - Add a MODULE_DESCRIPTION to preemptirq_delay_test"

* tag 'trace-fixes-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  rv: Update rv_en(dis)able_monitor doc to match kernel-doc
  tracing: Add MODULE_DESCRIPTION() to preemptirq_delay_test
  ring-buffer: Fix a race between readers and resize checks
  ring-buffer: Correct stale comments related to non-consuming readers
parents e82d2af5 1e8b7b3d
...@@ -215,4 +215,5 @@ static void __exit preemptirq_delay_exit(void) ...@@ -215,4 +215,5 @@ static void __exit preemptirq_delay_exit(void)
module_init(preemptirq_delay_init) module_init(preemptirq_delay_init)
module_exit(preemptirq_delay_exit) module_exit(preemptirq_delay_exit)
MODULE_DESCRIPTION("Preempt / IRQ disable delay thread to test latency tracers");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -1460,6 +1460,11 @@ static void rb_check_bpage(struct ring_buffer_per_cpu *cpu_buffer, ...@@ -1460,6 +1460,11 @@ static void rb_check_bpage(struct ring_buffer_per_cpu *cpu_buffer,
* *
* As a safety measure we check to make sure the data pages have not * As a safety measure we check to make sure the data pages have not
* been corrupted. * been corrupted.
*
* Callers of this function need to guarantee that the list of pages doesn't get
* modified during the check. In particular, if it's possible that the function
* is invoked with concurrent readers which can swap in a new reader page then
* the caller should take cpu_buffer->reader_lock.
*/ */
static void rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer) static void rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
{ {
...@@ -2210,8 +2215,12 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, ...@@ -2210,8 +2215,12 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
*/ */
synchronize_rcu(); synchronize_rcu();
for_each_buffer_cpu(buffer, cpu) { for_each_buffer_cpu(buffer, cpu) {
unsigned long flags;
cpu_buffer = buffer->buffers[cpu]; cpu_buffer = buffer->buffers[cpu];
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
rb_check_pages(cpu_buffer); rb_check_pages(cpu_buffer);
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
} }
atomic_dec(&buffer->record_disabled); atomic_dec(&buffer->record_disabled);
} }
...@@ -5046,13 +5055,9 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume); ...@@ -5046,13 +5055,9 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
* @flags: gfp flags to use for memory allocation * @flags: gfp flags to use for memory allocation
* *
* This performs the initial preparations necessary to iterate * This performs the initial preparations necessary to iterate
* through the buffer. Memory is allocated, buffer recording * through the buffer. Memory is allocated, buffer resizing
* is disabled, and the iterator pointer is returned to the caller. * is disabled, and the iterator pointer is returned to the caller.
* *
* Disabling buffer recording prevents the reading from being
* corrupted. This is not a consuming read, so a producer is not
* expected.
*
* After a sequence of ring_buffer_read_prepare calls, the user is * After a sequence of ring_buffer_read_prepare calls, the user is
* expected to make at least one call to ring_buffer_read_prepare_sync. * expected to make at least one call to ring_buffer_read_prepare_sync.
* Afterwards, ring_buffer_read_start is invoked to get things going * Afterwards, ring_buffer_read_start is invoked to get things going
...@@ -5139,8 +5144,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_start); ...@@ -5139,8 +5144,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_start);
* ring_buffer_read_finish - finish reading the iterator of the buffer * ring_buffer_read_finish - finish reading the iterator of the buffer
* @iter: The iterator retrieved by ring_buffer_start * @iter: The iterator retrieved by ring_buffer_start
* *
* This re-enables the recording to the buffer, and frees the * This re-enables resizing of the buffer, and frees the iterator.
* iterator.
*/ */
void void
ring_buffer_read_finish(struct ring_buffer_iter *iter) ring_buffer_read_finish(struct ring_buffer_iter *iter)
...@@ -5148,12 +5152,7 @@ ring_buffer_read_finish(struct ring_buffer_iter *iter) ...@@ -5148,12 +5152,7 @@ ring_buffer_read_finish(struct ring_buffer_iter *iter)
struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
unsigned long flags; unsigned long flags;
/* /* Use this opportunity to check the integrity of the ring buffer. */
* Ring buffer is disabled from recording, here's a good place
* to check the integrity of the ring buffer.
* Must prevent readers from trying to read, as the check
* clears the HEAD page and readers require it.
*/
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
rb_check_pages(cpu_buffer); rb_check_pages(cpu_buffer);
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
......
...@@ -245,6 +245,7 @@ static int __rv_disable_monitor(struct rv_monitor_def *mdef, bool sync) ...@@ -245,6 +245,7 @@ static int __rv_disable_monitor(struct rv_monitor_def *mdef, bool sync)
/** /**
* rv_disable_monitor - disable a given runtime monitor * rv_disable_monitor - disable a given runtime monitor
* @mdef: Pointer to the monitor definition structure.
* *
* Returns 0 on success. * Returns 0 on success.
*/ */
...@@ -256,6 +257,7 @@ int rv_disable_monitor(struct rv_monitor_def *mdef) ...@@ -256,6 +257,7 @@ int rv_disable_monitor(struct rv_monitor_def *mdef)
/** /**
* rv_enable_monitor - enable a given runtime monitor * rv_enable_monitor - enable a given runtime monitor
* @mdef: Pointer to the monitor definition structure.
* *
* Returns 0 on success, error otherwise. * Returns 0 on success, error otherwise.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment