* [PATCH V2] block: mark GFP_NOIO around sysfs ->store()
@ 2025-01-13 8:41 Ming Lei
2025-01-13 8:50 ` Thomas Hellström
0 siblings, 1 reply; 4+ messages in thread
From: Ming Lei @ 2025-01-13 8:41 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Ming Lei, Christoph Hellwig, John Garry, Thomas Hellström,
stable
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()
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Closes: https://lore.kernel.org/linux-block/ead7c5ce5138912c1f3179d62370b84a64014a38.camel@linux.intel.com/
Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IO schedulers")
Cc: stable@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
V2:
- add Closes & Reviewed-by & Fixes tag
block/blk-sysfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e828be777206..e09b455874bf 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -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;
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH V2] block: mark GFP_NOIO around sysfs ->store()
2025-01-13 8:41 [PATCH V2] block: mark GFP_NOIO around sysfs ->store() Ming Lei
@ 2025-01-13 8:50 ` Thomas Hellström
2025-01-13 9:01 ` Ming Lei
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Hellström @ 2025-01-13 8:50 UTC (permalink / raw)
To: Ming Lei, Jens Axboe, linux-block; +Cc: Christoph Hellwig, John Garry, stable
Hi!
On Mon, 2025-01-13 at 16:41 +0800, Ming Lei wrote:
> 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()
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: John Garry <john.g.garry@oracle.com>
> Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Closes:
> https://lore.kernel.org/linux-block/ead7c5ce5138912c1f3179d62370b84a64014a38.camel@linux.intel.com/
> Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IO
> schedulers")
Does this fix also the #2 lockdep splat in that email?
Thanks,
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] block: mark GFP_NOIO around sysfs ->store()
2025-01-13 8:50 ` Thomas Hellström
@ 2025-01-13 9:01 ` Ming Lei
2025-01-13 9:05 ` Thomas Hellström
0 siblings, 1 reply; 4+ messages in thread
From: Ming Lei @ 2025-01-13 9:01 UTC (permalink / raw)
To: Thomas Hellström
Cc: Jens Axboe, linux-block, Christoph Hellwig, John Garry, stable
On Mon, Jan 13, 2025 at 09:50:37AM +0100, Thomas Hellström wrote:
> Hi!
>
> On Mon, 2025-01-13 at 16:41 +0800, Ming Lei wrote:
> > 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()
> >
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Reviewed-by: John Garry <john.g.garry@oracle.com>
> > Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Closes:
> > https://lore.kernel.org/linux-block/ead7c5ce5138912c1f3179d62370b84a64014a38.camel@linux.intel.com/
> > Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IO
> > schedulers")
>
> 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/20250110054726.1499538-1-hch@lst.de/
Thanks,
Ming
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] block: mark GFP_NOIO around sysfs ->store()
2025-01-13 9:01 ` Ming Lei
@ 2025-01-13 9:05 ` Thomas Hellström
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Hellström @ 2025-01-13 9:05 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Christoph Hellwig, John Garry, stable
On Mon, 2025-01-13 at 17:01 +0800, Ming Lei wrote:
> On Mon, Jan 13, 2025 at 09:50:37AM +0100, Thomas Hellström wrote:
> > Hi!
> >
> > On Mon, 2025-01-13 at 16:41 +0800, Ming Lei wrote:
> > > 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()
> > >
> > > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > > Reviewed-by: John Garry <john.g.garry@oracle.com>
> > > Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > > Closes:
> > > https://lore.kernel.org/linux-block/ead7c5ce5138912c1f3179d62370b84a64014a38.camel@linux.intel.com/
> > > Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable
> > > IO
> > > schedulers")
> >
> > 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
>
> https://lore.kernel.org/linux-block/20250110054726.1499538-1-hch@lst.de/
>
>
> Thanks,
> Ming
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-13 9:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 8:41 [PATCH V2] block: mark GFP_NOIO around sysfs ->store() Ming Lei
2025-01-13 8:50 ` Thomas Hellström
2025-01-13 9:01 ` Ming Lei
2025-01-13 9:05 ` Thomas Hellström
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox