From: Zqiang <qiang.zhang@linux.dev>
To: linusw@kernel.org, brgl@kernel.org, paulmck@kernel.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
qiang.zhang@linux.dev
Subject: [PATCH] gpiolib: Use srcu_barrier() instead of synchronize_srcu() in gpiodev_release()
Date: Fri, 27 Nov 2026 10:31:01 +0800 [thread overview]
Message-ID: <20261127023101.27568-1-qiang.zhang@linux.dev> (raw)
The gpio_desc_label object are freed asynchronously via call_srcu() on
gdev->desc_srcu (see desc_set_label()). to drain these pending SRCU
callbacks before cleanup the SRCU structure, gpiodev_release() currently
calls synchronize_srcu(&gdev->desc_srcu).
However, synchronize_srcu() only waits for a grace period to elapse and
for its own wakeme_after_rcu callback to be invoked. it does not guarantee
that callbacks queued on other CPUs have actually been invoked by the time
it returns. The following race may happen:
CPUA CPUB
call_srcu(desc_srcu, desc_free_label)
gpiodev_release()
->synchronize_srcu()
->call_srcu() queue wakeme_after_rcu()
SRCU GP end
timer_reduce(delay_work)
SRCU GP end
synchronize_srcu() return
->cleanup_srcu_struct()
/* timer still pending! */ ->for CPUA timer_delete_sync() return true
and cblist not empty. tigger WARN_ON()
This commit therefore use srcu_barrier() instead of synchronize_srcu() on
gdev->desc_srcu, it entrains a barrier callback on every CPU that has callbacks
queued and waits until all of them have been invoked.
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c09342fc52cb..5dd4d142cf52 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -898,7 +898,7 @@ static void gpiodev_release(struct device *dev)
struct gpio_device *gdev = to_gpio_device(dev);
/* Call pending kfree()s for descriptor labels. */
- synchronize_srcu(&gdev->desc_srcu);
+ srcu_barrier(&gdev->desc_srcu);
cleanup_srcu_struct(&gdev->desc_srcu);
if (gdev->line_state_wq)
--
2.17.1
next reply other threads:[~2026-11-27 2:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 2:31 Zqiang [this message]
2026-11-27 2:41 ` [PATCH] gpiolib: Use srcu_barrier() instead of synchronize_srcu() in gpiodev_release() sashiko-bot
2026-11-27 7:09 ` Adrian Ambrozewicz
2026-11-27 11:39 ` Zqiang
-- strict thread matches above, loose matches on Subject: below --
2026-11-26 8:42 Zqiang
2026-11-26 8:52 ` sashiko-bot
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=20261127023101.27568-1-qiang.zhang@linux.dev \
--to=qiang.zhang@linux.dev \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.