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]
Date:   Fri, 19 Aug 2016 21:33:15 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Waiman Long <waiman.long@....com>
Cc:     Jason Low <jason.low2@....com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Ding Tianhong <dingtianhong@...wei.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Will Deacon <Will.Deacon@....com>,
        Ingo Molnar <mingo@...hat.com>, imre.deak@...el.com,
        linux-kernel@...r.kernel.org, Davidlohr Bueso <dave@...olabs.net>,
        Tim Chen <tim.c.chen@...ux.intel.com>, terry.rudd@....com,
        "Paul E. McKenney" <paulmck@...ibm.com>, jason.low2@...com
Subject: Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning
 is disabled


Please trim your emails..

On Fri, Aug 19, 2016 at 12:57:06PM -0400, Waiman Long wrote:

> >+static inline bool __mutex_trylock_pending(struct mutex *lock)
> >+{
> >+	return atomic_read(&lock->count)>= 0&&
> >+	       atomic_xchg_acquire(&lock->count, -1) == 1;
> >+}
> >+
> 
> Maybe you can make a more general __mutex_trylock function that is used in
> all three trylock attempts in the slowpath. For example,
> 
> static inline bool __mutex_trylock(struct mutex *lock, bool waiter)
> {
>     if (waiter) {
>         return atomic_read(&lock->count) >= 0 &&
>                atomic_xchg_acquire(&lock->count, -1) == 1;
>     } else {
>         return !need_yield_to_waiter(lock) &&
>                !mutex_is_locked(lock) &&
>                ((atomic_xchg_acquire(&lock->count, 0) == 1);
>     }
> }

That seems more messy to me..

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ