All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: kmsg_dump: revert msg_print_text() workaround
@ 2021-01-14  9:05 John Ogness
  2021-01-14 15:49 ` Petr Mladek
  0 siblings, 1 reply; 2+ messages in thread
From: John Ogness @ 2021-01-14  9:05 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Sergey Senozhatsky, Steven Rostedt, linux-kernel

The old msg_print_text() function only filled up to size-1 bytes of
the buffer. A workaround for this quirky behavior was implemented
with commit c9dccacfccc7 ("printk: Do not lose last line in kmsg
buffer dump").

However, with commit 896fbe20b4e2 ("printk: use the lockless
ringbuffer"), msg_print_text() was replaced by record_print_text(),
which will fill the full buffer. Therefore, the workaround is now
incorrectly assuming less data can fit into the buffer. Revert the
workaround.

Fixes: 896fbe20b4e2 ("printk: use the lockless ringbuffer")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 This patch is on top of https://lkml.kernel.org/r/20210113164413.1599-1-john.ogness@linutronix.de
 and possibly could be squashed into that patch. However I recommend
 keeping them separate since they affect kmsg_dump_get_buffer() in
 different ways.

 kernel/printk/printk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 848b56efc9d7..489b9330f7f7 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3433,8 +3433,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
 
 	/* move first record forward until length fits into the buffer */
 	seq = dumper->cur_seq;
-	while (l >= size && prb_read_valid_info(prb, seq,
-						&info, &line_count)) {
+	while (l > size && prb_read_valid_info(prb, seq, &info, &line_count)) {
 		if (r.info->seq >= dumper->next_seq)
 			break;
 		l -= get_record_print_text_size(&info, line_count, syslog, time);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] printk: kmsg_dump: revert msg_print_text() workaround
  2021-01-14  9:05 [PATCH] printk: kmsg_dump: revert msg_print_text() workaround John Ogness
@ 2021-01-14 15:49 ` Petr Mladek
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2021-01-14 15:49 UTC (permalink / raw)
  To: John Ogness
  Cc: Sergey Senozhatsky, Sergey Senozhatsky, Steven Rostedt, linux-kernel

On Thu 2021-01-14 10:11:11, John Ogness wrote:
> The old msg_print_text() function only filled up to size-1 bytes of
> the buffer. A workaround for this quirky behavior was implemented
> with commit c9dccacfccc7 ("printk: Do not lose last line in kmsg
> buffer dump").
> 
> However, with commit 896fbe20b4e2 ("printk: use the lockless
> ringbuffer"), msg_print_text() was replaced by,
> which will fill the full buffer. Therefore, the workaround is now
> incorrectly assuming less data can fit into the buffer. Revert the
> workaround.

We should make record_print_text() behave the same as msg_print_text()
behaved. There might be more users affected by this change and even
in userspace :-(

Let's discuss it in the other thread
https://lore.kernel.org/lkml/87im8038v7.fsf@jogness.linutronix.de/

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-14 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14  9:05 [PATCH] printk: kmsg_dump: revert msg_print_text() workaround John Ogness
2021-01-14 15:49 ` Petr Mladek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.