lkml.org 
[lkml]   [2020]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH printk 2/5] printk: kmsg_dump_rewind_nolock: start from first record
Date
kmsg_dump_rewind_nolock() accesses @clear_seq without any locking.
However, accessing this global variable requires holding
@logbuf_lock. For the _nolock() variant, start from the first record
in the ringbuffer rather than the @clear_seq record.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/printk.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 00bc1fce3299..cff13b33e926 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3410,11 +3410,12 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
* kmsg_dump_get_buffer() can be called again and used multiple
* times within the same dumper.dump() callback.
*
- * The function is similar to kmsg_dump_rewind(), but grabs no locks.
+ * The function is similar to kmsg_dump_rewind(), but grabs no locks
+ * and starts from the oldest record rather than from @clear_seq.
*/
void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
{
- dumper->cur_seq = clear_seq;
+ dumper->cur_seq = 0;
dumper->next_seq = prb_next_seq(prb);
}

@@ -3431,7 +3432,8 @@ void kmsg_dump_rewind(struct kmsg_dumper *dumper)
unsigned long flags;

logbuf_lock_irqsave(flags);
- kmsg_dump_rewind_nolock(dumper);
+ dumper->cur_seq = clear_seq;
+ dumper->next_seq = prb_next_seq(prb);
logbuf_unlock_irqrestore(flags);
}
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
--
2.20.1
\
 
 \ /
  Last update: 2020-09-22 17:38    [W:0.136 / U:1.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site