block/dm: add resubmit_bio_noacct for fixing iops throttling
Subsystems (2)
cover block/dm: add resubmit_bio_noacct for fixing iops throttling
Hello Guys,
Commit 4f1e9630afe6 ("blk-throtl: optimize IOPS throttle for large IO scenarios") only fixes iops throttle for blk-mq drivers. This patchset adds API of resubmit_bio_noacct so that we can use it for fixing the same issue on bio based drivers.
Meantime fix the issue on device mapper via the added API, and the issue is reported by lining.
Ming Lei (2):
block: add resubmit_bio_noacct()
dm: use resubmit_bio_noacct to submit split bio
block/blk-core.c | 12 ++++++++++++ block/blk-merge.c | 4 +--- drivers/md/dm.c | 2 +- include/linux/blkdev.h | 1 + 4 files changed, 15 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 block: add resubmit_bio_noacct()
Add block layer API of resubmit_bio_noacct() for handling blk-throttle iops limit correctly. Typical use case is that bio split, and it isn't good to export blk_throtl_charge_bio_split() for drivers, so add new API for serving such purpose.
--- block/blk-core.c | 12 ++++++++++++ block/blk-merge.c | 4 +--- include/linux/blkdev.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)
block/blk-core.c +12 -0
@@ -910,6 +910,18 @@ void submit_bio_noacct(struct bio *bio) }EXPORT_SYMBOL (submit_bio_noacct); +/* +* Usually for submitting one bio which has been checked by +* submit_bio_checks already. The typical use case is for handling +* blk-throttle iops limit correctly. +*/ +void resubmit_bio_noacct (struct bio *bio) +{ +submit_bio_noacct (bio); +blk_throtl_charge_bio_split (bio); +} +EXPORT_SYMBOL (resubmit_bio_noacct); +/** * submit_bio - submit a bio to the block device layer for I/O * @bio: The &struct bio which describes the I/O
block/blk-merge.c +1 -3
@@ -366,10 +366,8 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,bio_chain (split, *bio);trace_block_split (split, (*bio)->bi_iter.bi_sector); -submit_bio_noacct (*bio); +resubmit_bio_noacct (*bio); *bio = split; - -blk_throtl_charge_bio_split (*bio); } }
include/linux/blkdev.h +1 -0
@@ -600,6 +600,7 @@ static inline unsigned int blk_queue_depth(struct request_queue *q)extern int blk_register_queue (struct gendisk *disk);extern void blk_unregister_queue (struct gendisk *disk);void submit_bio_noacct (struct bio *bio); +void resubmit_bio_noacct (struct bio *bio);extern int blk_lld_busy (struct request_queue *q);extern void blk_queue_split (struct bio **);
Signature · 1 line
2.31.1
Re: [PATCH 1/2] block: add resubmit_bio_noacct()
Quoted 4 lines · Ming Lei
Add block layer API of
resubmit_bio_noacct()for handling blk-throttle iops limit correctly. Typical use case is that bio split, and it isn't good to exportblk_throtl_charge_bio_split()for drivers, so add new API for serving such purpose.
Umm, submit_bio_noacct is meant exactly for this case of resubmitting a bio. We should not need another API for that.
Re: [PATCH 1/2] block: add resubmit_bio_noacct()
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Ming Lei
Add block layer API of
resubmit_bio_noacct()for handling blk-throttle iops limit correctly. Typical use case is that bio split, and it isn't good to exportblk_throtl_charge_bio_split()for drivers, so add new API for serving such purpose.Umm,
submit_bio_noacctis meant exactly for this case of resubmitting a bio. We should not need another API for that.
Ming is lifting code out of __blk_queue_split() for reuse (by DM in this instance, because it has its own bio_split+bio_chain).
Are you saying submit_bio_noacct() should be made to call blk_throtl_charge_bio_split() and blk_throtl_charge_bio_split() simply return if not a split bio? (not sure bio has enough context to know, other than looking at some side-effect change from bio_chain)
But Ming: your __blk_queue_split() change seems wrong. Prior to your patch __blk_queue_split() did:
bio_chain(split, *bio);submit_bio_noacct(*bio);
*bio = split;blk_throtl_charge_bio_split(*bio);
After your patch (effectively):
bio_chain(split, *bio);submit_bio_noacct(*bio);blk_throtl_charge_bio_split(bio);
*bio = split;
Maybe that was intended? (or maybe it doesn't matter because bio_split copies fields with bio_clone_fast())? Regardless, it is subtle.
Should blk_throtl_charge_bio_split() just be pushed down to bio_split()?
In general, such narrow hacks for how to properly resubmit split bios are asking for further trouble. As is, I'm having to triage new reports of bio-based accounting issues (which has called into question my hack/fix commit a1e1cb72d9649 ("dm: fix redundant IO accounting for bios that need splitting") that papered over this bigger issue of needing proper split IO accounting, so likely needs to be revisited).
We also have the much bigger issue of IO poll support (or lack-there-of) for split bios.
Mike
Re: [PATCH 1/2] block: add resubmit_bio_noacct()
Quoted 13 lines · Mike Snitzer
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Ming Lei
Add block layer API of
resubmit_bio_noacct()for handling blk-throttle iops limit correctly. Typical use case is that bio split, and it isn't good to exportblk_throtl_charge_bio_split()for drivers, so add new API for serving such purpose.Umm,
submit_bio_noacctis meant exactly for this case of resubmitting a bio. We should not need another API for that.
Quoted 6 lines
Ming is lifting code out of
__blk_queue_split()for reuse (by DM in this instance, because it has its own bio_split+bio_chain).Are you saying
submit_bio_noacct()should be made to callblk_throtl_charge_bio_split()andblk_throtl_charge_bio_split()simply return if not a split bio? (not sure bio has enough context to know,
DM or MD may submit split bio to underlying queue directly, so we can't do that simply. Also some FS may call bio_split() too.
Or we simply let blk_throtl_bio cover everything? That is basically what V1 did, and the only issue is that we can't run the account in case that submit_bio_noacct() is called from blk_throtl_dispatch_work_fn().
Quoted 12 lines
other than looking at some side-effect change from
bio_chain)But Ming: your
__blk_queue_split()change seems wrong. Prior to your patch__blk_queue_split()did:
bio_chain(split, *bio);submit_bio_noacct(*bio);
*bio = split;blk_throtl_charge_bio_split(*bio);After your patch (effectively):
Quoted 7 lines
bio_chain(split, *bio);submit_bio_noacct(*bio);blk_throtl_charge_bio_split(bio);
*bio = split;Maybe that was intended? (or maybe it doesn't matter because
bio_splitcopies fields withbio_clone_fast())? Regardless, it is subtle.
It doesn't matter, blk_throtl_charge_bio_split() just accounts bio number, here the split bio is submitted to the same queue.
Quoted 3 lines
Should
blk_throtl_charge_bio_split()just be pushed down tobio_split()?
It is fragile, will the bio allocated from bio_split() always submitted finally? or submitted to same queue?
Quoted 3 lines
In general, such narrow hacks for how to properly resubmit split bios are asking for further trouble.
I don't think it is hacks, it is one approach which has been verified as workable in blk-mq.
Quoted 5 lines
As is, I'm having to triage new
reports of bio-based accounting issues (which has called into question my hack/fix commita1e1cb72d9649("dm: fix redundant IO accounting for bios that need splitting") that papered over this bigger issue of needing proper split IO accounting, so likely needs to be revisited).
Here the issue is just about bio number accounting.
BTW, maybe you can follow blk-mq's way: just account after io is split, such as, move start_io_acct() to the end of __split_and_process_non_flush(), then you can just account io start once.
Thanks,
Ming
Re: [dm-devel] [PATCH 1/2] block: add resubmit_bio_noacct()
In reply to Mike SnitzerQuoted 7 lines · Mike Snitzer
Ming is lifting code out of
__blk_queue_split()for reuse (by DM in this instance, because it has its own bio_split+bio_chain).Are you saying
submit_bio_noacct()should be made to callblk_throtl_charge_bio_split()andblk_throtl_charge_bio_split()simply return if not a split bio? (not sure bio has enough context to know, other than looking at some side-effect change frombio_chain)
Yes.
Re: [PATCH 1/2] block: add resubmit_bio_noacct()
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
Quoted 4 lines · Ming Lei
Add block layer API of
resubmit_bio_noacct()for handling blk-throttle iops limit correctly. Typical use case is that bio split, and it isn't good to exportblk_throtl_charge_bio_split()for drivers, so add new API for serving such purpose.Umm,
submit_bio_noacctis meant exactly for this case of resubmitting a bio. We should not need another API for that.
Follows the background of the issue first:
1) IOPS limit throttle needs to cover split bio since iostat accounts split bio actually, and user space setup iops limit throttle by the feedback from iostat/diskstat;
2) block throttle is block layer internal stuff, and we shouldn't expose blk_throtl_charge_bio_split() to driver.
Maybe rename the new API as submit_split_bio_noacct(), but we can't reuse submit_bio_noacct() simply, otherwise blk_throtl_charge_bio_split() needs to be exported.
Another ides is to clearing BIO_THROTTLED before calling submit_bio_noacct(), meantime blk-throttle code needs to change to avoid double accounting of bio bytes, so the caller of submit_bio_noacct() still needs some change. This way can get smooth IOPS throttle, but needs to call __blk_throtl_bio for split bio one more time.
Or other idea for this bio split vs. iops limit issue?
Thanks,
Ming
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] [PATCH 1/2] block: add resubmit_bio_noacct()
Quoted 6 lines · Ming Lei
2) block throttle is block layer internal stuff, and we shouldn't expose
blk_throtl_charge_bio_split()to driver.Maybe rename the new API as
submit_split_bio_noacct(), but we can't reusesubmit_bio_noacct()simply, otherwiseblk_throtl_charge_bio_split()needs to be exported.
submit_bio_noacct should only ever be used for resubmitting bios that came up from the upper layer, although they might not always be "split". blk_throtl_charge_bio_split
Quoted 7 lines
Another ides is to clearing
BIO_THROTTLEDbefore callingsubmit_bio_noacct(), meantime blk-throttle code needs to change to avoid double accounting of bio bytes, so the caller ofsubmit_bio_noacct()still needs some change. This way can get smooth IOPS throttle, but needs to call__blk_throtl_biofor split bio one more time.Or other idea for this bio split vs. iops limit issue?
Well, if you want a helper specificly for splits, add one that actally specifically handles splits and makes the callers life easier, something like:
void bio_submit_splice(struct bio *split, struct bio *orig)
{
split->bi_opf |= REQ_NOMERGE;
trace_block_split(split, orig->bi_iter.bi_sector);
submit_bio_noacct(orig);
blk_throtl_charge_bio_split(orig);
}including a proper kerneldoc comment.
But I still fail to grasp how a split is so different from just resubmitting a not split bio.
PATCH 2/2 dm: use resubmit_bio_noacct to submit split bio
In reply to Ming Leilining reported that blk-throttle iops limit doesn't work correctly for dm-thin. Turns out it is same issue with the one addressed by commit 4f1e9630afe6 ("blk-throtl: optimize IOPS throttle for large IO scenarios").
So use the new added block layer API for addressing the same issue.
--- drivers/md/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +1 -1
@@ -1562,7 +1562,7 @@ static void __split_and_process_bio(struct mapped_device *md,bio_chain (b, bio);trace_block_split (b, bio->bi_iter.bi_sector); -submit_bio_noacct (bio); +resubmit_bio_noacct (bio); } }
Signature · 6 lines
2.31.1 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel