mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
Mutex error check will capture trying to take the lock recursively and other problems that rwlock won't. At the expense of concurrency, adda debug mode that uses a mutex in place of a rwsem. Signed-off-by: Ian Rogers <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: German Gomez <[email protected]> Cc: James Clark <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Changbin Du <[email protected]> Cc: liuwenyu <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: Song Liu <[email protected]> Cc: Leo Yan <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Kan Liang <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Yanteng Si <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Paolo Bonzini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
31 lines
600 B
C
31 lines
600 B
C
#ifndef _PERF_RWSEM_H
|
|
#define _PERF_RWSEM_H
|
|
|
|
#include <pthread.h>
|
|
#include "mutex.h"
|
|
|
|
/*
|
|
* Mutexes have additional error checking. Enable to use a mutex rather than a
|
|
* rwlock for debugging.
|
|
*/
|
|
#define RWS_ERRORCHECK 0
|
|
|
|
struct rw_semaphore {
|
|
#if RWS_ERRORCHECK
|
|
struct mutex mtx;
|
|
#else
|
|
pthread_rwlock_t lock;
|
|
#endif
|
|
};
|
|
|
|
int init_rwsem(struct rw_semaphore *sem);
|
|
int exit_rwsem(struct rw_semaphore *sem);
|
|
|
|
int down_read(struct rw_semaphore *sem);
|
|
int up_read(struct rw_semaphore *sem);
|
|
|
|
int down_write(struct rw_semaphore *sem);
|
|
int up_write(struct rw_semaphore *sem);
|
|
|
|
#endif /* _PERF_RWSEM_H */
|