From: "Jan Beulich" Subject: Re: [PATCHv4 3/5] xen: use ticket locks for spin locks Date: Wed, 13 May 2015 10:31:46 +0100 Message-ID: <555336220200007800079E90@mail.emea.novell.com> References: <1431355025-20468-1-git-send-email-david.vrabel@citrix.com> <1431355025-20468-4-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.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsT13-0005iv-2C for xen-devel@lists.xenproject.org; Wed, 13 May 2015 09:31:49 +0000 In-Reply-To: <1431355025-20468-4-git-send-email-david.vrabel@citrix.com> Content-Disposition: inline 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 , Andrew Cooper , Tim Deegan , Jennifer Herbert , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 11.05.15 at 16:37, 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: Jan Beulich