From: Sharath Srinivasan <sharath.srinivasan@oracle.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Parav Pandit <parav@nvidia.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Sharath Srinivasan <sharath.srinivasan@oracle.com>
Subject: [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del
Date: Mon, 19 Jan 2026 11:43:52 -0800 [thread overview]
Message-ID: <ec221ec7-6abb-41b7-9237-8e799bbb5683@oracle.com> (raw)
The sync strategy in remove_all_compat_devs() can improved
by adopting that of rdma_dev_exit_net() which releases devices_rwsem
before calling remove_one_compat_dev()/device_del().
Also fixes a comment typo in rdma_dev_exit_net().
Fixes: 2b34c5580226 ("RDMA/core: Add command to set ib_core device net namspace sharing mode")
Signed-off-by: Sharath Srinivasan <sharath.srinivasan@oracle.com>
---
drivers/infiniband/core/device.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 1174ab7da629..81689924fab8 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1078,6 +1078,13 @@ static void remove_all_compat_devs(void)
xa_for_each (&devices, index, dev) {
unsigned long c_index = 0;
+ get_device(&dev->dev);
+ /*
+ * Release the devices_rwsem so that potentially blocking
+ * device_del doesn't hold the devices_rwsem for too long.
+ */
+ up_read(&devices_rwsem);
+
/* Hold nets_rwsem so that any other thread modifying this
* system param can sync with this thread.
*/
@@ -1085,6 +1092,9 @@ static void remove_all_compat_devs(void)
xa_for_each (&dev->compat_devs, c_index, cdev)
remove_one_compat_dev(dev, c_index);
up_read(&rdma_nets_rwsem);
+
+ put_device(&dev->dev);
+ down_read(&devices_rwsem);
}
up_read(&devices_rwsem);
}
@@ -1168,8 +1178,8 @@ static void rdma_dev_exit_net(struct net *net)
xa_for_each (&devices, index, dev) {
get_device(&dev->dev);
/*
- * Release the devices_rwsem so that pontentially blocking
- * device_del, doesn't hold the devices_rwsem for too long.
+ * Release the devices_rwsem so that potentially blocking
+ * device_del doesn't hold the devices_rwsem for too long.
*/
up_read(&devices_rwsem);
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-01-19 19:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 19:43 Sharath Srinivasan [this message]
2026-01-19 19:53 ` [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del Jason Gunthorpe
2026-01-25 13:47 ` Leon Romanovsky
2026-01-26 18:47 ` Sharath Srinivasan
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=ec221ec7-6abb-41b7-9237-8e799bbb5683@oracle.com \
--to=sharath.srinivasan@oracle.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=parav@nvidia.com \
/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.