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: <20190604090309.GG3402@hirez.programming.kicks-ass.net>
Date:   Tue, 4 Jun 2019 11:03:09 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Waiman Long <longman@...hat.com>
Cc:     Ingo Molnar <mingo@...hat.com>, Will Deacon <will.deacon@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
        x86@...nel.org, Davidlohr Bueso <dave@...olabs.net>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        huang ying <huang.ying.caritas@...il.com>
Subject: Re: [PATCH v8 14/19] locking/rwsem: Enable time-based spinning on
 reader-owned rwsem

On Mon, May 20, 2019 at 04:59:13PM -0400, Waiman Long wrote:
> +static inline void rwsem_set_nonspinnable(struct rw_semaphore *sem)
> +{
> +	long owner = atomic_long_read(&sem->owner);
> +
> +	while (owner & RWSEM_READER_OWNED) {
> +		if (owner & RWSEM_NONSPINNABLE)
> +			break;
> +		owner = atomic_long_cmpxchg(&sem->owner, owner,
> +					    owner | RWSEM_NONSPINNABLE);
> +	}
> +}

--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -206,12 +206,13 @@ static inline void rwsem_set_nonspinnabl
 {
 	long owner = atomic_long_read(&sem->owner);
 
-	while (owner & RWSEM_READER_OWNED) {
+	do {
+		if (!(owner & RWSEM_READER_OWNED))
+			break;
 		if (owner & RWSEM_NONSPINNABLE)
 			break;
-		owner = atomic_long_cmpxchg(&sem->owner, owner,
-					    owner | RWSEM_NONSPINNABLE);
-	}
+	} while (!atomic_long_try_cmpxchg(&sem->owner, &owner,
+					  owner | RWSEM_NONSPINNABLE));
 }
 
 /*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ