From: Kanchan Joshi <joshi.k@samsung.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/2] block: cache current nsec time in struct blk_plug
Date: Tue, 16 Jan 2024 15:21:54 +0530 [thread overview]
Message-ID: <ff4a6649-9f09-23fc-ad33-06deb4845590@samsung.com> (raw)
In-Reply-To: <20240115215840.54432-3-axboe@kernel.dk>
On 1/16/2024 3:23 AM, Jens Axboe wrote:
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 11342af420d0..cc4db4d92c75 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1073,6 +1073,7 @@ void blk_start_plug_nr_ios(struct blk_plug *plug, unsigned short nr_ios)
> if (tsk->plug)
> return;
>
> + plug->cur_ktime = 0;
> plug->mq_list = NULL;
> plug->cached_rq = NULL;
> plug->nr_ios = min_t(unsigned short, nr_ios, BLK_MAX_REQUEST_COUNT);
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 2f9ceea0e23b..23c237b22071 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -942,6 +942,7 @@ struct blk_plug {
>
> /* if ios_left is > 1, we can batch tag/rq allocations */
> struct request *cached_rq;
> + u64 cur_ktime;
> unsigned short nr_ios;
>
> unsigned short rq_count;
> @@ -977,7 +978,15 @@ long nr_blockdev_pages(void);
>
> static inline u64 blk_time_get_ns(void)
> {
> - return ktime_get_ns();
> + struct blk_plug *plug = current->plug;
> +
> + if (!plug)
> + return ktime_get_ns();
> + if (!(plug->cur_ktime & 1ULL)) {
> + plug->cur_ktime = ktime_get_ns();
> + plug->cur_ktime |= 1ULL;
> + }
> + return plug->cur_ktime;
I did not understand the relevance of 1ULL here.
If ktime_get_ns() returns even value, it will turn that into an odd
value before caching. And that value will be returned for the subsequent
calls.
But how is that better compared to just caching whatever ktime_get_ns()
returned.
next prev parent reply other threads:[~2024-01-16 9:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-15 21:53 [PATCHSET RFC 0/2] Cache issue side time querying Jens Axboe
2024-01-15 21:53 ` [PATCH 1/2] block: add blk_time_get_ns() helper Jens Axboe
2024-01-16 6:42 ` Yu Kuai
2024-01-16 14:41 ` Jens Axboe
2024-01-15 21:53 ` [PATCH 2/2] block: cache current nsec time in struct blk_plug Jens Axboe
2024-01-16 9:51 ` Kanchan Joshi [this message]
2024-01-16 10:25 ` Johannes Thumshirn
2024-01-16 10:47 ` Kanchan Joshi
2024-01-16 14:43 ` Jens Axboe
2024-01-16 16:13 ` Keith Busch
2024-01-16 16:18 ` 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=ff4a6649-9f09-23fc-ad33-06deb4845590@samsung.com \
--to=joshi.k@samsung.com \
--cc=axboe@kernel.dk \
--cc=linux-block@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