Skip to content

Commit 404001d

Browse files
committed
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
2 parents e82d2af + 1e8b7b3 commit 404001d

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

kernel/trace/preemptirq_delay_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,5 @@ static void __exit preemptirq_delay_exit(void)
215215

216216
module_init(preemptirq_delay_init)
217217
module_exit(preemptirq_delay_exit)
218+
MODULE_DESCRIPTION("Preempt / IRQ disable delay thread to test latency tracers");
218219
MODULE_LICENSE("GPL v2");

kernel/trace/ring_buffer.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,11 @@ static void rb_check_bpage(struct ring_buffer_per_cpu *cpu_buffer,
14601460
*
14611461
* As a safety measure we check to make sure the data pages have not
14621462
* been corrupted.
1463+
*
1464+
* Callers of this function need to guarantee that the list of pages doesn't get
1465+
* modified during the check. In particular, if it's possible that the function
1466+
* is invoked with concurrent readers which can swap in a new reader page then
1467+
* the caller should take cpu_buffer->reader_lock.
14631468
*/
14641469
static void rb_check_pages(struct ring_buffer_per_cpu *cpu_buffer)
14651470
{
@@ -2210,8 +2215,12 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
22102215
*/
22112216
synchronize_rcu();
22122217
for_each_buffer_cpu(buffer, cpu) {
2218+
unsigned long flags;
2219+
22132220
cpu_buffer = buffer->buffers[cpu];
2221+
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
22142222
rb_check_pages(cpu_buffer);
2223+
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
22152224
}
22162225
atomic_dec(&buffer->record_disabled);
22172226
}
@@ -5046,13 +5055,9 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
50465055
* @flags: gfp flags to use for memory allocation
50475056
*
50485057
* This performs the initial preparations necessary to iterate
5049-
* through the buffer. Memory is allocated, buffer recording
5058+
* through the buffer. Memory is allocated, buffer resizing
50505059
* is disabled, and the iterator pointer is returned to the caller.
50515060
*
5052-
* Disabling buffer recording prevents the reading from being
5053-
* corrupted. This is not a consuming read, so a producer is not
5054-
* expected.
5055-
*
50565061
* After a sequence of ring_buffer_read_prepare calls, the user is
50575062
* expected to make at least one call to ring_buffer_read_prepare_sync.
50585063
* Afterwards, ring_buffer_read_start is invoked to get things going
@@ -5139,21 +5144,15 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_start);
51395144
* ring_buffer_read_finish - finish reading the iterator of the buffer
51405145
* @iter: The iterator retrieved by ring_buffer_start
51415146
*
5142-
* This re-enables the recording to the buffer, and frees the
5143-
* iterator.
5147+
* This re-enables resizing of the buffer, and frees the iterator.
51445148
*/
51455149
void
51465150
ring_buffer_read_finish(struct ring_buffer_iter *iter)
51475151
{
51485152
struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
51495153
unsigned long flags;
51505154

5151-
/*
5152-
* Ring buffer is disabled from recording, here's a good place
5153-
* to check the integrity of the ring buffer.
5154-
* Must prevent readers from trying to read, as the check
5155-
* clears the HEAD page and readers require it.
5156-
*/
5155+
/* Use this opportunity to check the integrity of the ring buffer. */
51575156
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
51585157
rb_check_pages(cpu_buffer);
51595158
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);

kernel/trace/rv/rv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ static int __rv_disable_monitor(struct rv_monitor_def *mdef, bool sync)
245245

246246
/**
247247
* rv_disable_monitor - disable a given runtime monitor
248+
* @mdef: Pointer to the monitor definition structure.
248249
*
249250
* Returns 0 on success.
250251
*/
@@ -256,6 +257,7 @@ int rv_disable_monitor(struct rv_monitor_def *mdef)
256257

257258
/**
258259
* rv_enable_monitor - enable a given runtime monitor
260+
* @mdef: Pointer to the monitor definition structure.
259261
*
260262
* Returns 0 on success, error otherwise.
261263
*/

0 commit comments

Comments
 (0)