From: Tim Deegan Subject: Re: [PATCHv6 1/3] xen: use ticket locks for spin locks Date: Thu, 14 May 2015 12:33:08 +0100 Message-ID: <20150514113308.GG81528@deinos.phlegethon.org> References: <1431602502-22327-1-git-send-email-david.vrabel@citrix.com> <1431602502-22327-2-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsrO3-0006ia-9h for xen-devel@lists.xenproject.org; Thu, 14 May 2015 11:33:11 +0000 Content-Disposition: inline In-Reply-To: <1431602502-22327-2-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: Keir Fraser , Ian Campbell , Stefano Stabellini , Andrew Cooper , Jennifer Herbert , Jan Beulich , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org At 12:21 +0100 on 14 May (1431606100), David Vrabel wrote: > Replace the byte locks with ticket locks. Ticket locks are: a) fair; > and b) peform better when contented since they spin without an atomic > operation. > > The lock is split into two ticket values: head and tail. A locker > acquires a ticket by (atomically) increasing tail and using the > previous tail value. A CPU holds the lock if its ticket == head. The > lock is released by increasing head. > > spin_lock_irq() and spin_lock_irqsave() now spin with irqs disabled > (previously, they would spin with irqs enabled if possible). This is > required to prevent deadlocks when the irq handler tries to take the > same lock with a higher ticket. > > Architectures need only provide arch_fetch_and_add() and two barriers: > arch_lock_acquire_barrier() and arch_lock_release_barrier(). > > Signed-off-by: David Vrabel Reviewed-by: Tim Deegan