Browse Source

rcu: Move __rcu_read_unlock()'s barrier() within if-statement

We only need to constrain the compiler if we are actually exiting
the top-level RCU read-side critical section.  This commit therefore
moves the first barrier() cal in __rcu_read_unlock() to inside the
"if" statement, thus avoiding needless register flushes for inner
rcu_read_unlock() calls.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Paul E. McKenney 14 years ago
parent
commit
6206ab9bab
2 changed files with 3 additions and 13 deletions
  1. 2 12
      include/linux/rcupdate.h
  2. 1 1
      kernel/rcutree_plugin.h

+ 2 - 12
include/linux/rcupdate.h

@@ -134,16 +134,6 @@ extern void call_rcu_sched(struct rcu_head *head,
 
 
 extern void synchronize_sched(void);
 extern void synchronize_sched(void);
 
 
-static inline void __rcu_read_lock_bh(void)
-{
-	local_bh_disable();
-}
-
-static inline void __rcu_read_unlock_bh(void)
-{
-	local_bh_enable();
-}
-
 #ifdef CONFIG_PREEMPT_RCU
 #ifdef CONFIG_PREEMPT_RCU
 
 
 extern void __rcu_read_lock(void);
 extern void __rcu_read_lock(void);
@@ -686,7 +676,7 @@ static inline void rcu_read_unlock(void)
  */
  */
 static inline void rcu_read_lock_bh(void)
 static inline void rcu_read_lock_bh(void)
 {
 {
-	__rcu_read_lock_bh();
+	local_bh_disable();
 	__acquire(RCU_BH);
 	__acquire(RCU_BH);
 	rcu_read_acquire_bh();
 	rcu_read_acquire_bh();
 }
 }
@@ -700,7 +690,7 @@ static inline void rcu_read_unlock_bh(void)
 {
 {
 	rcu_read_release_bh();
 	rcu_read_release_bh();
 	__release(RCU_BH);
 	__release(RCU_BH);
-	__rcu_read_unlock_bh();
+	local_bh_enable();
 }
 }
 
 
 /**
 /**

+ 1 - 1
kernel/rcutree_plugin.h

@@ -415,10 +415,10 @@ void __rcu_read_unlock(void)
 {
 {
 	struct task_struct *t = current;
 	struct task_struct *t = current;
 
 
-	barrier();  /* needed if we ever invoke rcu_read_unlock in rcutree.c */
 	if (t->rcu_read_lock_nesting != 1)
 	if (t->rcu_read_lock_nesting != 1)
 		--t->rcu_read_lock_nesting;
 		--t->rcu_read_lock_nesting;
 	else {
 	else {
+		barrier();  /* critical section before exit code. */
 		t->rcu_read_lock_nesting = INT_MIN;
 		t->rcu_read_lock_nesting = INT_MIN;
 		barrier();  /* assign before ->rcu_read_unlock_special load */
 		barrier();  /* assign before ->rcu_read_unlock_special load */
 		if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
 		if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))