lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190515115344.oqkei4yzkqxu2uqf@pathway.suse.cz>
Date:   Wed, 15 May 2019 13:53:44 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Daniel Vetter <daniel.vetter@...ll.ch>
Cc:     Intel Graphics Development <intel-gfx@...ts.freedesktop.org>,
        DRI Development <dri-devel@...ts.freedesktop.org>,
        Daniel Vetter <daniel.vetter@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Will Deacon <will.deacon@....com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        John Ogness <john.ogness@...utronix.de>,
        Chris Wilson <chris@...is-wilson.co.uk>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel/locking/semaphore: use wake_q in up()

On Fri 2019-05-10 17:20:15, Daniel Vetter wrote:
> On Fri, May 10, 2019 at 11:28 AM Petr Mladek <pmladek@...e.com> wrote:
> >
> > On Thu 2019-05-09 22:06:33, Daniel Vetter wrote:
> > > console_trylock, called from within printk, can be called from pretty
> > > much anywhere. Including try_to_wake_up. Note that this isn't common,
> > > usually the box is in pretty bad shape at that point already. But it
> > > really doesn't help when then lockdep jumps in and spams the logs,
> > > potentially obscuring the real backtrace we're really interested in.
> > > One case I've seen (slightly simplified backtrace):
> > >
> > > Fix this specific locking recursion by moving the wake_up_process out
> > > from under the semaphore.lock spinlock, using wake_q as recommended by
> > > Peter Zijlstra.
> >
> > It might make sense to mention also the optimization effect mentioned
> > by Peter.
> >
> > > diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
> > > index 561acdd39960..7a6f33715688 100644
> > > --- a/kernel/locking/semaphore.c
> > > +++ b/kernel/locking/semaphore.c
> > > @@ -169,6 +169,14 @@ int down_timeout(struct semaphore *sem, long timeout)
> > >  }
> > >  EXPORT_SYMBOL(down_timeout);
> > >
> > > +/* Functions for the contended case */
> > > +
> > > +struct semaphore_waiter {
> > > +     struct list_head list;
> > > +     struct task_struct *task;
> > > +     bool up;
> > > +};
> > > +
> > >  /**
> > >   * up - release the semaphore
> > >   * @sem: the semaphore to release
> > > @@ -179,24 +187,25 @@ EXPORT_SYMBOL(down_timeout);
> > >  void up(struct semaphore *sem)
> > >  {
> > >       unsigned long flags;
> > > +     struct semaphore_waiter *waiter;
> > > +     DEFINE_WAKE_Q(wake_q);
> >
> > We need to call wake_q_init(&wake_q) to make sure that
> > it is empty.
> 
> DEFINE_WAKE_Q does that already, and if it didn't, I'd wonder how I
> managed to boot with this patch. console_lock is usally terribly
> contented because thanks to fbcon we must do a full display modeset
> while holding it, which takes forever. As long as anyone printks
> meanwhile (guaranteed while loading drivers really) you have
> contention.
> -Daniel

You are right. It is initialized by DEFINE_WAKE_Q.
The patch looks correct to me then:

Reviewed-by: Petr Mladek <pmladek@...e,com>

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ