summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2013-09-02lockref: implement lockless reference count updates using cmpxchg()Linus Torvalds
Instead of taking the spinlock, the lockless versions atomically check that the lock is not taken, and do the reference count update using a cmpxchg() loop. This is semantically identical to doing the reference count update protected by the lock, but avoids the "wait for lock" contention that you get when accesses to the reference count are contended. Note that a "lockref" is absolutely _not_ equivalent to an atomic_t. Even when the lockref reference counts are updated atomically with cmpxchg, the fact that they also verify the state of the spinlock means that the lockless updates can never happen while somebody else holds the spinlock. So while "lockref_put_or_lock()" looks a lot like just another name for "atomic_dec_and_lock()", and both optimize to lockless updates, they are fundamentally different: the decrement done by atomic_dec_and_lock() is truly independent of any lock (as long as it doesn't decrement to zero), so a locked region can still see the count change. The lockref structure, in contrast, really is a *locked* reference count. If you hold the spinlock, the reference count will be stable and you can modify the reference count without using atomics, because even the lockless updates will see and respect the state of the lock. In order to enable the cmpxchg lockless code, the architecture needs to do three things: (1) Make sure that the "arch_spinlock_t" and an "unsigned int" can fit in an aligned u64, and have a "cmpxchg()" implementation that works on such a u64 data type. (2) define a helper function to test for a spinlock being unlocked ("arch_spin_value_unlocked()") (3) select the "ARCH_USE_CMPXCHG_LOCKREF" config variable in its Kconfig file. This enables it for x86-64 (but not 32-bit, we'd need to make sure cmpxchg() turns into the proper cmpxchg8b in order to enable it for 32-bit mode). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-02lockref: uninline lockref helper functionsLinus Torvalds
They aren't very good to inline, since they already call external functions (the spinlock code), and we're going to create rather more complicated versions of them that can do the reference count updates locklessly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-02vfs: reimplement d_rcu_to_refcount() using lockref_get_or_lock()Linus Torvalds
This moves __d_rcu_to_refcount() from <linux/dcache.h> into fs/namei.c and re-implements it using the lockref infrastructure instead. It also adds a lot of comments about what is actually going on, because turning a dentry that was looked up using RCU into a long-lived reference counted entry is one of the more subtle parts of the rcu walk. We also used to be _particularly_ subtle in unlazy_walk() where we re-validate both the dentry and its parent using the same sequence count. We used to do it by nesting the locks and then verifying the sequence count just once. That was silly, because nested locking is expensive, but the sequence count check is not. So this just re-validates the dentry and the parent separately, avoiding the nested locking, and making the lockref lookup possible. Acked-by: Waiman Long <waiman.long@hp.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-02vfs: use lockref_get_not_zero() for optimistic lockless dget_parent()Waiman Long
A valid parent pointer is always going to have a non-zero reference count, but if we look up the parent optimistically without locking, we have to protect against the (very unlikely) race against renaming changing the parent from under us. We do that by using lockref_get_not_zero(), and then re-checking the parent pointer after getting a valid reference. [ This is a re-implementation of a chunk from the original patch by Waiman Long: "dcache: Enable lockless update of dentry's refcount". I've completely rewritten the patch-series and split it up, but I'm attributing this part to Waiman as it's close enough to his earlier patch - Linus ] Signed-off-by: Waiman Long <Waiman.Long@hp.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-02lockref: add 'lockref_get_or_lock() helperLinus Torvalds
This behaves like "lockref_get_not_zero()", but instead of doing nothing if the count was zero, it returns with the lock held. This allows callers to revalidate the lockref-protected data structure if required even if the count was zero to begin with, and possibly increment the count if it passes muster. In particular, the dentry code wants this when it wants to turn an RCU-protected dentry into a stable refcounted one: if the dentry count it zero, but the sequence number still validates the dentry, we can take a reference to it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-09-02Merge tag 'scsi-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi Pull SCSI fix from James Bottomley: "This is a bug fix for the pm80xx driver. It turns out that when the new hardware support was added in 3.10 the IO command size was kept at the old hard coded value. This means that the driver attaches to some new cards and then simply hangs the system" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: [SCSI] pm80xx: fix Adaptec 71605H hang
2013-09-02Merge branch 'x86-urgent-for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull x86 boot fix from Peter Anvin: "A single very small boot fix for very large memory systems (> 0.5T)" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: Fix boot crash with DEBUG_PAGE_ALLOC=y and more than 512G RAM
2013-09-02Merge branch 'fixes' of git://git.infradead.org/users/vkoul/slave-dmaLinus Torvalds
Pull slave-dma fix from Vinod Koul: "A fix for resolving TI_EDMA driver's build error in allmodconfig to have filter function built in"" * 'fixes' of git://git.infradead.org/users/vkoul/slave-dma: dma/Kconfig: TI_EDMA needs to be boolean
2013-09-01Merge remote-tracking branch 'regulator/topic/tps65912' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/ti-abb' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/sec' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/ramp' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/pfuze100' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/palmas' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/optional' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/max8660' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/lp8755' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/lp872x' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/linear-range' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/kconfig' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/helpers' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/fan53555' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/da9063' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/core' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/as3711' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'regulator/topic/88pm800' into regulator-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/txx9' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/topcliff' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/tle62x0' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/tel62x0' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/tegra' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/sirf' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/sh-msiof' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/sh-hspi' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/s3c64xx' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/rspi' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/quad' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/qspi' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/pxa' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/pl022' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/pdata' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/orion' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/omap-100k' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/octeon' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/nuc900' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/mxs' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/msglen' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/mpc512x' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/ioremap' into spi-nextMark Brown
2013-09-01Merge remote-tracking branch 'spi/topic/imx' into spi-nextMark Brown