public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Zhaoyang Huang <huangzhaoyang@gmail.com>
Cc: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	steve.kang@unisoc.com
Subject: Re: [RFC PATCH 1/1] block: introduce activity based ioprio
Date: Thu, 18 Jan 2024 08:25:03 -0700	[thread overview]
Message-ID: <33cef193-044a-4f25-8248-b10a9db9e0ba@kernel.dk> (raw)
In-Reply-To: <CAGWkznGSreuTvYUoqhL0KaWEg-NpBazfjAcjGLJ3Oh8puzQF0g@mail.gmail.com>

On 1/18/24 12:48 AM, Zhaoyang Huang wrote:
>>> +static enum dd_prio dd_req_ioprio(struct request *rq)
>>> +{
>>> +     enum dd_prio prio;
>>> +     const u8 ioprio_class = dd_rq_ioclass(rq);
>>> +#ifdef CONFIG_ACTIVITY_BASED_IOPRIO
>>> +     struct bio *bio;
>>> +     struct bio_vec bv;
>>> +     struct bvec_iter iter;
>>> +     struct page *page;
>>> +     int gen = 0;
>>> +     int cnt = 0;
>>> +
>>> +     if (req_op(rq) == REQ_OP_READ) {
>>> +             __rq_for_each_bio(bio, rq) {
>>> +                     bio_for_each_bvec(bv, bio, iter) {
>>> +                             page = bv.bv_page;
>>> +                             gen += PageWorkingset(page) ? 1 : 0;
>>> +                             cnt++;
>>> +                     }
>>> +             }
>>> +             prio = (gen >= cnt / 2) ? ioprio_class_to_prio[IOPRIO_CLASS_RT] :
>>> +                     ioprio_class_to_prio[ioprio_class];
>>> +     } else
>>> +             prio = ioprio_class_to_prio[ioprio_class];
>>> +#else
>>> +     prio = ioprio_class_to_prio[ioprio_class];
>>> +#endif
>>> +     return prio;
>>> +}
>>
>> This is pretty awful imho, you're iterating the pages which isn't
>> exactly cheap. There's also a ternary operator (get rid of it), and
>> magic cnt / 2 which isn't even explained.

> ok. The iterating is on purpose here to not enlarge the bio and
> request structure. The magic number would be replaced by an more
> sensible criteria like MULTI_GEN's thrashing tier things.

It's totally backwards, you're adding code that both dips into parts it
very much should not, and attempting to fix things up after the fact.
Again, not passing any judgement on whether this kind of thing makes
sense, but if it did, you'd do it when adding the page to the bio, as I
mentioned elsewhere in the email. There's no need to grow struct bio, it
already has an ioprio field.

-- 
Jens Axboe


  reply	other threads:[~2024-01-18 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17  9:23 [RFC PATCH 1/1] block: introduce activity based ioprio zhaoyang.huang
2024-01-17 15:20 ` Jens Axboe
2024-01-18  7:48   ` Zhaoyang Huang
2024-01-18 15:25     ` Jens Axboe [this message]
2024-01-17 17:29 ` Bart Van Assche
2024-01-18  8:40   ` Zhaoyang Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33cef193-044a-4f25-8248-b10a9db9e0ba@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=huangzhaoyang@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steve.kang@unisoc.com \
    --cc=zhaoyang.huang@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox