Re: [PATCH v3] printk: Add console owner and waiter logic to loadbalance console writes
From: Tetsuo Handa
Date: Sat Nov 04 2017 - 04:44:30 EST
Tetsuo Handa wrote:
> John Hubbard wrote:
> > On 11/03/2017 02:46 PM, John Hubbard wrote:
> > > On 11/03/2017 04:54 AM, Steven Rostedt wrote:
> > >> On Fri, 3 Nov 2017 07:21:21 -0400
> > >> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > [...]
> > >>
> > >> I'll condense the patch to show what I mean:
> > >>
> > >> To become a waiter, a task must do the following:
> > >>
> > >> + printk_safe_enter_irqsave(flags);
> > >> +
> > >> + raw_spin_lock(&console_owner_lock);
> > >> + owner = READ_ONCE(console_owner);
> > >> + waiter = READ_ONCE(console_waiter);
>
> When CPU0 is writing to consoles after "console_owner = current;",
> what prevents from CPU1 and CPU2 concurrently reached this line from
> seeing waiter == false && owner != NULL && owner != current (which will
> concurrently set console_waiter = true and spin = true) without
> using atomic instructions?
Oops. I overlooked that console_owner_lock is held.