login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2007
»
March
»
23
Re: [rfc][patch] queued spinlocks (i386)
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Ravikiran G Thirumalai
Subject:
Re: [rfc][patch] queued spinlocks (i386)
Date: Friday, March 23, 2007 - 12:27 pm
On Fri, Mar 23, 2007 at 10:40:17AM +0100, Eric Dumazet wrote:
quoted text
> On Fri, 23 Mar 2007 09:59:11 +0100 > Nick Piggin <npiggin@suse.de> wrote: > > > > > Implement queued spinlocks for i386. This shouldn't increase the size of > > the spinlock structure, while still able to handle 2^16 CPUs. > > > > Not completely implemented with assembly yet, to make the algorithm a bit > > clearer. > > > > The queued spinlock has 2 fields, a head and a tail, which are indexes > > into a FIFO of waiting CPUs. To take a spinlock, a CPU performs an > > "atomic_inc_return" on the head index, and keeps the returned value as > > a ticket. The CPU then spins until the tail index is equal to that > > ticket. > > > > To unlock a spinlock, the tail index is incremented (this can be non > > atomic, because only the lock owner will modify tail). > > > > Implementation inefficiencies aside, this change should have little > > effect on performance for uncontended locks, but will have quite a > > large cost for highly contended locks [O(N) cacheline transfers vs > > O(1) per lock aquisition, where N is the number of CPUs contending]. > > The benefit is is that contended locks will not cause any starvation. > > > > Just an idea. Big NUMA hardware seems to have fairness logic that > > prevents starvation for the regular spinlock logic. But it might be > > interesting for -rt kernel or systems with starvation issues. > > It's a very nice idea Nick.
Amen to that.
quoted text
> > You also have for free the number or cpus that are before you. > > On big SMP/NUMA, we could use this information to call a special lock_cpu_relax() function to avoid cacheline transferts. > > asm volatile(LOCK_PREFIX "xaddw %0, %1\n\t" > : "+r" (pos), "+m" (lock->qhead) : : "memory"); > for (;;) { > unsigned short nwait = pos - lock->qtail; > if (likely(nwait == 0)) > break; > lock_cpu_relax(lock, nwait); > } > > lock_cpu_relax(raw_spinlock_t *lock, unsigned int nwait) > { > unsigned int cycles = nwait * lock->min_cycles_per_round; > busy_loop(cycles); > }
Good Idea. Hopefully, this should reduce the number of cacheline transfers in the contended case. -
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Fri Mar 23, 1:59 am)
Re: [rfc][patch] queued spinlocks (i386)
, Eric Dumazet
, (Fri Mar 23, 2:40 am)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Fri Mar 23, 2:59 am)
Re: [rfc][patch] queued spinlocks (i386)
, Ingo Molnar
, (Fri Mar 23, 3:04 am)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Fri Mar 23, 3:10 am)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Fri Mar 23, 3:32 am)
Re: [rfc][patch] queued spinlocks (i386)
, Eric Dumazet
, (Fri Mar 23, 3:40 am)
Re: [rfc][patch] queued spinlocks (i386)
, William Lee Irwin III
, (Fri Mar 23, 4:02 am)
Re: [rfc][patch] queued spinlocks (i386)
, Davide Libenzi
, (Fri Mar 23, 11:15 am)
Re: [rfc][patch] queued spinlocks (i386)
, Ravikiran G Thirumalai
, (Fri Mar 23, 12:27 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nikita Danilov
, (Sat Mar 24, 8:55 am)
Re: [rfc][patch] queued spinlocks (i386)
, Ingo Molnar
, (Sat Mar 24, 10:29 am)
Re: [rfc][patch] queued spinlocks (i386)
, Nikita Danilov
, (Sat Mar 24, 11:49 am)
Re: [rfc][patch] queued spinlocks (i386)
, Andrew Morton
, (Sat Mar 24, 2:41 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Tue Mar 27, 11:43 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Tue Mar 27, 11:56 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Davide Libenzi
, (Wed Mar 28, 12:26 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Davide Libenzi
, (Wed Mar 28, 3:00 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Wed Mar 28, 6:24 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Wed Mar 28, 6:36 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Thu Mar 29, 12:16 am)
Re: [rfc][patch] queued spinlocks (i386)
, Davide Libenzi
, (Thu Mar 29, 5:27 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Nick Piggin
, (Thu Mar 29, 6:59 pm)
Re: [rfc][patch] queued spinlocks (i386)
, Davide Libenzi
, (Thu Mar 29, 7:43 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Rusty Russell
Re: 2.6.22-rc3-mm1
Gautham R Shenoy
[PATCH 1/8] Enhance process freezer interface for usage beyond software suspend
Jeffrey V. Merkey
Re: Versioning file system
James Bottomley
Re: [PATCH -mm 1/2] scsi: remove dma_is_consistent usage in 53c700
David Miller
Re: NO_HZ: timer interrupt stuck
git
:
Oliver Kullmann
Re: how to move with history?
Junio C Hamano
Re: [PATCH 2/3] git-add--interactive: remove hunk coalescing
Miles Bader
Re: way to automatically add untracked files?
Harvey Harrison
Re: [SoC RFC] libsvn-fs-git: A git backend for the subversion filesystem
Alex Riesen
Re: git exclude patterns for directory
git-commits-head
:
Linux Kernel Mailing List
V4L/DVB: tm6000: add special usb request to quit i2c tuner transfer
Linux Kernel Mailing List
OMAP: DSS2: SDI driver
Linux Kernel Mailing List
PCI: introduce pci_pcie_cap()
Linux Kernel Mailing List
netfilter: nf_conntrack_sip: add T.38 FAX support
Linux Kernel Mailing List
drivers/acpi: use kasprintf
linux-netdev
:
Timo Teräs
ip xfrm policy semantics
David Miller
Re: [2.6.30-rc3] powerpc: compilation error of mace module
Patrick McHardy
Re: [rfc 02/13] [RFC 02/13] netfilter: nf_conntrack_sip: Add callid parser
webmaster Maintenance
&#32852;&#31995;&#31995;&#32479;&#31649;&#29702;&#21592;
Krzysztof Oledzki
Re: Error: an inet prefix is expected rather than "0/0".
openbsd-misc
:
Ted Bullock
Re: Proliant DL380 G3 cannot get on network
Úlfar M. E. Johnson
installing openbsd in xen
Eric Furman
Re: Defending OpenBSD Performance
Damien Miller
Re: Patching a SSH 'Weakness'
frantisek holop
Re: mount ffs as msdos, system hangs
Colocation donated by:
Syndicate