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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANDhNCrN6o=_uKN4xK2uFfsKBQuhq7Rz82jgBss4LSWgK-OpqQ@mail.gmail.com>
Date:   Tue, 22 Aug 2023 12:24:56 -0700
From:   John Stultz <jstultz@...gle.com>
To:     Waiman Long <longman@...hat.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Joel Fernandes <joelaf@...gle.com>,
        Qais Yousef <qyousef@...gle.com>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Valentin Schneider <vschneid@...hat.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>,
        Zimuzo Ezeozue <zezeozue@...gle.com>,
        Youssef Esmat <youssefesmat@...gle.com>,
        Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Will Deacon <will@...nel.org>,
        Boqun Feng <boqun.feng@...il.com>,
        "Paul E . McKenney" <paulmck@...nel.org>, kernel-team@...roid.com
Subject: Re: [PATCH v5 02/19] locking/mutex: Removes wakeups from under mutex::wait_lock

On Tue, Aug 22, 2023 at 12:11 PM Waiman Long <longman@...hat.com> wrote:
> On 8/19/23 02:08, John Stultz wrote:
> > @@ -676,6 +677,10 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
> >               }
> >
> >               raw_spin_unlock(&lock->wait_lock);
> > +             /* Make sure we do wakeups before calling schedule */
> > +             wake_up_q(&wake_q);
> > +             wake_q_init(&wake_q);
> > +
>
> The wake_q may have task to wake up only in the case of ww_mutex which
> is a minority in the kernel. IOW, wake_up_q() which is a function call
> will do nothing in most cases. From an optimization point of view, it is
> better to do a "!wake_q_empty(&wake_q)" check before calling wake_up_q().

Thanks for the suggestion!  Updated for the next version!

> > @@ -946,9 +953,11 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
> >       if (owner & MUTEX_FLAG_HANDOFF)
> >               __mutex_handoff(lock, next);
> >
> > +     preempt_disable();
> >       raw_spin_unlock(&lock->wait_lock);
> >
> >       wake_up_q(&wake_q);
> > +     preempt_enable();
> >   }
>
> I think it looks better to put the preempt_disable() right before
> raw_spin_lock() for proper nesting.

Agreed.

Thanks so much for the review and feedback! I really appreciate it!
-john

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ