RFC block: remove q->sysfs_dir_lock and fix race updating nr_hw_queue
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 RFC Latest2 patches 4 repliesApplied
- v2 RFC2 patches 3 repliesSuperseded
- v1 RFC1 patch 2 repliesSuperseded
Changes in v3 from the cover letter
- few nitpicking fixes in the second patch (hch)
- Link to v2: https://lore.kernel.org/all/[email protected]/
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | block: get rid of request queue ->sysfs_dir_lockblock/ block/ block/ +2 more | +5 | 1 reply | |
| 2/2 | block: fix nr_hw_queue update racing with disk addition/removalblock/ | +9 | 2 replies |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Christoph Hellwig | Hannes Reinecke |
|---|---|---|
| 1/2 | R-b | R-b |
| 2/2 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCHv3 0/2] block: remove q->sysfs_dir_lock and fix race updating nr_hw_queue
Hi,
There're two patches in this patchest.
The first patch removes redundant q->sysfs_dir_lock.
The second patch fixes nr_hw_queue update racing with disk addition/ removal.
In the current implementation we use q->sysfs_dir_lock for protecting kobject addition/deletion while we register/unregister blk-mq with sysfs. However the sysfs/kernfs internal implementation already protects against the simultaneous addtion/deletion of kobjects. So in that sense use of q->sysfs_dir_lock appears redundant.
Furthermore, there're few other callsites in the current code where we use q->sysfs_dir_lock along with q->sysfs_lock while addition/deletion of independent access ranges for a disk under sysfs. Please refer, disk_ register_independent_access_ranges() and disk_unregister_independent_ access_ranges(). Here as well we could easily remove use of q->sysfs_dir_ lock.
The only thing which q->syfs_dir_lock appears to protect is the use of variable q->mq_sysfs_init_done. However this could be solved by converting q->mq_sysfs_init_done to an atomic variable.
In past few days, we have seen many lockdep splat in block layer and getting rid of this one might help reduce some contention as well we need to worry less about lock ordering wrt to q->sysfs_dir_lock. The first patch helps fix this.
The second patch addresses a potential race between nr_hw_queue update and disk addition/removal. The __blk_mq_update_nr_hw_queues function removes and then adds hctx sysfs files. Similarly the disk addition/ removal code also adds or remove the hctx sysfs files. So it's quite possible that disk addition/removal code could race with __blk_mq_update_ nr_hw_queues() while it adds/deletes hctx sysfs files. Apparently, __blk_mq_update_nr_hw_queues() holds q->tag_list_lock while it runs, and so to avoid race between __blk_mq_update_nr_hw_queues() and disk addition/removal code, we should hold the same q->tag_list_lock while we add/delete hctx sysfs files while registering/uregistering disk queue. So the second patch in the series helps fix this race condition which may manifests while we add/remove hctx sysfs files.
I ran blktests and xfstests with lockdep configured to ensure that above changes don't generate lockdep spalt.
Nilay Shroff (2):
block: get rid of request queue ->sysfs_dir_lock
block: fix nr_hw_queue update racing with disk addition/removal
Changes from v2:
- few nitpicking fixes in the second patch (hch)
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changes from v1:
- remove q->sysfs_init_done and replace it with registered queue
flag (hch)
- fix nr_hw_queue update racing with disk addition/removal (hch)
- Link to v1: https://lore.kernel.org/all/[email protected]/
Nilay Shroff (2):
block: get rid of request queue ->sysfs_dir_lock
block: fix nr_hw_queue update racing with disk addition/removal
block/blk-core.c | 1 - block/blk-ia-ranges.c | 4 ---- block/blk-mq-sysfs.c | 40 ++++++++++++++-------------------------- block/blk-sysfs.c | 5 ----- include/linux/blkdev.h | 3 --- 5 files changed, 14 insertions(+), 39 deletions(-)
Signature · 1 line
2.47.1