Thread (13 messages) 13 messages, 4 authors, 2019-02-11

Re: [PATCH] locking/rwsem: Remove arch specific rwsem files

From: Peter Zijlstra <peterz@infradead.org>
Date: 2019-02-11 10:57:55
Also in: linux-alpha, linux-arch, linux-arm-kernel, linux-sh, lkml, sparclinux

On Mon, Feb 11, 2019 at 10:40:44AM +0100, Peter Zijlstra wrote:
On Mon, Feb 11, 2019 at 10:36:01AM +0100, Peter Zijlstra wrote:
quoted
On Sun, Feb 10, 2019 at 09:00:50PM -0500, Waiman Long wrote:
quoted
+static inline int __down_read_trylock(struct rw_semaphore *sem)
+{
+	long tmp;
+
+	while ((tmp = atomic_long_read(&sem->count)) >= 0) {
+		if (tmp == atomic_long_cmpxchg_acquire(&sem->count, tmp,
+				   tmp + RWSEM_ACTIVE_READ_BIAS)) {
+			return 1;
That really wants to be:

		if (atomic_long_try_cmpxchg_acquire(&sem->count, &tmp,
						    tmp + RWSEM_ACTIVE_READ_BIAS))
quoted
+		}
+	}
+	return 0;
+}
Also, the is the one case where LL/SC can actually do 'better'. Do you
have benchmarks for say PowerPC or ARM64 ?
Ah, I see they already used asm-generic/rwsem.h which has similar code
to the above.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help