[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87imt2bl0k.fsf@linutronix.de>
Date: Wed, 19 Jun 2019 00:12:43 +0200
From: John Ogness <john.ogness@...utronix.de>
To: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrea Parri <andrea.parri@...rulasolutions.com>,
Thomas Gleixner <tglx@...utronix.de>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation
On 2019-06-18, Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> wrote:
>> + struct prb_reserved_entry e;
>> + char *s;
>> +
>> + s = prb_reserve(&e, &rb, 32);
>> + if (s) {
>> + sprintf(s, "Hello, world!");
>> + prb_commit(&e);
>> + }
>
> A nit: snprintf().
>
> sprintf() is tricky, it may write "slightly more than was
> anticipated" bytes - all those string_nocheck(" disabled"),
> error_string("pK-error"), etc.
Agreed. Documentation should show good examples.
>> +Sample reader code::
>> +
>> + DECLARE_PRINTKRB_ENTRY(entry, 128);
>> + DECLARE_PRINTKRB_ITER(iter, &test_rb, &entry);
>> + u64 last_seq = 0;
>> + int len;
>> + char *s;
>> +
>> + prb_for_each_entry(&iter, len) {
>> + if (entry.seq - last_seq != 1) {
>> + printf("LOST %llu ENTRIES\n",
>> + entry.seq - (last_seq + 1));
>> + }
>> + last_seq = entry.seq;
>> +
>> + s = (char *)&entry.buffer[0];
>> + if (len >= 128)
>> + s[128 - 1] = 0;
>> + printf("data: %s\n", s);
>> + }
>
> How are we going to handle pr_cont() loops?
>
> print_modules()
> preempt_disable();
> list_for_each_entry_rcu(mod, &modules, list) {
> pr_cont(" %s%s", mod->name, module_flags(mod, buf));
> }
> preempt_enable();
pr_cont() (in its current form) is not related to the printk buffer
because cont messages use their own separate struct cont buffer. And for
the initial integration of the new ringbuffer I would leave that as it
is. Which means initially, pr_cont() would still sit behind a raw
spinlock and pr_cont() from NMI context would be stored as individual
messages.
However, to remove the spinlock of the cont buffer and allow pr_cont()
to work from NMI context, I would like to introduce a separate lockless
ringbuffer instance for cont that contains all the cont pieces
(including the caller_id). As soon as the caller_id changes from the
oldest record in the cont ringbuffer, that caller would assemble the
full cont message, popping all the pieces from the ringbuffer (with a
single cmpxchg) and insert the message to the printk ringbuffer.
John Ogness
Powered by blists - more mailing lists