Commit 0cc1bc84 authored by Kent Overstreet's avatar Kent Overstreet

six locks: Simplify six_lock_counts()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 70f0b0fd
...@@ -830,19 +830,12 @@ struct six_lock_count six_lock_counts(struct six_lock *lock) ...@@ -830,19 +830,12 @@ struct six_lock_count six_lock_counts(struct six_lock *lock)
{ {
struct six_lock_count ret; struct six_lock_count ret;
ret.n[SIX_LOCK_read] = 0; ret.n[SIX_LOCK_read] = !lock->readers
? lock->state.read_lock
: pcpu_read_count(lock);
ret.n[SIX_LOCK_intent] = lock->state.intent_lock + lock->intent_lock_recurse; ret.n[SIX_LOCK_intent] = lock->state.intent_lock + lock->intent_lock_recurse;
ret.n[SIX_LOCK_write] = lock->state.seq & 1; ret.n[SIX_LOCK_write] = lock->state.seq & 1;
if (!lock->readers)
ret.n[SIX_LOCK_read] += lock->state.read_lock;
else {
int cpu;
for_each_possible_cpu(cpu)
ret.n[SIX_LOCK_read] += *per_cpu_ptr(lock->readers, cpu);
}
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(six_lock_counts); EXPORT_SYMBOL_GPL(six_lock_counts);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment