* [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del
@ 2026-01-19 19:43 Sharath Srinivasan
2026-01-19 19:53 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: Sharath Srinivasan @ 2026-01-19 19:43 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky, Parav Pandit
Cc: linux-rdma, linux-kernel, Sharath Srinivasan
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del
2026-01-19 19:43 [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del Sharath Srinivasan
@ 2026-01-19 19:53 ` Jason Gunthorpe
2026-01-25 13:47 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2026-01-19 19:53 UTC (permalink / raw)
To: Sharath Srinivasan
Cc: Leon Romanovsky, Parav Pandit, linux-rdma, linux-kernel
On Mon, Jan 19, 2026 at 11:43:52AM -0800, Sharath Srinivasan wrote:
> 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().
You cannot change this locking without writing a huge commit message
explaining in detail the reason why any change like this is safe..
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del
2026-01-19 19:53 ` Jason Gunthorpe
@ 2026-01-25 13:47 ` Leon Romanovsky
2026-01-26 18:47 ` Sharath Srinivasan
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2026-01-25 13:47 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Sharath Srinivasan, Parav Pandit, linux-rdma, linux-kernel
On Mon, Jan 19, 2026 at 03:53:29PM -0400, Jason Gunthorpe wrote:
> On Mon, Jan 19, 2026 at 11:43:52AM -0800, Sharath Srinivasan wrote:
> > 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().
>
> You cannot change this locking without writing a huge commit message
> explaining in detail the reason why any change like this is safe..
We can drop this patch, it doesn't even apply.
Thanks
>
> Jason
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del
2026-01-25 13:47 ` Leon Romanovsky
@ 2026-01-26 18:47 ` Sharath Srinivasan
0 siblings, 0 replies; 4+ messages in thread
From: Sharath Srinivasan @ 2026-01-26 18:47 UTC (permalink / raw)
To: Leon Romanovsky, Jason Gunthorpe; +Cc: Parav Pandit, linux-rdma, linux-kernel
On 2026-01-25 5:47 a.m., Leon Romanovsky wrote:
> On Mon, Jan 19, 2026 at 03:53:29PM -0400, Jason Gunthorpe wrote:
>> On Mon, Jan 19, 2026 at 11:43:52AM -0800, Sharath Srinivasan wrote:
>>> 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().
>>
>> You cannot change this locking without writing a huge commit message
>> explaining in detail the reason why any change like this is safe..
>
> We can drop this patch, it doesn't even apply.
>
> Thanks
>
Thanks for trying. I'll send a rebased-v2 with an expanded commit message as Jason suggested.
Regards,
Sharath
>>
>> Jason
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-26 18:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 19:43 [PATCH rdma-next] RDMA/core: release devices_rwsem when calling device_del Sharath Srinivasan
2026-01-19 19:53 ` Jason Gunthorpe
2026-01-25 13:47 ` Leon Romanovsky
2026-01-26 18:47 ` Sharath Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox