forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bit_spinlocks are horrible on RT because there's absolutely nowhere to put the mutex to sleep on. They also do not participate in lockdep because there's nowhere to put the map. Most (all?) bit spinlocks are actually a split lock; logically they could be treated as a single spinlock, but for performance, we want to split the lock over many objects. Introduce the split_lock as somewhere to store the lockdep map and as somewhere that the RT kernel can put a mutex. It may also let us store a ticket lock for better performance on non-RT kernels in the future, but I have left the current cpu_relax() implementation intact for now. The API change breaks all users except for the two which have been converted. This is an RFC, and I'm willing to fix all the rest. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
- Loading branch information
1 parent
5e46d1b
commit 31f9627
Showing
5 changed files
with
84 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef _LINUX_SPLIT_LOCK_H | ||
#define _LINUX_SPLIT_LOCK_H | ||
|
||
#include <linux/lockdep_types.h> | ||
|
||
struct split_lock { | ||
#ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
struct lockdep_map dep_map; | ||
#endif | ||
}; | ||
|
||
#ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
#define SPLIT_DEP_MAP_INIT(lockname) \ | ||
.dep_map = { \ | ||
.name = #lockname, \ | ||
.wait_type_inner = LD_WAIT_SPIN, \ | ||
} | ||
#else | ||
#define SPLIT_DEP_MAP_INIT(lockname) | ||
#endif | ||
|
||
#define DEFINE_SPLIT_LOCK(name) \ | ||
struct split_lock name = { \ | ||
SPLIT_DEP_MAP_INIT(name) \ | ||
}; | ||
|
||
/* | ||
* This is only called if we're contended. We use a non-atomic test | ||
* to reduce contention on the cacheline while we wait. | ||
*/ | ||
static inline void split_lock_spin(struct split_lock *lock, int bitnum, | ||
unsigned long *addr) | ||
{ | ||
preempt_enable(); | ||
do { | ||
cpu_relax(); | ||
} while (test_bit(bitnum, addr)); | ||
preempt_disable(); | ||
} | ||
|
||
static inline void split_lock_unlock(struct split_lock *lock, int bitnum, | ||
unsigned long *addr) | ||
{ | ||
} | ||
#endif /* _LINUX_SPLIT_LOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters