diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-24 01:33:13 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:41 -0400 |
commit | f6ea2d575d70ab0e1aaa9f9fced1d04e6dd6ef4f (patch) | |
tree | ffb897fe2550908c27f623d8dc91ccea36ef8aa2 /fs/bcachefs/six.c | |
parent | 0bfb9f42b7b16aa11a7b5d283b0b7b98d11476b7 (diff) | |
download | lwn-f6ea2d575d70ab0e1aaa9f9fced1d04e6dd6ef4f.tar.gz lwn-f6ea2d575d70ab0e1aaa9f9fced1d04e6dd6ef4f.zip |
six locks: Add start_time to six_lock_waiter
This is needed by the cycle detector in bcachefs - we need a way to
iterater over waitlist entries while dropping and retaking the waitlist
lock.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/six.c')
-rw-r--r-- | fs/bcachefs/six.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 82e8d77c3082..e2cebd3ba5fe 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -6,6 +6,7 @@ #include <linux/preempt.h> #include <linux/rcupdate.h> #include <linux/sched.h> +#include <linux/sched/clock.h> #include <linux/sched/rt.h> #include <linux/slab.h> @@ -466,6 +467,17 @@ static int __six_lock_type_slowpath(struct six_lock *lock, enum six_lock_type ty raw_spin_lock(&lock->wait_lock); if (!(lock->state.waiters & (1 << type))) set_bit(waitlist_bitnr(type), (unsigned long *) &lock->state.v); + wait->start_time = local_clock(); + + if (!list_empty(&lock->wait_list)) { + struct six_lock_waiter *last = + list_last_entry(&lock->wait_list, + struct six_lock_waiter, list); + + if (time_before_eq64(wait->start_time, last->start_time)) + wait->start_time = last->start_time + 1; + } + list_add_tail(&wait->list, &lock->wait_list); raw_spin_unlock(&lock->wait_lock); @@ -503,6 +515,8 @@ static int __six_lock_type_waiter(struct six_lock *lock, enum six_lock_type type { int ret; + wait->start_time = 0; + if (type != SIX_LOCK_write) six_acquire(&lock->dep_map, 0); |