From: "Paul E. McKenney" <paulmck@kernel.org>
To: frederic@kernel.org, rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Kent Overstreet <kent.overstreet@linux.dev>,
bpf@vger.kernel.org
Subject: [PATCH rcu 07/12] srcu: Allow inlining of __srcu_read_{,un}lock_lite()
Date: Wed, 9 Oct 2024 11:07:14 -0700 [thread overview]
Message-ID: <20241009180719.778285-7-paulmck@kernel.org> (raw)
In-Reply-To: <ff986c31-9cd0-45e5-aa31-9aedf582325f@paulmck-laptop>
This commit moves __srcu_read_lock_lite() and __srcu_read_unlock_lite()
into include/linux/srcu.h and marks them "static inline" so that they
can be inlined into srcu_read_lock_lite() and srcu_read_unlock_lite(),
respectively. They are not hand-inlined due to Tree SRCU and Tiny SRCU
having different implementations.
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: <bpf@vger.kernel.org>
---
include/linux/srcutree.h | 39 ++++++++++++++++++++++++++++++++++++++
kernel/rcu/srcutree.c | 41 ----------------------------------------
2 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
index 8074138cbd624..778eb61542e18 100644
--- a/include/linux/srcutree.h
+++ b/include/linux/srcutree.h
@@ -209,4 +209,43 @@ void synchronize_srcu_expedited(struct srcu_struct *ssp);
void srcu_barrier(struct srcu_struct *ssp);
void srcu_torture_stats_print(struct srcu_struct *ssp, char *tt, char *tf);
+/*
+ * Counts the new reader in the appropriate per-CPU element of the
+ * srcu_struct. Returns an index that must be passed to the matching
+ * srcu_read_unlock_lite().
+ *
+ * Note that this_cpu_inc() is an RCU read-side critical section either
+ * because it disables interrupts, because it is a single instruction,
+ * or because it is a read-modify-write atomic operation, depending on
+ * the whims of the architecture.
+ */
+static inline int __srcu_read_lock_lite(struct srcu_struct *ssp)
+{
+ int idx;
+
+ RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_lite().");
+ idx = READ_ONCE(ssp->srcu_idx) & 0x1;
+ this_cpu_inc(ssp->sda->srcu_lock_count[idx].counter); /* Y */
+ barrier(); /* Avoid leaking the critical section. */
+ return idx;
+}
+
+/*
+ * Removes the count for the old reader from the appropriate
+ * per-CPU element of the srcu_struct. Note that this may well be a
+ * different CPU than that which was incremented by the corresponding
+ * srcu_read_lock_lite(), but it must be within the same task.
+ *
+ * Note that this_cpu_inc() is an RCU read-side critical section either
+ * because it disables interrupts, because it is a single instruction,
+ * or because it is a read-modify-write atomic operation, depending on
+ * the whims of the architecture.
+ */
+static inline void __srcu_read_unlock_lite(struct srcu_struct *ssp, int idx)
+{
+ barrier(); /* Avoid leaking the critical section. */
+ this_cpu_inc(ssp->sda->srcu_unlock_count[idx].counter); /* Z */
+ RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_lite().");
+}
+
#endif
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index bf51758cf4a64..07147efcb64d3 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -763,47 +763,6 @@ void __srcu_read_unlock(struct srcu_struct *ssp, int idx)
}
EXPORT_SYMBOL_GPL(__srcu_read_unlock);
-/*
- * Counts the new reader in the appropriate per-CPU element of the
- * srcu_struct. Returns an index that must be passed to the matching
- * srcu_read_unlock_lite().
- *
- * Note that this_cpu_inc() is an RCU read-side critical section either
- * because it disables interrupts, because it is a single instruction,
- * or because it is a read-modify-write atomic operation, depending on
- * the whims of the architecture.
- */
-int __srcu_read_lock_lite(struct srcu_struct *ssp)
-{
- int idx;
-
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_lite().");
- idx = READ_ONCE(ssp->srcu_idx) & 0x1;
- this_cpu_inc(ssp->sda->srcu_lock_count[idx].counter); /* Y */
- barrier(); /* Avoid leaking the critical section. */
- return idx;
-}
-EXPORT_SYMBOL_GPL(__srcu_read_lock_lite);
-
-/*
- * Removes the count for the old reader from the appropriate
- * per-CPU element of the srcu_struct. Note that this may well be a
- * different CPU than that which was incremented by the corresponding
- * srcu_read_lock_lite(), but it must be within the same task.
- *
- * Note that this_cpu_inc() is an RCU read-side critical section either
- * because it disables interrupts, because it is a single instruction,
- * or because it is a read-modify-write atomic operation, depending on
- * the whims of the architecture.
- */
-void __srcu_read_unlock_lite(struct srcu_struct *ssp, int idx)
-{
- barrier(); /* Avoid leaking the critical section. */
- this_cpu_inc(ssp->sda->srcu_unlock_count[idx].counter); /* Z */
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_lite().");
-}
-EXPORT_SYMBOL_GPL(__srcu_read_unlock_lite);
-
#ifdef CONFIG_NEED_SRCU_NMI_SAFE
/*
--
2.40.1
next prev parent reply other threads:[~2024-10-09 18:07 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 18:07 [PATCH rcu 0/12] SRCU-lite changes for v6.13 Paul E. McKenney
2024-10-09 18:07 ` [PATCH rcu 01/12] srcu: Rename srcu_might_be_idle() to srcu_should_expedite() Paul E. McKenney
2024-10-14 8:56 ` Neeraj Upadhyay
2024-10-09 18:07 ` [PATCH rcu 02/12] srcu: Introduce srcu_gp_is_expedited() helper function Paul E. McKenney
2024-10-14 8:57 ` Neeraj Upadhyay
2024-10-09 18:07 ` [PATCH rcu 03/12] srcu: Renaming in preparation for additional reader flavor Paul E. McKenney
2024-10-14 9:10 ` Neeraj Upadhyay
2024-10-14 16:52 ` Paul E. McKenney
2024-10-15 3:25 ` Neeraj Upadhyay
2024-10-09 18:07 ` [PATCH rcu 04/12] srcu: Bit manipulation changes " Paul E. McKenney
2024-10-14 9:12 ` Neeraj Upadhyay
2024-10-14 16:51 ` Paul E. McKenney
2024-10-15 3:32 ` Neeraj Upadhyay
2024-10-09 18:07 ` [PATCH rcu 05/12] srcu: Standardize srcu_data pointers to "sdp" and similar Paul E. McKenney
2024-10-14 9:15 ` Neeraj Upadhyay
2024-10-14 16:49 ` Paul E. McKenney
2024-10-15 0:29 ` Paul E. McKenney
2024-10-15 5:10 ` Neeraj Upadhyay
2024-10-09 18:07 ` [PATCH rcu 06/12] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Paul E. McKenney
2024-11-11 12:54 ` Neeraj Upadhyay
2024-11-11 15:26 ` Paul E. McKenney
2024-11-11 16:51 ` Neeraj Upadhyay
2024-11-12 1:28 ` Paul E. McKenney
2024-11-12 1:31 ` [PATCH rcu 1/3] srcu: Remove smp_mb() from srcu_read_unlock_lite() Paul E. McKenney
2024-11-12 3:17 ` Neeraj Upadhyay
2024-11-12 1:31 ` [PATCH rcu 2/3] srcu: Check for srcu_read_lock_lite() across all CPUs Paul E. McKenney
2024-11-12 3:28 ` Neeraj Upadhyay
2024-11-12 5:48 ` Paul E. McKenney
2024-11-12 1:31 ` [PATCH rcu 3/3] srcu: Unconditionally record srcu_read_lock_lite() in ->srcu_reader_flavor Paul E. McKenney
2024-11-12 4:32 ` Neeraj Upadhyay
2024-11-12 3:15 ` [PATCH rcu 06/12] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Neeraj Upadhyay
2024-10-09 18:07 ` Paul E. McKenney [this message]
2024-10-09 18:07 ` [PATCH rcu 08/12] rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits Paul E. McKenney
2024-10-09 18:07 ` [PATCH rcu 09/12] rcutorture: Add reader_flavor parameter for SRCU readers Paul E. McKenney
2024-10-09 18:07 ` [PATCH rcu 10/12] rcutorture: Add srcu_read_lock_lite() support to rcutorture.reader_flavor Paul E. McKenney
2024-10-09 18:07 ` [PATCH rcu 11/12] rcutorture: Add light-weight SRCU scenario Paul E. McKenney
2024-10-09 18:07 ` [PATCH rcu 12/12] refscale: Add srcu_read_lock_lite() support using "srcu-lite" Paul E. McKenney
2024-10-10 15:38 ` Frederic Weisbecker
2024-10-10 16:06 ` Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 0/13] SRCU-lite changes for v6.13 Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 01/13] srcu: Rename srcu_might_be_idle() to srcu_should_expedite() Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 02/13] srcu: Introduce srcu_gp_is_expedited() helper function Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 03/13] srcu: Renaming in preparation for additional reader flavor Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 04/13] srcu: Bit manipulation changes " Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 05/13] srcu: Standardize srcu_data pointers to "sdp" and similar Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 06/13] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 07/13] srcu: Allow inlining of __srcu_read_{,un}lock_lite() Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 08/13] rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 09/13] rcutorture: Add reader_flavor parameter for SRCU readers Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 10/13] rcutorture: Add srcu_read_lock_lite() support to rcutorture.reader_flavor Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 11/13] rcutorture: Add light-weight SRCU scenario Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 12/13] refscale: Add srcu_read_lock_lite() support using "srcu-lite" Paul E. McKenney
2024-10-11 17:39 ` [PATCH v2 rcu 13/13] srcu: Improve srcu_read_lock_lite() kernel-doc comment Paul E. McKenney
2024-10-11 17:57 ` Andrii Nakryiko
2024-10-15 15:59 ` Paul E. McKenney
2024-10-15 16:11 ` [PATCH v3 rcu 0/13] SRCU-lite changes for v6.13 Paul E. McKenney
2024-10-15 16:10 ` [PATCH rcu 01/15] srcu: Rename srcu_might_be_idle() to srcu_should_expedite() Paul E. McKenney
2024-10-15 16:10 ` [PATCH rcu 02/15] srcu: Introduce srcu_gp_is_expedited() helper function Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 03/15] srcu: Renaming in preparation for additional reader flavor Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 04/15] srcu: Bit manipulation changes " Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 05/15] srcu: Standardize srcu_data pointers to "sdp" and similar Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 06/15] srcu: Improve srcu_read_lock{,_nmisafe}() comments Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 07/15] srcu: Create CPP macros for normal and NMI-safe SRCU readers Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 08/15] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Paul E. McKenney
2024-11-04 23:27 ` Frederic Weisbecker
2024-11-05 0:39 ` Paul E. McKenney
2024-11-11 11:17 ` Neeraj Upadhyay
2024-11-11 15:17 ` Paul E. McKenney
2024-11-11 17:46 ` Andrii Nakryiko
2024-11-11 17:51 ` Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 09/15] srcu: Allow inlining of __srcu_read_{,un}lock_lite() Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 10/15] rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 11/15] rcutorture: Add reader_flavor parameter for SRCU readers Paul E. McKenney
2024-11-12 4:42 ` Neeraj Upadhyay
2024-11-12 19:27 ` Paul E. McKenney
2024-11-13 3:20 ` Neeraj Upadhyay
2024-10-15 16:11 ` [PATCH rcu 12/15] rcutorture: Add srcu_read_lock_lite() support to rcutorture.reader_flavor Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 13/15] rcutorture: Add light-weight SRCU scenario Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 14/15] refscale: Add srcu_read_lock_lite() support using "srcu-lite" Paul E. McKenney
2024-10-29 0:25 ` [PATCH rcu v4 " Paul E. McKenney
2024-10-15 16:11 ` [PATCH rcu 15/15] srcu: Improve srcu_read_lock_lite() kernel-doc comment Paul E. McKenney
2024-11-12 4:37 ` [PATCH v3 rcu 0/13] SRCU-lite changes for v6.13 Neeraj Upadhyay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241009180719.778285-7-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=frederic@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox