block: mark GFP_NOIO around sysfs ->store()
Subsystems (2)
PATCH v2 1/1 block: mark GFP_NOIO around sysfs ->store()
sysfs ->store is called with queue freezed, meantime we have several ->store() callbacks(update_nr_requests, wbt, scheduler) to allocate memory with GFP_KERNEL which may run into direct reclaim code path, then potential deadlock can be caused.
Fix the issue by marking NOIO around sysfs ->store()
---
V2:
- add Closes & Reviewed-by & Fixes tag
block/blk-sysfs.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-sysfs.c +3 -0
@@ -681,6 +681,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,struct queue_sysfs_entry *entry =to_queue (attr); struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);struct request_queue *q = disk->queue; +unsigned int noio_flag;ssize_t res;if (!entry->store_limit && !entry->store)
@@ -711,7 +712,9 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,mutex_lock (&q->sysfs_lock);blk_mq_freeze_queue (q); + noio_flag =memalloc_noio_save (); res = entry->store (disk, page, length); +memalloc_noio_restore (noio_flag);blk_mq_unfreeze_queue (q);mutex_unlock (&q->sysfs_lock);return res;
Signature · 1 line
2.44.0
Hi!
Quoted 7 lines · Ming Lei
sysfs ->store is called with queue freezed, meantime we have several ->store()
callbacks(update_nr_requests, wbt, scheduler)to allocate memory withGFP_KERNELwhich may run into direct reclaim code path, then potential deadlock can be caused.Fix the issue by marking NOIO around sysfs ->store()
Quoted 7 lines
Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by John Garry <[email protected]>Reported-by Thomas Hellström <[email protected]>Closes:
https://lore.kernel.org/linux-block/[email protected]/Fixes bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IOschedulers")
Does this fix also the #2 lockdep splat in that email? Thanks,
Thomas
Quoted 18 lines · Thomas Hellström
Hi!
Quoted 7 lines · Ming Lei
sysfs ->store is called with queue freezed, meantime we have several ->store()
callbacks(update_nr_requests, wbt, scheduler)to allocate memory withGFP_KERNELwhich may run into direct reclaim code path, then potential deadlock can be caused.Fix the issue by marking NOIO around sysfs ->store()
Quoted 7 lines
Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by John Garry <[email protected]>Reported-by Thomas Hellström <[email protected]>Closes:
https://lore.kernel.org/linux-block/[email protected]/Fixes bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IOschedulers")
Quoted 1 line
Does this fix also the #2 lockdep splat in that email?
No.
The #2 splat fix has been merged to for-6.14/block, and this patch only covers the one reported in the Closes link.
https://lore.kernel.org/linux-block/[email protected]/
Thanks,
Ming
Quoted 23 lines · Ming Lei
Quoted 22 lines · Thomas Hellström
Hi!
Quoted 18 lines · Ming Lei
sysfs ->store is called with queue freezed, meantime we have several
->store()callbacks(update_nr_requests, wbt, scheduler)to allocate
memory withGFP_KERNELwhich may run into direct reclaim code path,
then potential deadlock can be caused.Fix the issue by marking NOIO around sysfs ->store()
Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by John Garry <[email protected]>Reported-by Thomas Hellström <[email protected]>Closes:
https://lore.kernel.org/linux-block/[email protected]/Fixes bd166ef183c2 ("blk-mq-sched: add framework for MQ capableIO
schedulers")
Quoted 7 lines
Quoted 1 line
Does this fix also the #2 lockdep splat in that email?
No.
The #2 splat fix has been merged to for-6.14/block, and this patch only
covers the one reported in the Closes link.
I actually reported two new splats in the Closes link.
(The second was found when using the suggested lockdep priming, but would ofc emerge sooner or later without it). I'm pretty sure Christoph's series was applied when that patch emerged, but I can retry if you want.
Thanks,
Thomas
Quoted 7 lines
https://lore.kernel.org/linux-block/[email protected]/
Thanks,
Ming