Skip to content

Use ticket locks for spinlocks

David Vrabel xen-devel 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest3 patches 6 repliesIn review
  2. v50 of 5 patches 0 repliesSuperseded
  3. v48 patches 12 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v34 patches31 repliesSuperseded
v26 patches37 repliesSuperseded

Changes in v6 from the cover letter

- Check sample.head in _spin_barrier().
- Improve comments.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xen: use ticket locks for spin locksxen/common/spinlock.c xen/include/asm-arm/system.h xen/include/asm-x86/system.h +1 more+92 -547 replies
2/3x86, arm: remove asm/spinlock.h from all architecturesxen/arch/arm/README.LinuxPrimitives xen/include/asm-arm/arm32/spinlock.h xen/include/asm-arm/arm64/spinlock.h +3 more+0 -2180 replies
3/3x86: reduce struct hvm_domain sizexen/include/asm-x86/hvm/domain.h+6 -60 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchTim DeeganJan BeulichIan Campbell
1/3R-b
2/3R-b A-b A-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCHv6 0/3] Use ticket locks for spinlocks

Use ticket locks for spin locks instead of the current byte locks. Ticket locks are fair. This is an important property for hypervisor locks.

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.

We have analysed the affect of this series on interrupt latency (by measuring the duration of irq disable/enable regions) and there is no signficant impact.

http://xenbits.xen.org/people/dvrabel/ticket-locks/busy_comp.png

Thanks to Jennifer Herbert for performing this analysis.

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 v6:
- Check sample.head in _spin_barrier().
- Improve comments.

Changes in v5:
- _spin_barrier() fixes (re-add smp_mb(), profiling, cpu_relax()).
- Cleanup x86 add_sized().

Changes in v4:
- Use new add_sized() to increment ticket head.
- Add arch_lock_acquire_barrier() and arch_lock_release_barrier().
- Rename xadd() to arch_fetch_and_add().
- Shrink struct domain by 16 bytes.

Changes in v3:
- xadd() implementation for arm32 and arm64.
- Add barriers required on arm.
- Only wait for the current lock holder in _spin_barrier().

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