Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_PERCPU_RWSEM_H |
| 2 | #define _LINUX_PERCPU_RWSEM_H |
| 3 | |
Oleg Nesterov | 9390ef0 | 2012-12-17 16:01:36 -0800 | [diff] [blame^] | 4 | #include <linux/atomic.h> |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 5 | #include <linux/rwsem.h> |
Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 6 | #include <linux/percpu.h> |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 7 | #include <linux/wait.h> |
Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 8 | |
| 9 | struct percpu_rw_semaphore { |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 10 | unsigned int __percpu *fast_read_ctr; |
Oleg Nesterov | 9390ef0 | 2012-12-17 16:01:36 -0800 | [diff] [blame^] | 11 | atomic_t write_ctr; |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 12 | struct rw_semaphore rw_sem; |
| 13 | atomic_t slow_read_ctr; |
| 14 | wait_queue_head_t write_waitq; |
Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 15 | }; |
| 16 | |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 17 | extern void percpu_down_read(struct percpu_rw_semaphore *); |
| 18 | extern void percpu_up_read(struct percpu_rw_semaphore *); |
Mikulas Patocka | 5c1eabe | 2012-10-22 19:37:47 -0400 | [diff] [blame] | 19 | |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 20 | extern void percpu_down_write(struct percpu_rw_semaphore *); |
| 21 | extern void percpu_up_write(struct percpu_rw_semaphore *); |
Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 22 | |
Oleg Nesterov | a1fd3e2 | 2012-12-17 16:01:32 -0800 | [diff] [blame] | 23 | extern int percpu_init_rwsem(struct percpu_rw_semaphore *); |
| 24 | extern void percpu_free_rwsem(struct percpu_rw_semaphore *); |
Mikulas Patocka | 62ac665 | 2012-09-26 07:46:43 +0200 | [diff] [blame] | 25 | |
| 26 | #endif |