Re: [PATCH printk v4 7/8 v2] printk: use printk_buffers for devkmsg

From: John Ogness
Date: Sun Jan 08 2023 - 16:12:16 EST


On 2023-01-06, Petr Mladek <pmladek@xxxxxxxx> wrote:
>> - if (!prb_read_valid(prb, atomic64_read(&user->seq), r)) {
>> + while (!printk_get_next_message(&pmsg, atomic64_read(&user->seq), true)) {
>
> A problem is that printk_get_next_message() does not format the
> message when it shoud get supressed on the console.

Nice catch. I missed that.

> I would solve it be adding a parameter to printk_get_next_message()
> that will tell whether to suppress or not, e.g. @can_suppress.

OK.

>> if (file->f_flags & O_NONBLOCK) {
>> ret = -EAGAIN;
>> goto out;
>> @@ -814,36 +814,31 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
>> * This pairs with __wake_up_klogd:A.
>> */
>> ret = wait_event_interruptible(log_wait,
>> - prb_read_valid(prb,
>> - atomic64_read(&user->seq), r)); /* LMM(devkmsg_read:A) */
>> + prb_read_valid(prb, atomic64_read(&user->seq),
>> + NULL)); /* LMM(devkmsg_read:A) */
>
> The above change from "if" to "while" could be avoided if we use
> printk_get_next_message() here as well. It looks slightly more
> strightfoward to me.

Yes, that is better. A loop is overkill here.

John