[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210827022122.15816-1-longman@redhat.com>
Date: Thu, 26 Aug 2021 22:21:22 -0400
From: Waiman Long <longman@...hat.com>
To: "Paul E. McKenney" <paulmck@...ux.ibm.com>,
Josh Triplett <josh@...htriplett.org>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Joel Fernandes <joel@...lfernandes.org>
Cc: rcu@...r.kernel.org, linux-kernel@...r.kernel.org,
Waiman Long <longman@...hat.com>
Subject: [PATCH] rcu: Avoid unneeded function call in rcu_read_unlock()
Since commit aa40c138cc8f3 ("rcu: Report QS for outermost
PREEMPT=n rcu_read_unlock() for strict GPs"). A real function call
rcu_read_unlock_strict() is added to the inlined rcu_read_unlock().
The rcu_read_unlock_strict() call is only needed if the performance
sagging CONFIG_RCU_STRICT_GRACE_PERIOD option is set. This config
option isn't set for most production kernels while the function call
overhead remains.
To provide a slight performance improvement, the
CONFIG_RCU_STRICT_GRACE_PERIOD config check is moved from
rcu_read_unlock_strict() to __rcu_read_unlock() so that the function
call can be compiled out in most cases.
Besides, the GPL exported rcu_read_unlock_strict() also impact the
the compilation of non-GPL kernel modules as rcu_read_unlock() is a
frequently used kernel API.
Signed-off-by: Waiman Long <longman@...hat.com>
---
include/linux/rcupdate.h | 3 ++-
kernel/rcu/tree_plugin.h | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index d9680b798b21..945594770d57 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -71,7 +71,8 @@ static inline void __rcu_read_lock(void)
static inline void __rcu_read_unlock(void)
{
preempt_enable();
- rcu_read_unlock_strict();
+ if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD))
+ rcu_read_unlock_strict();
}
static inline int rcu_preempt_depth(void)
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index de1dc3bb7f70..7fa518bef15d 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -844,8 +844,7 @@ void rcu_read_unlock_strict(void)
{
struct rcu_data *rdp;
- if (!IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD) ||
- irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
+ if (irqs_disabled() || preempt_count() || !rcu_state.gp_kthread)
return;
rdp = this_cpu_ptr(&rcu_data);
rcu_report_qs_rdp(rdp);
--
2.18.1
Powered by blists - more mailing lists