mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
locking/percpu-rwsem: Add percpu_is_write_locked() and percpu_is_read_locked()
Implement simple accessors to probe percpu-rwsem's locked state: percpu_is_write_locked(), percpu_is_read_locked(). Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Acked-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20220829124719.675715-11-elver@google.com
This commit is contained in:
parent
f95e5a3d59
commit
01fe8a3f81
2 changed files with 12 additions and 0 deletions
|
@ -192,6 +192,12 @@ EXPORT_SYMBOL_GPL(__percpu_down_read);
|
|||
__sum; \
|
||||
})
|
||||
|
||||
bool percpu_is_read_locked(struct percpu_rw_semaphore *sem)
|
||||
{
|
||||
return per_cpu_sum(*sem->read_count) != 0 && !atomic_read(&sem->block);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(percpu_is_read_locked);
|
||||
|
||||
/*
|
||||
* Return true if the modular sum of the sem->read_count per-CPU variable is
|
||||
* zero. If this sum is zero, then it is stable due to the fact that if any
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue