Message ID | 20240131105912.3849767-1-zhaoyang.huang@unisoc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [PATCHv6,1/1] block: introduce content activity based ioprio | expand |
On Wed, Jan 31, 2024 at 06:59:12PM +0800, zhaoyang.huang wrote: > change of v6: replace the macro of bio_add_xxx by submit_bio which > iterating the bio_vec before launching bio to block layer Still wrong.
On Wed, Jan 31, 2024 at 9:23 PM Matthew Wilcox <willy@infradead.org> wrote: > > On Wed, Jan 31, 2024 at 06:59:12PM +0800, zhaoyang.huang wrote: > > change of v6: replace the macro of bio_add_xxx by submit_bio which > > iterating the bio_vec before launching bio to block layer > > Still wrong. I did some research on bio operations in the system and state my understanding here. I would like to have you review it and give me more details of the fault. thanks 1. REQ_OP_ZONE_xxx a. These operations are from driver/block layer/fs where we can keep driver/block layer using the legacy submit_bio by not including act_prio.h. b. most of fs's REQ_OP_ZONE_xxx will be handled by blkdev_zone_mgmt which is the same as 'a' c. __submit_zone_reset_cmd within f2fs use no page for REQ_OP_ZONE_RESET 2. other REQ_OP_<none>_READ/WRITE except REQ_OP_ZONE_xxx These operations all comes from driver and block layer as same as 1.a 3. direct_io keep fs/direct-io.c and fs/iomap/direct-io.c using legacy submit_bio 4. metadata, dentry Are these data also file pages? 5. normal REQ_OP_READ/WRITE/SYNC fs choose to use act based submit_bio by including act_ioprio.h in corresponding c file
On Thu, Feb 1, 2024 at 10:39 AM Zhaoyang Huang <huangzhaoyang@gmail.com> wrote: > > On Wed, Jan 31, 2024 at 9:23 PM Matthew Wilcox <willy@infradead.org> wrote: > > > > On Wed, Jan 31, 2024 at 06:59:12PM +0800, zhaoyang.huang wrote: > > > change of v6: replace the macro of bio_add_xxx by submit_bio which > > > iterating the bio_vec before launching bio to block layer > > > > Still wrong. > I did some research on bio operations in the system and state my > understanding here. I would like to have you review it and give me > more details of the fault. thanks > > 1. REQ_OP_ZONE_xxx > a. These operations are from driver/block layer/fs where we can keep > driver/block layer using the legacy submit_bio by not including > act_prio.h. > b. most of fs's REQ_OP_ZONE_xxx will be handled by blkdev_zone_mgmt > which is the same as 'a' > c. __submit_zone_reset_cmd within f2fs use no page for REQ_OP_ZONE_RESET > > 2. other REQ_OP_<none>_READ/WRITE except REQ_OP_ZONE_xxx > These operations all comes from driver and block layer as same as 1.a > > 3. direct_io > keep fs/direct-io.c and fs/iomap/direct-io.c using legacy submit_bio > > 4. metadata, dentry > Are these data also file pages? > > 5. normal REQ_OP_READ/WRITE/SYNC > fs choose to use act based submit_bio by including act_ioprio.h in > corresponding c file OR could I restrict the change by judging bio_op as below + if (bio_op(bio) == REQ_OP_READ || bio_op(bio) == REQ_OP_WRITE) + { class = IOPRIO_PRIO_CLASS(bio->bi_ioprio); level = IOPRIO_PRIO_LEVEL(bio->bi_ioprio); hint = IOPRIO_PRIO_HINT(bio->bi_ioprio); bio_for_each_bvec(bv, bio, iter) { page = bv.bv_page; activity += PageWorkingset(page) ? 1 : 0; cnt++; } if (activity >= cnt / 2) class = IOPRIO_CLASS_RT; else if (activity >= cnt / 4) class = max(IOPRIO_PRIO_CLASS(get_current_ioprio()), IOPRIO_CLASS_BE); bio->bi_ioprio = IOPRIO_PRIO_VALUE_HINT(class, level, hint); + } submit_bio(bio);
On Thu, Feb 01, 2024 at 12:05:23PM +0800, Zhaoyang Huang wrote:
> OR could I restrict the change by judging bio_op as below
bio_set_active_prio() like I said last time you posted a patch set.
diff --git a/include/linux/act_ioprio.h b/include/linux/act_ioprio.h new file mode 100644 index 000000000000..797304acdabc --- /dev/null +++ b/include/linux/act_ioprio.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ACT_IOPRIO_H +#define _ACT_IOPRIO_H + +#ifdef CONFIG_CONTENT_ACT_BASED_IOPRIO +#include <linux/bio.h> + +static __maybe_unused +void act_submit_bio(struct bio *bio) +{ + struct bio_vec bv; + struct bvec_iter iter; + struct page *page; + int class, level, hint; + int activity = 0; + int cnt = 0; + + class = IOPRIO_PRIO_CLASS(bio->bi_ioprio); + level = IOPRIO_PRIO_LEVEL(bio->bi_ioprio); + hint = IOPRIO_PRIO_HINT(bio->bi_ioprio); + bio_for_each_bvec(bv, bio, iter) { + page = bv.bv_page; + activity += PageWorkingset(page) ? 1 : 0; + cnt++; + } + if (activity >= cnt / 2) + class = IOPRIO_CLASS_RT; + else if (activity >= cnt / 4) + class = max(IOPRIO_PRIO_CLASS(get_current_ioprio()), IOPRIO_CLASS_BE); + bio->bi_ioprio = IOPRIO_PRIO_VALUE_HINT(class, level, hint); + submit_bio(bio); +} +#define submit_bio(bio) act_submit_bio(bio) +#endif +#endif diff --git a/mm/Kconfig b/mm/Kconfig index 264a2df5ecf5..e0e5a5a44ded 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1240,6 +1240,14 @@ config LRU_GEN_STATS from evicted generations for debugging purpose. This option has a per-memcg and per-node memory overhead. + +config CONTENT_ACT_BASED_IOPRIO + bool "Enable content activity based ioprio" + depends on LRU_GEN + default n + help + This item enable the feature of adjust bio's priority by + calculating its content's activity. # } config ARCH_SUPPORTS_PER_VMA_LOCK