lkml.org 
[lkml]   [2023]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH printk v4 7/8] printk: use printk_buffers for devkmsg
Date
On 2023-01-05, John Ogness <john.ogness@linutronix.de> wrote:
> /* /dev/kmsg - userspace message inject/listen interface */
> struct devkmsg_user {
> atomic64_t seq;
> struct ratelimit_state rs;
> struct mutex lock;
> - char buf[CONSOLE_EXT_LOG_MAX];
>
> + struct printk_buffers pbufs;
> struct printk_info info;
> - char text_buf[CONSOLE_EXT_LOG_MAX];
> struct printk_record record;
> };

There is also no need for the printk_info and printk_record
structs. printk_get_next_message() uses its own on the stack.

> @@ -797,7 +801,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
> if (ret)
> return ret;
>
> - if (!prb_read_valid(prb, atomic64_read(&user->seq), r)) {
> + if (!printk_get_next_message(&pmsg, atomic64_read(&user->seq), true)) {

This needs to be a while loop because printk_get_next_message() should
be the only function reading from the ringbuffer. The
wait_event_interruptible() in this loop should just wait for the
existence of the new record. It should not be the one reading it.

I will reply to this message with the correct patch to replace this
patch.

John Ogness

\
 
 \ /
  Last update: 2023-03-26 23:28    [W:0.121 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site