Re: [PATCH v2] printk: Add console owner and waiter logic to load balance console writes

From: Steven Rostedt
Date: Fri Nov 03 2017 - 07:18:34 EST


On Fri, 3 Nov 2017 11:19:53 +0100
Jan Kara <jack@xxxxxxx> wrote:

> Hi,
>
> On Thu 02-11-17 13:06:05, Steven Rostedt wrote:
> > + if (spin) {
> > + /* We spin waiting for the owner to release us */
> > + spin_acquire(&console_owner_dep_map, 0, 0, _THIS_IP_);
> > + /* Owner will clear console_waiter on hand off */
> > + while (!READ_ONCE(console_waiter))
> > + cpu_relax();
>
> Hum, what prevents us from rescheduling here? And what if the process
> stored in console_owner is scheduled out? Both seem to be possible with
> CONFIG_PREEMPT kernel? Unless I'm missing something you will need to
> disable preemption in some places...

Yes you are missing something ;-)

>
> Other than that I like the simplicity of your approach.
>
> Honza
>
> > +
> > + spin_release(&console_owner_dep_map, 1, _THIS_IP_);
> > + printk_safe_exit_irqrestore(flags);

The above line re-enables interrupts. And is done for both the
console_owner and the console_waiter. These are only held with
interrupts disabled. Nothing will preempt it. In fact, if it could,
lockdep would complain (it did in when I screwed it up at first ;-)


-- Steve