diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-05-01 08:47:44 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-05-01 08:47:44 -0700 | 
| commit | bf61c8840efe60fd8f91446860b63338fb424158 (patch) | |
| tree | 7a71832407a4f0d6346db773343f4c3ae2257b19 /include/linux/srcu.h | |
| parent | 5846115b30f3a881e542c8bfde59a699c1c13740 (diff) | |
| parent | 0c6a61657da78098472fd0eb71cc01f2387fa1bb (diff) | |
| download | olio-linux-3.10-bf61c8840efe60fd8f91446860b63338fb424158.tar.xz olio-linux-3.10-bf61c8840efe60fd8f91446860b63338fb424158.zip  | |
Merge branch 'next' into for-linus
Prepare first set of updates for 3.10 merge window.
Diffstat (limited to 'include/linux/srcu.h')
| -rw-r--r-- | include/linux/srcu.h | 60 | 
1 files changed, 37 insertions, 23 deletions
diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 55a5c52cbb2..04f4121a23a 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -16,8 +16,10 @@   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   *   * Copyright (C) IBM Corporation, 2006 + * Copyright (C) Fujitsu, 2012   *   * Author: Paul McKenney <paulmck@us.ibm.com> + *	   Lai Jiangshan <laijs@cn.fujitsu.com>   *   * For detailed explanation of Read-Copy Update mechanism see -   * 		Documentation/RCU/ *.txt @@ -40,6 +42,8 @@ struct rcu_batch {  	struct rcu_head *head, **tail;  }; +#define RCU_BATCH_INIT(name) { NULL, &(name.head) } +  struct srcu_struct {  	unsigned completed;  	struct srcu_struct_array __percpu *per_cpu_ref; @@ -70,12 +74,42 @@ int __init_srcu_struct(struct srcu_struct *sp, const char *name,  	__init_srcu_struct((sp), #sp, &__srcu_key); \  }) +#define __SRCU_DEP_MAP_INIT(srcu_name)	.dep_map = { .name = #srcu_name },  #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */  int init_srcu_struct(struct srcu_struct *sp); +#define __SRCU_DEP_MAP_INIT(srcu_name)  #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ +void process_srcu(struct work_struct *work); + +#define __SRCU_STRUCT_INIT(name)					\ +	{								\ +		.completed = -300,					\ +		.per_cpu_ref = &name##_srcu_array,			\ +		.queue_lock = __SPIN_LOCK_UNLOCKED(name.queue_lock),	\ +		.running = false,					\ +		.batch_queue = RCU_BATCH_INIT(name.batch_queue),	\ +		.batch_check0 = RCU_BATCH_INIT(name.batch_check0),	\ +		.batch_check1 = RCU_BATCH_INIT(name.batch_check1),	\ +		.batch_done = RCU_BATCH_INIT(name.batch_done),		\ +		.work = __DELAYED_WORK_INITIALIZER(name.work, process_srcu, 0),\ +		__SRCU_DEP_MAP_INIT(name)				\ +	} + +/* + * define and init a srcu struct at build time. + * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it. + */ +#define DEFINE_SRCU(name)						\ +	static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\ +	struct srcu_struct name = __SRCU_STRUCT_INIT(name); + +#define DEFINE_STATIC_SRCU(name)					\ +	static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\ +	static struct srcu_struct name = __SRCU_STRUCT_INIT(name); +  /**   * call_srcu() - Queue a callback for invocation after an SRCU grace period   * @sp: srcu_struct in queue the callback @@ -117,30 +151,14 @@ void srcu_barrier(struct srcu_struct *sp);   * Checks debug_lockdep_rcu_enabled() to prevent false positives during boot   * and while lockdep is disabled.   * - * Note that if the CPU is in the idle loop from an RCU point of view - * (ie: that we are in the section between rcu_idle_enter() and - * rcu_idle_exit()) then srcu_read_lock_held() returns false even if - * the CPU did an srcu_read_lock().  The reason for this is that RCU - * ignores CPUs that are in such a section, considering these as in - * extended quiescent state, so such a CPU is effectively never in an - * RCU read-side critical section regardless of what RCU primitives it - * invokes.  This state of affairs is required --- we need to keep an - * RCU-free window in idle where the CPU may possibly enter into low - * power mode. This way we can notice an extended quiescent state to - * other CPUs that started a grace period. Otherwise we would delay any - * grace period as long as we run in the idle task. - * - * Similarly, we avoid claiming an SRCU read lock held if the current - * CPU is offline. + * Note that SRCU is based on its own statemachine and it doesn't + * relies on normal RCU, it can be called from the CPU which + * is in the idle loop from an RCU point of view or offline.   */  static inline int srcu_read_lock_held(struct srcu_struct *sp)  {  	if (!debug_lockdep_rcu_enabled())  		return 1; -	if (rcu_is_cpu_idle()) -		return 0; -	if (!rcu_lockdep_current_cpu_online()) -		return 0;  	return lock_is_held(&sp->dep_map);  } @@ -202,8 +220,6 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)  	int retval = __srcu_read_lock(sp);  	rcu_lock_acquire(&(sp)->dep_map); -	rcu_lockdep_assert(!rcu_is_cpu_idle(), -			   "srcu_read_lock() used illegally while idle");  	return retval;  } @@ -217,8 +233,6 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)  static inline void srcu_read_unlock(struct srcu_struct *sp, int idx)  	__releases(sp)  { -	rcu_lockdep_assert(!rcu_is_cpu_idle(), -			   "srcu_read_unlock() used illegally while idle");  	rcu_lock_release(&(sp)->dep_map);  	__srcu_read_unlock(sp, idx);  }  |