Skip to content

Commit 584528d

Browse files
jognesspmladek
authored andcommitted
printk: ringbuffer: Cleanup reader terminology
With the lockless ringbuffer, it is allowed that multiple CPUs/contexts write simultaneously into the buffer. This creates an ambiguity as some writers will finalize sooner. The documentation for the prb_read functions is not clear as it refers to "not yet written" and "no data available". Clarify the return values and language to be in terms of the reader: records available for reading. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 36652d0 commit 584528d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

kernel/printk/printk_ringbuffer.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,11 +1987,13 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
19871987
}
19881988

19891989
/*
1990-
* Non-blocking read of a record. Updates @seq to the last finalized record
1991-
* (which may have no data available).
1990+
* Non-blocking read of a record.
19921991
*
1993-
* See the description of prb_read_valid() and prb_read_valid_info()
1994-
* for details.
1992+
* On success @seq is updated to the record that was read and (if provided)
1993+
* @r and @line_count will contain the read/calculated data.
1994+
*
1995+
* On failure @seq is updated to a record that is not yet available to the
1996+
* reader, but it will be the next record available to the reader.
19951997
*/
19961998
static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq,
19971999
struct printk_record *r, unsigned int *line_count)
@@ -2010,7 +2012,7 @@ static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq,
20102012
*seq = tail_seq;
20112013

20122014
} else if (err == -ENOENT) {
2013-
/* Record exists, but no data available. Skip. */
2015+
/* Record exists, but the data was lost. Skip. */
20142016
(*seq)++;
20152017

20162018
} else {
@@ -2043,7 +2045,7 @@ static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq,
20432045
* On success, the reader must check r->info.seq to see which record was
20442046
* actually read. This allows the reader to detect dropped records.
20452047
*
2046-
* Failure means @seq refers to a not yet written record.
2048+
* Failure means @seq refers to a record not yet available to the reader.
20472049
*/
20482050
bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq,
20492051
struct printk_record *r)
@@ -2073,7 +2075,7 @@ bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq,
20732075
* On success, the reader must check info->seq to see which record meta data
20742076
* was actually read. This allows the reader to detect dropped records.
20752077
*
2076-
* Failure means @seq refers to a not yet written record.
2078+
* Failure means @seq refers to a record not yet available to the reader.
20772079
*/
20782080
bool prb_read_valid_info(struct printk_ringbuffer *rb, u64 seq,
20792081
struct printk_info *info, unsigned int *line_count)

0 commit comments

Comments
 (0)