RDMA/core: release devices_rwsem when calling device_del
PATCH 1/1 RDMA/core: release devices_rwsem when calling device_del
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().
--- drivers/infiniband/core/device.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/infiniband/core/device.c +12 -2
@@ -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)
Quoted 5 lines · Sharath Srinivasan
The sync strategy in
remove_all_compat_devs()can improved by adopting that ofrdma_dev_exit_net()which releasesdevices_rwsembefore 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
Quoted 9 lines · Jason Gunthorpe
Quoted 5 lines · Sharath Srinivasan
The sync strategy in
remove_all_compat_devs()can improved by adopting that ofrdma_dev_exit_net()which releasesdevices_rwsembefore 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
Quoted 3 lines
Jason
Quoted 6 lines · Leon Romanovsky
Quoted 5 lines · Jason Gunthorpe
Quoted 4 lines · Sharath Srinivasan
The sync strategy in
remove_all_compat_devs()can improved by adopting that ofrdma_dev_exit_net()which releasesdevices_rwsembefore calling remove_one_compat_dev()/device_del().
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
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
Quoted 4 lines
Quoted 3 lines
Jason