Message ID | 20231213104216.27845-2-hongyu.jin.cn@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v5,1/5] block: Fix bio IO priority setting | expand |
On Wed, Dec 13 2023 at 5:42P -0500, Hongyu Jin <hongyu.jin.cn@gmail.com> wrote: > From: Hongyu Jin <hongyu.jin@unisoc.com> > > Move bio_set_ioprio() into submit_bio(): > 1. Only call bio_set_ioprio() once to set the priority of original bio, > the bio that cloned and splited from original bio will auto inherit > the priority of original bio in clone process. > > 2. The IO priority can be passed to module that implement > struct gendisk::fops::submit_bio, help resolve some > of the IO priority loss issues. > > This patch depends on commit 82b74cac2849 ("blk-ioprio: Convert from > rqos policy to direct call") > > Fixes: a78418e6a04c ("block: Always initialize bio IO priority on submit") > > Co-developed-by: Yibin Ding <yibin.ding@unisoc.com> > Signed-off-by: Yibin Ding <yibin.ding@unisoc.com> > Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com> Would be nice to get this block core fix upstream ASAP independent of your various DM changes. Please simplify this patch's header like was requested in review of v4: https://patchwork.kernel.org/project/dm-devel/patch/20231212111150.18155-2-hongyu.jin.cn@gmail.com/
Mike Snitzer <snitzer@kernel.org> 于2023年12月14日周四 00:58写道: > > On Wed, Dec 13 2023 at 5:42P -0500, > Hongyu Jin <hongyu.jin.cn@gmail.com> wrote: > > > From: Hongyu Jin <hongyu.jin@unisoc.com> > > > > Move bio_set_ioprio() into submit_bio(): > > 1. Only call bio_set_ioprio() once to set the priority of original bio, > > the bio that cloned and splited from original bio will auto inherit > > the priority of original bio in clone process. > > > > 2. The IO priority can be passed to module that implement > > struct gendisk::fops::submit_bio, help resolve some > > of the IO priority loss issues. > > > > This patch depends on commit 82b74cac2849 ("blk-ioprio: Convert from > > rqos policy to direct call") > > > > Fixes: a78418e6a04c ("block: Always initialize bio IO priority on submit") > > > > Co-developed-by: Yibin Ding <yibin.ding@unisoc.com> > > Signed-off-by: Yibin Ding <yibin.ding@unisoc.com> > > Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com> > > Would be nice to get this block core fix upstream ASAP independent of > your various DM changes. dm modification depends on block modification to have effect, so it is reviewed together. > > Please simplify this patch's header like was requested in review of v4: > https://patchwork.kernel.org/project/dm-devel/patch/20231212111150.18155-2-hongyu.jin.cn@gmail.com/ ok, i will send the header。
From: Hongyu Jin <hongyu.jin@unisoc.com>
A high-priority task obtains data from the dm-verity device using the
RT IO priority, during the verification, the IO reading FEC and hash
by kworker loses the RT priority and is blocked by the low-priority IO.
dm-crypt has the same problem in the process of writing data.
This is because io_context and blkcg are missing.
Move bio_set_ioprio() into submit_bio():
1. Only call bio_set_ioprio() once to set the priority of original bio,
the bio that cloned and splited from original bio will auto inherit
the priority of original bio in clone process.
2. Make the IO priority of the original bio to be passed to dm,
and the dm target inherits the IO priority as needed.
All changes are based on commit 9bacdd8996c7 ("Merge tag 'for-6.7-rc1-tag'
of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux")
on the master branch.
Changes in v5:
- Rewrite patch 2, add ioprio parameter in dm_io();
- Modify dm_io() in patch 3
Changes in v4:
- Modify commit message by Suggestion
- Modify patch for dm-crypt
Changes in v3:
- Split patch for device-mapper
- Add patch to fix dm-crypy I/O priority question
- Add block patch to review together
- Fix some error in v2 patch
Changes in v2:
- Add ioprio field in struct dm_io_region
- Initial struct dm_io_region::ioprio to IOPRIO_DEFAULT
- Add two interface
Hongyu Jin (5):
block: Fix bio IO priority setting
dm: Support I/O priority for dm_io()
dm-bufio: Support I/O priority
dm verity: Fix I/O priority lost when read FEC and hash
dm-crypt: Fix lost ioprio when queuing write bios
block/blk-core.c | 10 +++++
block/blk-mq.c | 11 ------
drivers/md/dm-bufio.c | 39 ++++++++++---------
drivers/md/dm-crypt.c | 1 +
drivers/md/dm-ebs-target.c | 8 ++--
drivers/md/dm-integrity.c | 12 +++---
drivers/md/dm-io.c | 23 ++++++-----
drivers/md/dm-kcopyd.c | 4 +-
drivers/md/dm-log.c | 4 +-
drivers/md/dm-raid1.c | 6 +--
drivers/md/dm-snap-persistent.c | 8 ++--
drivers/md/dm-verity-fec.c | 5 ++-
drivers/md/dm-verity-target.c | 8 +++-
drivers/md/dm-writecache.c | 8 ++--
drivers/md/persistent-data/dm-block-manager.c | 6 +--
include/linux/dm-bufio.h | 5 +--
include/linux/dm-io.h | 3 +-
17 files changed, 85 insertions(+), 76 deletions(-)
On Mon, Dec 18, 2023 at 09:27:41AM +0800, Hongyu Jin wrote: > All changes are based on commit 9bacdd8996c7 ("Merge tag 'for-6.7-rc1-tag' > of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux") > on the master branch. That's from last month, and the patchset does not apply to the latest mainline. Can you make sure to use an up-to-date tree? Thanks. - Eric
diff --git a/block/blk-core.c b/block/blk-core.c index fdf25b8d6e78..68158c327aea 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -49,6 +49,7 @@ #include "blk-pm.h" #include "blk-cgroup.h" #include "blk-throttle.h" +#include "blk-ioprio.h" struct dentry *blk_debugfs_root; @@ -809,6 +810,14 @@ void submit_bio_noacct(struct bio *bio) } EXPORT_SYMBOL(submit_bio_noacct); +static void bio_set_ioprio(struct bio *bio) +{ + /* Nobody set ioprio so far? Initialize it based on task's nice value */ + if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) + bio->bi_ioprio = get_current_ioprio(); + blkcg_set_ioprio(bio); +} + /** * submit_bio - submit a bio to the block device layer for I/O * @bio: The &struct bio which describes the I/O @@ -831,6 +840,7 @@ void submit_bio(struct bio *bio) count_vm_events(PGPGOUT, bio_sectors(bio)); } + bio_set_ioprio(bio); submit_bio_noacct(bio); } EXPORT_SYMBOL(submit_bio); diff --git a/block/blk-mq.c b/block/blk-mq.c index e2d11183f62e..a6e2609df9c9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -40,7 +40,6 @@ #include "blk-stat.h" #include "blk-mq-sched.h" #include "blk-rq-qos.h" -#include "blk-ioprio.h" static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd); @@ -2922,14 +2921,6 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q, return rq; } -static void bio_set_ioprio(struct bio *bio) -{ - /* Nobody set ioprio so far? Initialize it based on task's nice value */ - if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) - bio->bi_ioprio = get_current_ioprio(); - blkcg_set_ioprio(bio); -} - /** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer. @@ -2963,8 +2954,6 @@ void blk_mq_submit_bio(struct bio *bio) if (!bio_integrity_prep(bio)) return; - bio_set_ioprio(bio); - rq = blk_mq_get_cached_request(q, plug, &bio, nr_segs); if (!rq) { if (!bio)