[2/2] fs: introduce content activity based ioprio

Message ID 20240221075338.598280-3-zhaoyang.huang@unisoc.com
State New
Headers
Series *** introduce content activity based ioprio *** |

Commit Message

zhaoyang.huang Feb. 21, 2024, 7:53 a.m. UTC
  From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

This commit would like to introduce content activity based ioprio into
general aops and def_blk_aops read/write API, which account the
content's(folio) activity and set the ioprio_class accordingly. This
change do NOT violate previous ioprio policy but only promote the
value if the activities raise to certain proportion, that can be
deemed as both of the IO launcher and the content's are important
for raising the priority.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 fs/iomap/buffered-io.c | 3 +++
 fs/mpage.c             | 2 ++
 2 files changed, 5 insertions(+)
  

Patch

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 5db54ca29a35..5079395d6823 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -390,6 +390,7 @@  static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
 		ctx->bio->bi_iter.bi_sector = sector;
 		ctx->bio->bi_end_io = iomap_read_end_io;
 		bio_add_folio_nofail(ctx->bio, folio, plen, poff);
+		bio_set_active_ioprio_folio(ctx->bio, folio);
 	}
 
 done:
@@ -624,6 +625,7 @@  static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
 	bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
 	bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
 	bio_add_folio_nofail(&bio, folio, plen, poff);
+	bio_set_active_ioprio_folio(&bio, folio);
 	return submit_bio_wait(&bio);
 }
 
@@ -1742,6 +1744,7 @@  iomap_add_to_ioend(struct inode *inode, loff_t pos, struct folio *folio,
 	if (!bio_add_folio(wpc->ioend->io_bio, folio, len, poff)) {
 		wpc->ioend->io_bio = iomap_chain_bio(wpc->ioend->io_bio);
 		bio_add_folio_nofail(wpc->ioend->io_bio, folio, len, poff);
+		bio_set_active_ioprio_folio(wpc->ioend->io_bio, folio);
 	}
 
 	if (ifs)
diff --git a/fs/mpage.c b/fs/mpage.c
index 242e213ee064..f209e5860423 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -308,6 +308,7 @@  static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
 		goto alloc_new;
 	}
 
+	bio_set_active_ioprio_folio(args->bio, folio);
 	relative_block = block_in_file - args->first_logical_block;
 	nblocks = map_bh->b_size >> blkbits;
 	if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
@@ -626,6 +627,7 @@  static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
 		goto alloc_new;
 	}
 
+	bio_set_active_ioprio_folio(bio, folio);
 	clean_buffers(&folio->page, first_unmapped);
 
 	BUG_ON(folio_test_writeback(folio));