Skip to content

Commit 293e242

Browse files
fbqpaulmck
authored andcommitted
rcu: Remove superfluous versions of rcu_read_lock_sched_held()
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 <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 8c7c482 commit 293e242

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

include/linux/rcupdate.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,7 @@ int rcu_read_lock_bh_held(void);
508508
* CONFIG_DEBUG_LOCK_ALLOC, this assumes we are in an RCU-sched read-side
509509
* critical section unless it can prove otherwise.
510510
*/
511-
#ifdef CONFIG_PREEMPT_COUNT
512511
int rcu_read_lock_sched_held(void);
513-
#else /* #ifdef CONFIG_PREEMPT_COUNT */
514-
static inline int rcu_read_lock_sched_held(void)
515-
{
516-
return 1;
517-
}
518-
#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
519512

520513
#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
521514

@@ -532,18 +525,10 @@ static inline int rcu_read_lock_bh_held(void)
532525
return 1;
533526
}
534527

535-
#ifdef CONFIG_PREEMPT_COUNT
536528
static inline int rcu_read_lock_sched_held(void)
537529
{
538-
return preempt_count() != 0 || irqs_disabled();
530+
return !preemptible();
539531
}
540-
#else /* #ifdef CONFIG_PREEMPT_COUNT */
541-
static inline int rcu_read_lock_sched_held(void)
542-
{
543-
return 1;
544-
}
545-
#endif /* #else #ifdef CONFIG_PREEMPT_COUNT */
546-
547532
#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
548533

549534
#ifdef CONFIG_PROVE_RCU

kernel/rcu/update.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int rcu_normal_after_boot;
6767
module_param(rcu_normal_after_boot, int, 0);
6868
#endif /* #ifndef CONFIG_TINY_RCU */
6969

70-
#if defined(CONFIG_DEBUG_LOCK_ALLOC) && defined(CONFIG_PREEMPT_COUNT)
70+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
7171
/**
7272
* rcu_read_lock_sched_held() - might we be in RCU-sched read-side critical section?
7373
*
@@ -111,7 +111,7 @@ int rcu_read_lock_sched_held(void)
111111
return 0;
112112
if (debug_locks)
113113
lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
114-
return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
114+
return lockdep_opinion || !preemptible();
115115
}
116116
EXPORT_SYMBOL(rcu_read_lock_sched_held);
117117
#endif

0 commit comments

Comments
 (0)