All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, danil.kipnis@cloud.ionos.com,
	jinpu.wang@cloud.ionos.com,
	Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Subject: [PATCH 4/4] block: call blk_additional_{latency,sector} only when io_extra_stats is true
Date: Wed, 27 Jan 2021 15:59:30 +0100	[thread overview]
Message-ID: <20210127145930.8826-5-guoqing.jiang@cloud.ionos.com> (raw)
In-Reply-To: <20210127145930.8826-1-guoqing.jiang@cloud.ionos.com>

If ADDITIONAL_DISKSTAT is enabled carelessly, then it is bad to people
who don't want the additional overhead.

Now add check before call blk_additional_{latency,sector}, which guarntee
only those who really know about the attribute can account the additional
data.

Reviewed-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 block/blk-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 4271c5a8e685..f62cfc8f801e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1313,7 +1313,8 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes)
 		const int sgrp = op_stat_group(req_op(req));
 
 		part_stat_lock();
-		blk_additional_sector(req->part, sgrp, bytes >> SECTOR_SHIFT);
+		if (blk_queue_io_extra_stat(req->q))
+			blk_additional_sector(req->part, sgrp, bytes >> SECTOR_SHIFT);
 		part_stat_add(req->part, sectors[sgrp], bytes >> 9);
 		part_stat_unlock();
 	}
@@ -1332,7 +1333,8 @@ void blk_account_io_done(struct request *req, u64 now)
 
 		part_stat_lock();
 		update_io_ticks(req->part, jiffies, true);
-		blk_additional_latency(req->part, sgrp, req, 0);
+		if (blk_queue_io_extra_stat(req->q))
+			blk_additional_latency(req->part, sgrp, req, 0);
 		part_stat_inc(req->part, ios[sgrp]);
 		part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns);
 		part_stat_unlock();
@@ -1365,7 +1367,8 @@ static unsigned long __part_start_io_acct(struct block_device *part,
 	update_io_ticks(part, now, false);
 	part_stat_inc(part, ios[sgrp]);
 	part_stat_add(part, sectors[sgrp], sectors);
-	blk_additional_sector(part, sgrp, sectors);
+	if (blk_queue_io_extra_stat(part->bd_disk->queue))
+		blk_additional_sector(part, sgrp, sectors);
 	part_stat_local_inc(part, in_flight[op_is_write(op)]);
 	part_stat_unlock();
 
@@ -1400,7 +1403,8 @@ static void __part_end_io_acct(struct block_device *part, unsigned int op,
 
 	part_stat_lock();
 	update_io_ticks(part, now, true);
-	blk_additional_latency(part, sgrp, NULL, start_time);
+	if (blk_queue_io_extra_stat(part->bd_disk->queue))
+		blk_additional_latency(part, sgrp, NULL, start_time);
 	part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration));
 	part_stat_local_dec(part, in_flight[op_is_write(op)]);
 	part_stat_unlock();
-- 
2.17.1


  parent reply	other threads:[~2021-01-27 16:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 14:59 [PATCH 0/4] block: add two statistic tables Guoqing Jiang
2021-01-27 14:59 ` [PATCH 1/4] block: add a statistic table for io latency Guoqing Jiang
2021-01-27 17:10   ` Christoph Hellwig
2021-01-28  2:44     ` Guoqing Jiang
2021-01-27 14:59 ` [PATCH 2/4] block: add a statistic table for io sector Guoqing Jiang
2021-01-27 14:59 ` [PATCH 3/4] block: add io_extra_stats node Guoqing Jiang
2021-01-27 14:59 ` Guoqing Jiang [this message]
2021-01-27 17:09   ` [PATCH 4/4] block: call blk_additional_{latency,sector} only when io_extra_stats is true Christoph Hellwig
2021-01-28  2:53     ` Guoqing Jiang

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=20210127145930.8826-5-guoqing.jiang@cloud.ionos.com \
    --to=guoqing.jiang@cloud.ionos.com \
    --cc=axboe@kernel.dk \
    --cc=danil.kipnis@cloud.ionos.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.