From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Jinke Han <hanjinke.666-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Cc: josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org,
axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
yinxin.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org
Subject: Re: [PATCH] blk-throtl: Introduce sync and async queues for blk-throtl
Date: Mon, 19 Dec 2022 11:22:32 -1000 [thread overview]
Message-ID: <Y6DWGBQSP/DA7apC@slm.duckdns.org> (raw)
In-Reply-To: <20221218111314.55525-1-hanjinke.666-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Hello,
This looks generally fine to me. Some nits below.
> +static inline struct bio *throtl_qnode_bio_peek(struct throtl_qnode *qn)
> +{
> + struct bio *bio1, *bio2;
> +
> + /* qn for read ios */
> + if (qn->dispatch_sync_cnt == UINT_MAX)
> + return bio_list_peek(&qn->bios[SYNC]);
> +
> + /* qn for write ios */
> + bio1 = bio_list_peek(&qn->bios[SYNC]);
> + bio2 = bio_list_peek(&qn->bios[ASYNC]);
> +
> + if (bio1 && bio2) {
> + if (qn->dispatch_sync_cnt == THROTL_SYNC_FACTOR)
> + return bio2;
> + return bio1;
> + }
> +
> + return bio1 ?: bio2;
> +}
Wouldn't it be simpler to write:
if (qn->dispatch_sync_count < THROTL_SYNC_FACTOR)
return bio1 ?: bio2;
else
return bio2 ?: bio1;
> +/**
> + * throtl_qnode_bio_pop: pop a bio from a qnode
> + * @qn: the qnode to pop a bio from
> + *
> + * For read io qn, just pop bio from sync queu and return.
> + * For write io qn, the target queue to pop was determined by the dispatch_sync_cnt.
> + * Try to pop bio from target queue, fetch the bio and return when it is not empty.
> + * If the target queue empty, pop bio from other queue instead.
> + */
> +static inline struct bio *throtl_qnode_bio_pop(struct throtl_qnode *qn)
> +{
> + struct bio *bio;
> +
> + /* qn for read ios */
> + if (qn->dispatch_sync_cnt == UINT_MAX)
> + return bio_list_pop(&qn->bios[SYNC]);
> +
> + /* try to dispatch sync io */
> + if (qn->dispatch_sync_cnt < THROTL_SYNC_FACTOR) {
> + bio = bio_list_pop(&qn->bios[SYNC]);
> + if (bio) {
> + qn->dispatch_sync_cnt++;
> + return bio;
> + }
> + bio = bio_list_pop(&qn->bios[ASYNC]);
> + qn->dispatch_sync_cnt = 0;
> + return bio;
> + }
> +
> + /* try to dispatch async io */
> + bio = bio_list_pop(&qn->bios[ASYNC]);
> + if (bio) {
> + qn->dispatch_sync_cnt = 0;
> + return bio;
> + }
> + bio = bio_list_pop(&qn->bios[SYNC]);
> +
> + return bio;
> +}
This also seems like it can be simplified a bit.
Thanks.
--
tejun
next prev parent reply other threads:[~2022-12-19 21:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-18 11:13 [PATCH] blk-throtl: Introduce sync and async queues for blk-throtl Jinke Han
[not found] ` <20221218111314.55525-1-hanjinke.666-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
2022-12-19 21:22 ` Tejun Heo [this message]
2022-12-20 2:38 ` [External] " hanjinke
2022-12-21 10:42 ` [PATCH v2] " Jinke Han
2022-12-22 13:39 ` Michal Koutný
[not found] ` <20221222133912.GA20830-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-12-22 15:38 ` [External] " hanjinke
2022-12-23 9:52 ` hanjinke
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=Y6DWGBQSP/DA7apC@slm.duckdns.org \
--to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hanjinke.666-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org \
--cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=yinxin.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
/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