summaryrefslogtreecommitdiff
path: root/include/linux/six.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-08-25 10:49:52 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-10-03 23:54:35 -0400
commit0b79a2ce71118dca11ff8d06e0b490eb7028044f (patch)
tree98e5ed44833c6feb61d0c3ae2bd80a7d33137ddf /include/linux/six.h
parentac4f9d6d2a926f34a4ae3aa4d39d5e9bb51d6f9d (diff)
six locks: Simplify wait lists
This switches to a single list of waiters, instead of separate lists for read and intent, and switches write locks to also use the wait lists instead of being handled differently. Also, removal from the wait list is now done by the process waiting on the lock, not the process doing the wakeup. This is needed for the new deadlock cycle detector - we need tasks to stay on the waitlist until they've successfully acquired the lock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/six.h')
-rw-r--r--include/linux/six.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/linux/six.h b/include/linux/six.h
index 6cec7ecdd156..313154a7927a 100644
--- a/include/linux/six.h
+++ b/include/linux/six.h
@@ -111,12 +111,18 @@ struct six_lock {
unsigned __percpu *readers;
raw_spinlock_t wait_lock;
- struct list_head wait_list[2];
+ struct list_head wait_list;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
};
+struct six_lock_waiter {
+ struct list_head list;
+ struct task_struct *task;
+ enum six_lock_type lock_want;
+};
+
typedef int (*six_lock_should_sleep_fn)(struct six_lock *lock, void *);
static __always_inline void __six_lock_init(struct six_lock *lock,
@@ -125,8 +131,7 @@ static __always_inline void __six_lock_init(struct six_lock *lock,
{
atomic64_set(&lock->state.counter, 0);
raw_spin_lock_init(&lock->wait_lock);
- INIT_LIST_HEAD(&lock->wait_list[SIX_LOCK_read]);
- INIT_LIST_HEAD(&lock->wait_list[SIX_LOCK_intent]);
+ INIT_LIST_HEAD(&lock->wait_list);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
debug_check_no_locks_freed((void *) lock, sizeof(*lock));
lockdep_init_map(&lock->dep_map, name, key, 0);