From: Nikolay Borisov <nborisov@suse.com>
To: Pavel Begunkov <asml.silence@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] blk-mq: optimise rq sort function
Date: Fri, 29 Nov 2019 10:28:31 +0200 [thread overview]
Message-ID: <0124910c-4dcf-2143-0ec6-32dad123067c@suse.com> (raw)
In-Reply-To: <a21e91fff1abe201ebbc010d596b034f7b5123de.1574974577.git.asml.silence@gmail.com>
On 28.11.19 г. 23:11 ч., Pavel Begunkov wrote:
> Check "!=" in multi-layer comparisons. The same memory usage, fewer
> instructions, and 2 from 4 jumps are replaced with SETcc.
>
> Note, that list_sort() doesn't differ 0 and <0.
>
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
My first reaction was this is wrong since you no longer return negative
values. But then I looked into list_sort/merge and this branch
'if (cmp(priv, a, b) <= 0) {' clearly shows this is correct.
So :
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> block/blk-mq.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 323c9cb28066..f32a3cfdd34e 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1668,14 +1668,10 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
> struct request *rqa = container_of(a, struct request, queuelist);
> struct request *rqb = container_of(b, struct request, queuelist);
>
> - if (rqa->mq_ctx < rqb->mq_ctx)
> - return -1;
> - else if (rqa->mq_ctx > rqb->mq_ctx)
> - return 1;
> - else if (rqa->mq_hctx < rqb->mq_hctx)
> - return -1;
> - else if (rqa->mq_hctx > rqb->mq_hctx)
> - return 1;
> + if (rqa->mq_ctx != rqb->mq_ctx)
> + return rqa->mq_ctx > rqb->mq_ctx;
> + if (rqa->mq_hctx != rqb->mq_hctx)
> + return rqa->mq_hctx > rqb->mq_hctx;
>
> return blk_rq_pos(rqa) > blk_rq_pos(rqb);
> }
>
next prev parent reply other threads:[~2019-11-29 8:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-28 21:11 [PATCH 0/3] blk-mq: optimise plugging Pavel Begunkov
2019-11-28 21:11 ` [PATCH 1/3] blk-mq: optimise rq sort function Pavel Begunkov
2019-11-29 8:28 ` Nikolay Borisov [this message]
2019-11-29 9:45 ` Pavel Begunkov
2019-11-29 10:07 ` Nikolay Borisov
2019-11-28 21:11 ` [PATCH 2/3] list: introduce list_for_each_continue() Pavel Begunkov
2019-11-28 21:11 ` [PATCH 3/3] blk-mq: optimise blk_mq_flush_plug_list() Pavel Begunkov
2019-12-05 13:19 ` [PATCH 0/3] blk-mq: optimise plugging Pavel Begunkov
2019-12-05 15:00 ` Jens Axboe
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=0124910c-4dcf-2143-0ec6-32dad123067c@suse.com \
--to=nborisov@suse.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®