From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755496AbcETHx0 (ORCPT ); Fri, 20 May 2016 03:53:26 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:51699 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754231AbcETHxZ (ORCPT ); Fri, 20 May 2016 03:53:25 -0400 Date: Fri, 20 May 2016 09:53:18 +0200 From: Peter Zijlstra To: Davidlohr Bueso Cc: manfred@colorfullife.com, Waiman.Long@hpe.com, mingo@kernel.org, torvalds@linux-foundation.org, ggherdovich@suse.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org Subject: Re: sem_lock() vs qspinlocks Message-ID: <20160520075318.GB3193@twins.programming.kicks-ass.net> References: <20160520053926.GC31084@linux-uzut.site> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160520053926.GC31084@linux-uzut.site> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2016 at 10:39:26PM -0700, Davidlohr Bueso wrote: > However, this is semantically different to > what was previously done with ticket locks in that spin_unlock_wait() will always observe > all waiters by adding itself to the tail. static inline void arch_spin_unlock_wait(arch_spinlock_t *lock) { __ticket_t head = READ_ONCE(lock->tickets.head); for (;;) { struct __raw_tickets tmp = READ_ONCE(lock->tickets); /* * We need to check "unlocked" in a loop, tmp.head == head * can be false positive because of overflow. */ if (__tickets_equal(tmp.head, tmp.tail) || !__tickets_equal(tmp.head, head)) break; cpu_relax(); } } I'm not seeing that (although I think I agreed yesterday on IRC). Note how we observe the head and then loop until either the lock is unlocked (head == tail) or simply head isn't what it used to be. And head is the lock holder end of the queue; see arch_spin_unlock() incrementing it. So the ticket lock too should only wait for the current lock holder to go away, not any longer.