Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376887

[PATCH tip/core/rcu 5/6] rcu: Remove superfluous versions of rcu_read_lock_sched_held()

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH tip/core/rcu 5/6] rcu: Remove superfluous versions of rcu_read_lock_sched_held()
Date 2016-04-12 17:10 +0200
Message-ID <rn871-W0-29@gated-at.bofh.it> (permalink)
References <rn870-W0-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Boqun Feng <boqun.feng@gmail.com>

Currently, we have four versions of rcu_read_lock_sched_held(), depending
on the combined choices on PREEMPT_COUNT and DEBUG_LOCK_ALLOC.  However,
there is an existing function preemptible() that already distinguishes
between the PREEMPT_COUNT=y and PREEMPT_COUNT=n cases, and allows these
four implementations to be consolidated down to two.

This commit therefore uses preemptible() to achieve this consolidation.

Note that there could be a small performance regression in the case
of CONFIG_DEBUG_LOCK_ALLOC=y && PREEMPT_COUNT=n.  However, given the
overhead associated with CONFIG_DEBUG_LOCK_ALLOC=y, this should be
down in the noise.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/rcupdate.h | 17 +----------------
 kernel/rcu/update.c      |  4 ++--
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 45de591657a6..5f1533e3d032 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -508,14 +508,7 @@ int rcu_read_lock_bh_held(void);
  * CONFIG_DEBUG_LOCK_ALLOC, this assumes we are in an RCU-sched read-side
  * critical section unless it can prove otherwise.
  */
-#ifdef CONFIG_PREEMPT_COUNT
 int rcu_read_lock_sched_held(void);
-#else /* #ifdef CONFIG_PREEMPT_COUNT */
-static inline int rcu_read_lock_sched_held(void)
-{
-	return 1;
-}
-#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
 
 #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
@@ -532,18 +525,10 @@ static inline int rcu_read_lock_bh_held(void)
 	return 1;
 }
 
-#ifdef CONFIG_PREEMPT_COUNT
 static inline int rcu_read_lock_sched_held(void)
 {
-	return preempt_count() != 0 || irqs_disabled();
+	return !preemptible();
 }
-#else /* #ifdef CONFIG_PREEMPT_COUNT */
-static inline int rcu_read_lock_sched_held(void)
-{
-	return 1;
-}
-#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
-
 #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
 
 #ifdef CONFIG_PROVE_RCU
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index ca828b41c938..3ccdc8eebc5a 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -67,7 +67,7 @@ static int rcu_normal_after_boot;
 module_param(rcu_normal_after_boot, int, 0);
 #endif /* #ifndef CONFIG_TINY_RCU */
 
-#if defined(CONFIG_DEBUG_LOCK_ALLOC) && defined(CONFIG_PREEMPT_COUNT)
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
 /**
  * rcu_read_lock_sched_held() - might we be in RCU-sched read-side critical section?
  *
@@ -111,7 +111,7 @@ int rcu_read_lock_sched_held(void)
 		return 0;
 	if (debug_locks)
 		lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
-	return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
+	return lockdep_opinion || !preemptible();
 }
 EXPORT_SYMBOL(rcu_read_lock_sched_held);
 #endif
-- 
2.5.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH tip/core/rcu 0/6] Miscellaneous fixes for 4.7 "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200
  [PATCH tip/core/rcu 4/6] rcu: Awaken grace-period kthread if too long since FQS "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200
  [PATCH tip/core/rcu 6/6] rcu: Dump ftrace buffer when kicking grace-period kthread "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200
  [PATCH tip/core/rcu 2/6] rcu: Awaken grace-period kthread when stalled "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200
  [PATCH tip/core/rcu 5/6] rcu: Remove superfluous versions of rcu_read_lock_sched_held() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200
  [PATCH tip/core/rcu 1/6] rcu: Consolidate dumping of ftrace buffer "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-04-12 17:10 +0200

csiph-web