Re: [PATCH RFC v3 02/15] block: add QUEUE_FLAG_BIO_ISSUE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

在 2025/09/04 0:54, Yu Kuai 写道:
Hi,

在 2025/9/3 21:24, Christoph Hellwig 写道:
On Mon, Sep 01, 2025 at 11:32:07AM +0800, Yu Kuai wrote:
  static inline void blkcg_bio_issue_init(struct bio *bio)
  {
-    bio->issue_time_ns = blk_time_get_ns();
+    struct request_queue *q = bdev_get_queue(bio->bi_bdev);
+
+    if (test_bit(QUEUE_FLAG_BIO_ISSUE, &q->queue_flags))
+        bio->issue_time_ns = blk_time_get_ns();
  }
Given that this is called on a bio and called from generic code
and not blk-mq, the flag should in the gendisk and not the queue.

ok, will change to disk, and also change set/clear the flag to
enable/disable iolatency.

After careful consideration, I think it's better to delay
blkcg_bio_issue_init() to blk_mq_submit_bio():

- it's only used by iolatency, which can only be enabled for rq-based
disks;
- For bio that is submitted the first time, blk_cgroup_bio_start() is
called from submit_bio_no_acct_nocheck(), where q_usage_counter is not
grabbed yet, hence it's not safe to enable that flag while enabling
iolatency.

diff --git a/block/blk-core.c b/block/blk-core.c
index 4201504158a1..83c262a3dfd9 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -728,7 +728,6 @@ static void __submit_bio_noacct_mq(struct bio *bio)
 void submit_bio_noacct_nocheck(struct bio *bio)
 {
        blk_cgroup_bio_start(bio);
-       blkcg_bio_issue_init(bio);

        if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {
                trace_block_bio_queue(bio);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 70d704615be5..5538356770a4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -119,7 +119,6 @@ static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
                        goto error;
                }
                split->bi_opf |= REQ_NOMERGE;
-               blkcg_bio_issue_init(split);
                bio_chain(split, bio);
                trace_block_split(split, bio->bi_iter.bi_sector);
                WARN_ON_ONCE(bio_zone_write_plugging(bio));
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ba3a4b77f578..030937b129a2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3108,7 +3108,7 @@ static bool bio_unaligned(const struct bio *bio, struct request_queue *q) * It will not queue the request if there is an error with the bio, or at the
  * request creation.
  */
-void blk_mq_submit_bio(struct bio *bio)
+void b k_mq_submit_bio(struct bio *bio)
 {
        struct request_queue *q = bdev_get_queue(bio->bi_bdev);
        struct blk_plug *plug = current->plug;
@@ -3168,6 +3168,9 @@ void blk_mq_submit_bio(struct bio *bio)
        if (!bio_integrity_prep(bio))
                goto queue_exit;

+       if (test_bit(QUEUE_FLAG_BIO_ISSUE, &q->queue_flags))
+               bio->issue_time_ns = blk_time_get_ns();
+
        if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
                goto queue_exit;



Thanks,
Kuai

.






[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux