Skip to content

Commit ea70a96

Browse files
petrpavlurostedt
authored andcommitted
ring-buffer: Correct stale comments related to non-consuming readers
Adjust the following code documentation: * Kernel-doc comments for ring_buffer_read_prepare() and ring_buffer_read_finish() mention that recording to the ring buffer is disabled when the read is active. Remove mention of this restriction because it was already lifted in commit 1039221 ("ring-buffer: Do not disable recording when there is an iterator"). * Function ring_buffer_read_finish() performs a self-check of the ring-buffer by locking cpu_buffer->reader_lock and then calling rb_check_pages(). The preceding comment explains that the lock is needed because rb_check_pages() clears the HEAD flag required by readers which might be running in parallel. Remove this explanation because commit 8843e06 ("ring-buffer: Handle race between rb_move_tail and rb_check_pages") simplified the function so it no longer resets the mentioned flag. Nonetheless, the lock is still needed because a reader swapping a page into the ring buffer can make the underlying doubly-linked list temporarily inconsistent. This is a non-functional change. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Signed-off-by: Petr Pavlu <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent fa3889d commit ea70a96

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

kernel/trace/ring_buffer.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5046,13 +5046,9 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
50465046
* @flags: gfp flags to use for memory allocation
50475047
*
50485048
* This performs the initial preparations necessary to iterate
5049-
* through the buffer. Memory is allocated, buffer recording
5049+
* through the buffer. Memory is allocated, buffer resizing
50505050
* is disabled, and the iterator pointer is returned to the caller.
50515051
*
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-
*
50565052
* After a sequence of ring_buffer_read_prepare calls, the user is
50575053
* expected to make at least one call to ring_buffer_read_prepare_sync.
50585054
* Afterwards, ring_buffer_read_start is invoked to get things going
@@ -5139,21 +5135,15 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_start);
51395135
* ring_buffer_read_finish - finish reading the iterator of the buffer
51405136
* @iter: The iterator retrieved by ring_buffer_start
51415137
*
5142-
* This re-enables the recording to the buffer, and frees the
5143-
* iterator.
5138+
* This re-enables resizing of the buffer, and frees the iterator.
51445139
*/
51455140
void
51465141
ring_buffer_read_finish(struct ring_buffer_iter *iter)
51475142
{
51485143
struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
51495144
unsigned long flags;
51505145

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-
*/
5146+
/* Use this opportunity to check the integrity of the ring buffer. */
51575147
raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
51585148
rb_check_pages(cpu_buffer);
51595149
raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);

0 commit comments

Comments
 (0)