blob: d2146a4f833e5819c56ba16afefe01687a3981fc [file] [log] [blame]
Mikulas Patocka62ac6652012-09-26 07:46:43 +02001#ifndef _LINUX_PERCPU_RWSEM_H
2#define _LINUX_PERCPU_RWSEM_H
3
Oleg Nesterov9390ef02012-12-17 16:01:36 -08004#include <linux/atomic.h>
Oleg Nesterova1fd3e22012-12-17 16:01:32 -08005#include <linux/rwsem.h>
Mikulas Patocka62ac6652012-09-26 07:46:43 +02006#include <linux/percpu.h>
Oleg Nesterova1fd3e22012-12-17 16:01:32 -08007#include <linux/wait.h>
Mikulas Patocka62ac6652012-09-26 07:46:43 +02008
9struct percpu_rw_semaphore {
Oleg Nesterova1fd3e22012-12-17 16:01:32 -080010 unsigned int __percpu *fast_read_ctr;
Oleg Nesterov9390ef02012-12-17 16:01:36 -080011 atomic_t write_ctr;
Oleg Nesterova1fd3e22012-12-17 16:01:32 -080012 struct rw_semaphore rw_sem;
13 atomic_t slow_read_ctr;
14 wait_queue_head_t write_waitq;
Mikulas Patocka62ac6652012-09-26 07:46:43 +020015};
16
Oleg Nesterova1fd3e22012-12-17 16:01:32 -080017extern void percpu_down_read(struct percpu_rw_semaphore *);
18extern void percpu_up_read(struct percpu_rw_semaphore *);
Mikulas Patocka5c1eabe2012-10-22 19:37:47 -040019
Oleg Nesterova1fd3e22012-12-17 16:01:32 -080020extern void percpu_down_write(struct percpu_rw_semaphore *);
21extern void percpu_up_write(struct percpu_rw_semaphore *);
Mikulas Patocka62ac6652012-09-26 07:46:43 +020022
Oleg Nesterova1fd3e22012-12-17 16:01:32 -080023extern int percpu_init_rwsem(struct percpu_rw_semaphore *);
24extern void percpu_free_rwsem(struct percpu_rw_semaphore *);
Mikulas Patocka62ac6652012-09-26 07:46:43 +020025
26#endif