mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-20 08:47:59 -05:00
six locks: Simplify six_lock_counts()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -830,19 +830,12 @@ struct six_lock_count six_lock_counts(struct six_lock *lock)
|
||||
{
|
||||
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_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;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(six_lock_counts);
|
||||
|
||||
Reference in New Issue
Block a user