Skip to content

Commit 925da92

Browse files
Waiman-Longpaulmckrcu
authored andcommitted
rcu: Avoid unneeded function call in rcu_read_unlock()
Since commit aa40c13 ("rcu: Report QS for outermost PREEMPT=n rcu_read_unlock() for strict GPs") the function rcu_read_unlock_strict() is invoked by the inlined rcu_read_unlock() function. However, rcu_read_unlock_strict() is an empty function in production kernels, which are built with CONFIG_RCU_STRICT_GRACE_PERIOD=n. There is a mention of rcu_read_unlock_strict() in the BPF verifier, but this is in a deny-list, meaning that BPF does not care whether rcu_read_unlock_strict() is ever called. This commit therefore provides a slight performance improvement by hoisting the check of CONFIG_RCU_STRICT_GRACE_PERIOD from rcu_read_unlock_strict() into rcu_read_unlock(), thus avoiding the pointless call to an empty function. Cc: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent f0b2b2d commit 925da92

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/linux/rcupdate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static inline void __rcu_read_lock(void)
7171
static inline void __rcu_read_unlock(void)
7272
{
7373
preempt_enable();
74-
rcu_read_unlock_strict();
74+
if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD))
75+
rcu_read_unlock_strict();
7576
}
7677

7778
static inline int rcu_preempt_depth(void)

kernel/rcu/tree_plugin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,7 @@ void rcu_read_unlock_strict(void)
814814
{
815815
struct rcu_data *rdp;
816816

817-
if (!IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD) ||
818-
irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
817+
if (irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
819818
return;
820819
rdp = this_cpu_ptr(&rcu_data);
821820
rcu_report_qs_rdp(rdp);

0 commit comments

Comments
 (0)