diff options
Diffstat (limited to 'linux/six.c')
-rw-r--r-- | linux/six.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/linux/six.c b/linux/six.c index 5b81c3fc..0b9c4bb7 100644 --- a/linux/six.c +++ b/linux/six.c @@ -47,26 +47,26 @@ struct six_lock_vals { enum six_lock_type unlock_wakeup; }; -#define LOCK_VALS { \ - [SIX_LOCK_read] = { \ - .lock_val = 1U << SIX_LOCK_HELD_read_OFFSET, \ - .lock_fail = SIX_LOCK_HELD_write, \ - .held_mask = SIX_LOCK_HELD_read, \ - .unlock_wakeup = SIX_LOCK_write, \ - }, \ - [SIX_LOCK_intent] = { \ - .lock_val = SIX_LOCK_HELD_intent, \ - .lock_fail = SIX_LOCK_HELD_intent, \ - .held_mask = SIX_LOCK_HELD_intent, \ - .unlock_wakeup = SIX_LOCK_intent, \ - }, \ - [SIX_LOCK_write] = { \ - .lock_val = SIX_LOCK_HELD_write, \ - .lock_fail = SIX_LOCK_HELD_read, \ - .held_mask = SIX_LOCK_HELD_write, \ - .unlock_wakeup = SIX_LOCK_read, \ - }, \ -} +static const struct six_lock_vals l[] = { + [SIX_LOCK_read] = { + .lock_val = 1U << SIX_LOCK_HELD_read_OFFSET, + .lock_fail = SIX_LOCK_HELD_write, + .held_mask = SIX_LOCK_HELD_read, + .unlock_wakeup = SIX_LOCK_write, + }, + [SIX_LOCK_intent] = { + .lock_val = SIX_LOCK_HELD_intent, + .lock_fail = SIX_LOCK_HELD_intent, + .held_mask = SIX_LOCK_HELD_intent, + .unlock_wakeup = SIX_LOCK_intent, + }, + [SIX_LOCK_write] = { + .lock_val = SIX_LOCK_HELD_write, + .lock_fail = SIX_LOCK_HELD_read, + .held_mask = SIX_LOCK_HELD_write, + .unlock_wakeup = SIX_LOCK_read, + }, +}; static inline void six_set_bitmask(struct six_lock *lock, u32 mask) { @@ -116,7 +116,6 @@ static inline unsigned pcpu_read_count(struct six_lock *lock) static int __do_six_trylock(struct six_lock *lock, enum six_lock_type type, struct task_struct *task, bool try) { - const struct six_lock_vals l[] = LOCK_VALS; int ret; u32 old; @@ -301,10 +300,10 @@ EXPORT_SYMBOL_GPL(six_trylock_ip); bool six_relock_ip(struct six_lock *lock, enum six_lock_type type, unsigned seq, unsigned long ip) { - if (lock->seq != seq || !six_trylock_ip(lock, type, ip)) + if (six_lock_seq(lock) != seq || !six_trylock_ip(lock, type, ip)) return false; - if (lock->seq != seq) { + if (six_lock_seq(lock) != seq) { six_unlock_ip(lock, type, ip); return false; } @@ -588,7 +587,6 @@ EXPORT_SYMBOL_GPL(six_lock_ip_waiter); __always_inline static void do_six_unlock_type(struct six_lock *lock, enum six_lock_type type) { - const struct six_lock_vals l[] = LOCK_VALS; u32 state; if (type == SIX_LOCK_intent) @@ -638,6 +636,8 @@ void six_unlock_ip(struct six_lock *lock, enum six_lock_type type, unsigned long if (type != SIX_LOCK_write) six_release(&lock->dep_map, ip); + else + lock->seq++; if (type == SIX_LOCK_intent && lock->intent_lock_recurse) { @@ -645,8 +645,6 @@ void six_unlock_ip(struct six_lock *lock, enum six_lock_type type, unsigned long return; } - lock->seq += type == SIX_LOCK_write; - do_six_unlock_type(lock, type); } EXPORT_SYMBOL_GPL(six_unlock_ip); @@ -675,7 +673,6 @@ EXPORT_SYMBOL_GPL(six_lock_downgrade); */ bool six_lock_tryupgrade(struct six_lock *lock) { - const struct six_lock_vals l[] = LOCK_VALS; u32 old = atomic_read(&lock->state), new; do { @@ -743,8 +740,6 @@ EXPORT_SYMBOL_GPL(six_trylock_convert); */ void six_lock_increment(struct six_lock *lock, enum six_lock_type type) { - const struct six_lock_vals l[] = LOCK_VALS; - six_acquire(&lock->dep_map, 0, type == SIX_LOCK_read, _RET_IP_); /* XXX: assert already locked, and that we don't overflow: */ |