Re: [PATCHv7 1/1] block: introduce content activity based ioprio

From: Zhaoyang Huang
Date: Mon Feb 05 2024 - 02:13:42 EST


On Mon, Feb 5, 2024 at 3:08 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Mon, Feb 05, 2024 at 01:57:05PM +0800, zhaoyang.huang wrote:
> > +/*
> > + * bio_set_active_ioprio() is helper function for fs to adjust the bio's ioprio via
> > + * calculating the content's activity which measured from MGLRU.
> > + * The file system should call this function before submit_bio for the buffered
> > + * read/write/sync.
> > + */
> > +#ifdef CONFIG_BLK_CONT_ACT_BASED_IOPRIO
> > +void bio_set_active_ioprio(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);
> > + /*apply legacy ioprio policy on RT task*/
> > + if (task_is_realtime(current)) {
> > + bio->bi_ioprio = IOPRIO_PRIO_VALUE_HINT(IOPRIO_CLASS_RT, level, hint);
> > + return;
> > + }
> > + bio_for_each_bvec(bv, bio, iter) {
> > + page = bv.bv_page;
>
> I gave you the prototype:
>
> : No, stop this. What the filesystem needs to do is not
> : s/bio_add_folio/act_bio_add_folio/. There needs to be an API to set the
> : bio prio; something like:
> :
> : bio_set_active_prio(bio, folio);
>
> Do not iterate over the bio. Use the folio provided to set the prio.
ok. I should miss the above information. I will update them in the next version
>
> Or is there some reason this doesn't work?