cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: hch@infradead.org, colyli@kernel.org, hare@suse.de,
	dlemoal@kernel.org, tieren@fnnas.com, axboe@kernel.dk,
	tj@kernel.org, josef@toxicpanda.com, song@kernel.org,
	kmo@daterainc.com, satyat@google.com, ebiggers@google.com,
	neil@brown.name, akpm@linux-foundation.org
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	cgroups@vger.kernel.org, linux-raid@vger.kernel.org,
	yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com,
	yangerkun@huawei.com, johnny.chenyi@huawei.com
Subject: [PATCH RFC v3 01/15] block: cleanup bio_issue
Date: Mon,  1 Sep 2025 11:32:06 +0800	[thread overview]
Message-ID: <20250901033220.42982-2-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20250901033220.42982-1-yukuai1@huaweicloud.com>

From: Yu Kuai <yukuai3@huawei.com>

Now that bio->bi_issue is only used by io-latency to get bio issue time,
replace bio_issue with u64 time directly and remove bio_issue to make
code cleaner.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/bio.c               |  2 +-
 block/blk-cgroup.h        |  2 +-
 block/blk-iolatency.c     | 14 +++----------
 block/blk.h               | 42 ---------------------------------------
 include/linux/blk_types.h |  7 ++-----
 5 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 44c43b970387..c8fce0d6e332 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -261,7 +261,7 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table,
 	bio->bi_private = NULL;
 #ifdef CONFIG_BLK_CGROUP
 	bio->bi_blkg = NULL;
-	bio->bi_issue.value = 0;
+	bio->issue_time_ns = 0;
 	if (bdev)
 		bio_associate_blkg(bio);
 #ifdef CONFIG_BLK_CGROUP_IOCOST
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 81868ad86330..d73204d27d72 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -372,7 +372,7 @@ static inline void blkg_put(struct blkcg_gq *blkg)
 
 static inline void blkcg_bio_issue_init(struct bio *bio)
 {
-	bio_issue_init(&bio->bi_issue, bio_sectors(bio));
+	bio->issue_time_ns = blk_time_get_ns();
 }
 
 static inline void blkcg_use_delay(struct blkcg_gq *blkg)
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index 2f8fdecdd7a9..554b191a6892 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -485,19 +485,11 @@ static void blkcg_iolatency_throttle(struct rq_qos *rqos, struct bio *bio)
 		mod_timer(&blkiolat->timer, jiffies + HZ);
 }
 
-static void iolatency_record_time(struct iolatency_grp *iolat,
-				  struct bio_issue *issue, u64 now,
-				  bool issue_as_root)
+static void iolatency_record_time(struct iolatency_grp *iolat, u64 start,
+				  u64 now, bool issue_as_root)
 {
-	u64 start = bio_issue_time(issue);
 	u64 req_time;
 
-	/*
-	 * Have to do this so we are truncated to the correct time that our
-	 * issue is truncated to.
-	 */
-	now = __bio_issue_time(now);
-
 	if (now <= start)
 		return;
 
@@ -625,7 +617,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
 		 * submitted, so do not account for it.
 		 */
 		if (iolat->min_lat_nsec && bio->bi_status != BLK_STS_AGAIN) {
-			iolatency_record_time(iolat, &bio->bi_issue, now,
+			iolatency_record_time(iolat, bio->issue_time_ns, now,
 					      issue_as_root);
 			window_start = atomic64_read(&iolat->window_start);
 			if (now > window_start &&
diff --git a/block/blk.h b/block/blk.h
index 46f566f9b126..0268deb22268 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -680,48 +680,6 @@ static inline ktime_t blk_time_get(void)
 	return ns_to_ktime(blk_time_get_ns());
 }
 
-/*
- * From most significant bit:
- * 1 bit: reserved for other usage, see below
- * 12 bits: original size of bio
- * 51 bits: issue time of bio
- */
-#define BIO_ISSUE_RES_BITS      1
-#define BIO_ISSUE_SIZE_BITS     12
-#define BIO_ISSUE_RES_SHIFT     (64 - BIO_ISSUE_RES_BITS)
-#define BIO_ISSUE_SIZE_SHIFT    (BIO_ISSUE_RES_SHIFT - BIO_ISSUE_SIZE_BITS)
-#define BIO_ISSUE_TIME_MASK     ((1ULL << BIO_ISSUE_SIZE_SHIFT) - 1)
-#define BIO_ISSUE_SIZE_MASK     \
-	(((1ULL << BIO_ISSUE_SIZE_BITS) - 1) << BIO_ISSUE_SIZE_SHIFT)
-#define BIO_ISSUE_RES_MASK      (~((1ULL << BIO_ISSUE_RES_SHIFT) - 1))
-
-/* Reserved bit for blk-throtl */
-#define BIO_ISSUE_THROTL_SKIP_LATENCY (1ULL << 63)
-
-static inline u64 __bio_issue_time(u64 time)
-{
-	return time & BIO_ISSUE_TIME_MASK;
-}
-
-static inline u64 bio_issue_time(struct bio_issue *issue)
-{
-	return __bio_issue_time(issue->value);
-}
-
-static inline sector_t bio_issue_size(struct bio_issue *issue)
-{
-	return ((issue->value & BIO_ISSUE_SIZE_MASK) >> BIO_ISSUE_SIZE_SHIFT);
-}
-
-static inline void bio_issue_init(struct bio_issue *issue,
-				       sector_t size)
-{
-	size &= (1ULL << BIO_ISSUE_SIZE_BITS) - 1;
-	issue->value = ((issue->value & BIO_ISSUE_RES_MASK) |
-			(blk_time_get_ns() & BIO_ISSUE_TIME_MASK) |
-			((u64)size << BIO_ISSUE_SIZE_SHIFT));
-}
-
 void bdev_release(struct file *bdev_file);
 int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
 	      const struct blk_holder_ops *hops, struct file *bdev_file);
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 930daff207df..b8be751e16fc 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -198,10 +198,6 @@ static inline bool blk_path_error(blk_status_t error)
 	return true;
 }
 
-struct bio_issue {
-	u64 value;
-};
-
 typedef __u32 __bitwise blk_opf_t;
 
 typedef unsigned int blk_qc_t;
@@ -242,7 +238,8 @@ struct bio {
 	 * on release of the bio.
 	 */
 	struct blkcg_gq		*bi_blkg;
-	struct bio_issue	bi_issue;
+	/* Time that this bio was issued. */
+	u64			issue_time_ns;
 #ifdef CONFIG_BLK_CGROUP_IOCOST
 	u64			bi_iocost_cost;
 #endif
-- 
2.39.2


  reply	other threads:[~2025-09-01  3:41 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01  3:32 [PATCH RFC v3 00/15] block: fix disordered IO in the case recursive split Yu Kuai
2025-09-01  3:32 ` Yu Kuai [this message]
2025-09-01  3:43   ` [PATCH RFC v3 01/15] block: cleanup bio_issue Damien Le Moal
2025-09-01  6:22     ` Yu Kuai
2025-09-03 13:23   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 02/15] block: add QUEUE_FLAG_BIO_ISSUE Yu Kuai
2025-09-02 17:05   ` Bart Van Assche
2025-09-03  0:54     ` Yu Kuai
2025-09-03 13:24   ` Christoph Hellwig
2025-09-03 16:54     ` Yu Kuai
2025-09-01  3:32 ` [PATCH RFC v3 03/15] md: fix mssing blktrace bio split events Yu Kuai
2025-09-01  6:30   ` Damien Le Moal
2025-09-01  7:53     ` Yu Kuai
2025-09-03 13:25   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 04/15] blk-crypto: fix missing processing for split bio Yu Kuai
2025-09-01  6:31   ` Damien Le Moal
2025-09-03 13:26   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 05/15] block: factor out a helper bio_submit_split_bioset() Yu Kuai
2025-09-01  6:34   ` Damien Le Moal
2025-09-02 17:12   ` Bart Van Assche
2025-09-03 13:28     ` Christoph Hellwig
2025-09-03 13:28   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 06/15] md/raid0: convert raid0_handle_discard() to use bio_submit_split_bioset() Yu Kuai
2025-09-01  6:37   ` Damien Le Moal
2025-09-01  7:57     ` Yu Kuai
2025-09-03 13:29   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 07/15] md/raid1: convert " Yu Kuai
2025-09-01  6:43   ` Damien Le Moal
2025-09-01  8:03     ` Yu Kuai
2025-09-03 13:30       ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 08/15] md/raid10: add a new r10bio flag R10BIO_Returned Yu Kuai
2025-09-01  3:32 ` [PATCH RFC v3 09/15] md/raid10: convert read/write to use bio_submit_split_bioset() Yu Kuai
2025-09-01  3:32 ` [PATCH RFC v3 10/15] md/raid5: convert " Yu Kuai
2025-09-01  3:32 ` [PATCH RFC v3 11/15] md/md-linear: " Yu Kuai
2025-09-03 17:43   ` Bart Van Assche
2025-09-01  3:32 ` [PATCH RFC v3 12/15] blk-crypto: " Yu Kuai
2025-09-03 13:31   ` Christoph Hellwig
2025-09-01  3:32 ` [PATCH RFC v3 13/15] block: skip unnecessary checks for split bio Yu Kuai
2025-09-03 13:33   ` Christoph Hellwig
2025-09-03 17:00     ` Yu Kuai
2025-09-01  3:32 ` [PATCH RFC v3 14/15] block: fix disordered IO in the case recursive split Yu Kuai
2025-09-02 17:20   ` Bart Van Assche
2025-09-03  1:00     ` Yu Kuai
2025-09-03  1:12       ` Bart Van Assche
2025-09-03  1:41         ` Yu Kuai
2025-09-03 13:34   ` Christoph Hellwig
2025-09-03 16:59     ` Yu Kuai
2025-09-03 17:52       ` Bart Van Assche
2025-09-01  3:32 ` [PATCH RFC v3 15/15] md/raid0: convert raid0_make_request() to use bio_submit_split_bioset() Yu Kuai
2025-09-01 14:09 ` [PATCH RFC v3 00/15] block: fix disordered IO in the case recursive split Bart Van Assche
2025-09-02  1:50   ` Yu Kuai
2025-09-02  8:04     ` Yu Kuai

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=20250901033220.42982-2-yukuai1@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=colyli@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=ebiggers@google.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=johnny.chenyi@huawei.com \
    --cc=josef@toxicpanda.com \
    --cc=kmo@daterainc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=satyat@google.com \
    --cc=song@kernel.org \
    --cc=tieren@fnnas.com \
    --cc=tj@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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;
as well as URLs for NNTP newsgroup(s).