mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-23 02:51:47 +00:00
six locks: Simplify six_lock_counts()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
70f0b0fd7e
commit
0cc1bc84d6
1 changed files with 3 additions and 10 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue