From: David Vrabel Subject: [PATCHv2 0/6] Use ticket locks for spinlocks Date: Fri, 10 Apr 2015 15:19:51 +0100 Message-ID: <1428675597-28465-1-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 1YgZn3-0005Sq-QJ for xen-devel@lists.xenproject.org; Fri, 10 Apr 2015 14:20:13 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Keir Fraser , Ian Campbell , Stefano Stabellini , Tim Deegan , David Vrabel , Jan Beulich List-Id: xen-devel@lists.xenproject.org Use ticket locks for spin locks instead of the current byte locks. Ticket locks are fair. This is an important property for hypervisor locks. This has the following limitations: - No ARM optimized xadd() implementation. The generic implementation usign cmpxchg is probably sub-optimal. Note that 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. A quick survey of the interrupt disabling spin locks suggests that this should not introduce significant extra interrupt latency (there aren't many such locks and I don't think they're heavily contended) but we are attempting to collect experimental evidence to support this. Performance results (using a earlier prototype) of aggregate network throughput between 20 VIF pairs shows good improvements. http://xenbits.xen.org/people/dvrabel/3336.png This benchmark is limited by contention on the map track lock. Changes in v2: - Reimplemented in C, requiring only an arch-specific xadd() op - Optimize spin_lock_recursive() to call spin_lock() since trylock loops are bad with ticket locks. David