Skip to contentSkip to conversation

block: set noio context in submit_bio_noacct_nocheck

RFC PATCH In review Christoph Hellwig 3 participants 7 messages Jan 24, 2024 – Jan 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 block: set noio context in submit_bio_noacct_nocheck

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

---
 block/blk-core.c | 4 ++++
 1 file changed, 4 insertions(+)
block/blk-core.c +4 -0
index 11342af420d0c4..b85ef8a0fdf6a0 100644
@@ -691,6 +691,8 @@ static void __submit_bio_noacct_mq(struct bio *bio)
 
 void submit_bio_noacct_nocheck(struct bio *bio)
 {
+	unsigned int noio_flag = memalloc_noio_save();
+
 	blk_cgroup_bio_start(bio);
 	blkcg_bio_issue_init(bio);
 
@@ -715,6 +717,8 @@ void submit_bio_noacct_nocheck(struct bio *bio)
 		__submit_bio_noacct_mq(bio);
 	else
 		__submit_bio_noacct(bio);
+
+	memalloc_noio_restore(noio_flag);
 }
 
 /**
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 4 lines · Christoph Hellwig

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

I really don't like adding this for no good reason. Who's doing non NOIO allocations down from this path?

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 8 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

I really don't like adding this for no good reason. Who's doing non NOIO allocations down from this path?

If there is a non-NOIO allocation right now that would be a bug, although I would not be surprised if we had a few of them.

The reason to add this is a different one: The MM folks want to get rid of GFP_NOIO and GFP_NOFS and replace them by these context.

And doing this in the submission path and kblockd will cover almost all of the noio context, with the rest probably covered by other workqueues. And this feels a lot less error prone than requiring every driver to annotate the context in their submission routines.

maintainer
#3 lore raw
Quoted 13 lines · Christoph Hellwig
Quoted 8 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

I really don't like adding this for no good reason. Who's doing non NOIO allocations down from this path?

If there is a non-NOIO allocation right now that would be a bug, although I would not be surprised if we had a few of them.

Quoted 7 lines

The reason to add this is a different one: The MM folks want to get rid of GFP_NOIO and GFP_NOFS and replace them by these context.

And doing this in the submission path and kblockd will cover almost all of the noio context, with the rest probably covered by other workqueues. And this feels a lot less error prone than requiring every driver to annotate the context in their submission routines.

I think it'd be much better to add a DEBUG protected aid that checks for violating allocations. Nothing that isn't buggy should trigger this, right now, and then we could catch problems if there are any. If we do the save/restore there and call it good, then we're going to be stuck with that forever. Regardless of whether it's actually needed or not.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 22 lines · Jens Axboe
Quoted 13 lines · Christoph Hellwig
Quoted 8 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

I really don't like adding this for no good reason. Who's doing non NOIO allocations down from this path?

If there is a non-NOIO allocation right now that would be a bug, although I would not be surprised if we had a few of them.

Quoted 7 lines

The reason to add this is a different one: The MM folks want to get rid of GFP_NOIO and GFP_NOFS and replace them by these context.

And doing this in the submission path and kblockd will cover almost all of the noio context, with the rest probably covered by other workqueues. And this feels a lot less error prone than requiring every driver to annotate the context in their submission routines.

Quoted 5 lines

I think it'd be much better to add a DEBUG protected aid that checks for violating allocations. Nothing that isn't buggy should trigger this, right now, and then we could catch problems if there are any. If we do the save/restore there and call it good, then we're going to be stuck with that forever. Regardless of whether it's actually needed or not.

Nono, you don't understand. The plan is to remove GFP_NOIO entirely. Allocations should be done with GFP_KERNEL while under a memalloc_noio_save().

maintainer
#5 lore raw
Quoted 30 lines · On Thu, Jan 25, 2024 at 9:11?AM Matthew Wilcox <[email protected]> wrote:
Quoted 22 lines · Jens Axboe
Quoted 13 lines · Christoph Hellwig
Quoted 8 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig

Make sure all in-line block layer submission runs in noio reclaim context. This is a big step towards allowing GFP_NOIO, the other one would be to have noio (and nofs for that matter) workqueues for kblockd and driver internal workqueues.

I really don't like adding this for no good reason. Who's doing non NOIO allocations down from this path?

If there is a non-NOIO allocation right now that would be a bug, although I would not be surprised if we had a few of them.

Quoted 7 lines

The reason to add this is a different one: The MM folks want to get rid of GFP_NOIO and GFP_NOFS and replace them by these context.

And doing this in the submission path and kblockd will cover almost all of the noio context, with the rest probably covered by other workqueues. And this feels a lot less error prone than requiring every driver to annotate the context in their submission routines.

Quoted 5 lines

I think it'd be much better to add a DEBUG protected aid that checks for violating allocations. Nothing that isn't buggy should trigger this, right now, and then we could catch problems if there are any. If we do the save/restore there and call it good, then we're going to be stuck with that forever. Regardless of whether it's actually needed or not.

Quoted 3 lines

Nono, you don't understand. The plan is to remove GFP_NOIO entirely. Allocations should be done with GFP_KERNEL while under a memalloc_noio_save().

I do understand, but thanks for the vote of confidence. Place the save/restore higher up, most likely actual IO submission isn't going to be the only (or even major) allocation potentially needed for the IO.

Signature · 1 line
Jens Axboe
#6 lore raw
Quoted 7 lines · Jens Axboe
Quoted 3 lines

Nono, you don't understand. The plan is to remove GFP_NOIO entirely. Allocations should be done with GFP_KERNEL while under a memalloc_noio_save().

I do understand, but thanks for the vote of confidence. Place the save/restore higher up, most likely actual IO submission isn't going to be the only (or even major) allocation potentially needed for the IO.

NOIO is defined as allocations that will not recurse into the I/O stack. So for anything block based, entering the block layer is literally the defined boundary where it should be used below. So no, wrapping every submit_bio into a context annotation doesn't make much sense.