Re: [PATCH v5 2/2] printk: Hide console waiter logic into helpers

From: Steven Rostedt
Date: Fri Jan 12 2018 - 10:38:03 EST


On Thu, 11 Jan 2018 13:03:41 +0100
Petr Mladek <pmladek@xxxxxxxx> wrote:

> > > +static DEFINE_RAW_SPINLOCK(console_owner_lock);
> > > +static struct task_struct *console_owner;
> > > +static bool console_waiter;
> > > +
> > > +/**
> > > + * console_lock_spinning_enable - mark beginning of code where another
> > > + * thread might safely busy wait
> > > + *
> > > + * This might be called in sections where the current console_lock owner
> >
> >
> > "might be"? It has to be called in sections where the current
> > console_lock owner can not sleep. It's basically saying "console lock is
> > now acting like a spinlock".
>
> I am afraid that both explanations are confusing. Your one sounds like
> it must be called every time we enter non-preemptive context in
> console_unlock. What about the following?
>
> * This is basically saying that "console lock is now acting like
> * a spinlock". It can be called _only_ in sections where the current
> * console_lock owner could not sleep. Also it must be ready to hand
> * over the lock at the end of the section.

I would reword the above:

* This basically converts console_lock into a spinlock. This marks
* the section where the console_lock owner can not sleep, because
* there may be a waiter spinning (like a spinlock). Also it must be
* ready to hand over the lock at the end of the section.

>
> > > + * cannot sleep. It is a signal that another thread might start busy
> > > + * waiting for console_lock.
> > > + */
>
> All the other changes look good to me. I will use them in the next version.

Great.

-- Steve