From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: pengdonglin <dolinux.peng@gmail.com>
Cc: tj@kernel.org, tony.luck@intel.com, jani.nikula@linux.intel.com,
ap420073@gmail.com, jv@jvosburgh.net, freude@linux.ibm.com,
bcrl@kvack.org, trondmy@kernel.org, longman@redhat.com,
kees@kernel.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev, linux-nfs@vger.kernel.org,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
intel-gfx@lists.freedesktop.org, linux-acpi@vger.kernel.org,
linux-s390@vger.kernel.org, cgroups@vger.kernel.org,
Hillf Danton <hdanton@sina.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
pengdonglin <pengdonglin@xiaomi.com>
Subject: Re: [PATCH v2] rcu: Remove redundant rcu_read_lock/unlock() in spin_lock critical sections
Date: Mon, 15 Sep 2025 16:40:52 +0200 [thread overview]
Message-ID: <20250915144052.VHYlgilw@linutronix.de> (raw)
In-Reply-To: <20250915134729.1801557-1-dolinux.peng@gmail.com>
On 2025-09-15 21:47:29 [+0800], pengdonglin wrote:
> From: pengdonglin <pengdonglin@xiaomi.com>
>
> Per Documentation/RCU/rcu_dereference.rst [1], since Linux 4.20's RCU
> consolidation [2][3], RCU read-side critical sections include:
> - Explicit rcu_read_lock()
> - BH/interrupt/preemption-disabling regions
> - Spinlock critical sections (including CONFIG_PREEMPT_RT kernels [4])
>
> Thus, explicit rcu_read_lock()/unlock() calls within spin_lock*() regions are redundant.
> This patch removes them, simplifying locking semantics while preserving RCU protection.
>
> [1] https://elixir.bootlin.com/linux/v6.17-rc5/source/Documentation/RCU/rcu_dereference.rst#L407
> [2] https://lore.kernel.org/lkml/20180829222021.GA29944@linux.vnet.ibm.com/
> [3] https://lwn.net/Articles/777036/
> [4] https://lore.kernel.org/lkml/6435833a-bdcb-4114-b29d-28b7f436d47d@paulmck-laptop/
What about something like this:
Since commit a8bb74acd8efe ("rcu: Consolidate RCU-sched update-side
function definitions") there is no difference between rcu_read_lock(),
rcu_read_lock_bh() and rcu_read_lock_sched() in terms of RCU read
section and the relevant grace period. That means that spin_lock(),
which implies rcu_read_lock_sched(), also implies rcu_read_lock().
There is no need no explicitly start a RCU read section if one has
already been started implicitly by spin_lock().
Simplify the code and remove the inner rcu_read_lock() invocation.
The description above should make it clear what:
- the intention is
- the proposed solution to it and why it is correct.
You can't send a patch like this. You need to split it at the very least
by subsystem. The networking bits need to follow to follow for instance
Documentation/process/maintainer-netdev.rst
and so on.
Sebastian
next prev parent reply other threads:[~2025-09-15 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 13:47 [PATCH v2] rcu: Remove redundant rcu_read_lock/unlock() in spin_lock critical sections pengdonglin
2025-09-15 14:13 ` Waiman Long
2025-09-15 14:40 ` Sebastian Andrzej Siewior [this message]
2025-09-16 1:55 ` Donglin Peng
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=20250915144052.VHYlgilw@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=ap420073@gmail.com \
--cc=bcrl@kvack.org \
--cc=cgroups@vger.kernel.org \
--cc=dolinux.peng@gmail.com \
--cc=freude@linux.ibm.com \
--cc=hdanton@sina.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jv@jvosburgh.net \
--cc=kees@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-s390@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=longman@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=pengdonglin@xiaomi.com \
--cc=tj@kernel.org \
--cc=tony.luck@intel.com \
--cc=trondmy@kernel.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