linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET 0/2] Further block iostat cleanups
@ 2024-10-03 13:35 Jens Axboe
  2024-10-03 13:35 ` [PATCH 1/2] block: remove 'req->part' check for stats accounting Jens Axboe
  2024-10-03 13:35 ` [PATCH 2/2] block: kill blk_do_io_stat() helper Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Jens Axboe @ 2024-10-03 13:35 UTC (permalink / raw)
  To: linux-block

Hi,

1) Drop unnecessary ->part check, RQF_IO_STAT should always be the only
   gating factor for if the request is accounted or not.

2) Kill blk_do_io_stat() helper, as now the only thing being checked is
   RQF_IO_STAT and hence it serves no purpose.

 block/blk-merge.c | 13 ++++++-------
 block/blk-mq.c    |  7 +++----
 block/blk.h       | 11 -----------
 3 files changed, 9 insertions(+), 22 deletions(-)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] block: remove 'req->part' check for stats accounting
  2024-10-03 13:35 [PATCHSET 0/2] Further block iostat cleanups Jens Axboe
@ 2024-10-03 13:35 ` Jens Axboe
  2024-10-03 13:38   ` Christoph Hellwig
  2024-10-03 13:35 ` [PATCH 2/2] block: kill blk_do_io_stat() helper Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2024-10-03 13:35 UTC (permalink / raw)
  To: linux-block; +Cc: Jens Axboe

If RQF_IO_STAT is set, then accounting is enabled. There's no need to
further gate this on req->part being set or not, RQF_IO_STAT should
never be set if accounting is not being done for this request.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ee6cde39e52b..f21bd390e07b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -92,7 +92,7 @@ static bool blk_mq_check_inflight(struct request *rq, void *priv)
 {
 	struct mq_inflight *mi = priv;
 
-	if (rq->part && blk_do_io_stat(rq) &&
+	if (blk_do_io_stat(rq) &&
 	    (!bdev_is_partition(mi->part) || rq->part == mi->part) &&
 	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
 		mi->inflight[rq_data_dir(rq)]++;
@@ -762,7 +762,7 @@ EXPORT_SYMBOL(blk_dump_rq_flags);
 
 static void blk_account_io_completion(struct request *req, unsigned int bytes)
 {
-	if (req->part && blk_do_io_stat(req)) {
+	if (blk_do_io_stat(req)) {
 		const int sgrp = op_stat_group(req_op(req));
 
 		part_stat_lock();
@@ -980,8 +980,7 @@ static inline void blk_account_io_done(struct request *req, u64 now)
 	 * normal IO on queueing nor completion.  Accounting the
 	 * containing request is enough.
 	 */
-	if (blk_do_io_stat(req) && req->part &&
-	    !(req->rq_flags & RQF_FLUSH_SEQ)) {
+	if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) {
 		const int sgrp = op_stat_group(req_op(req));
 
 		part_stat_lock();
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] block: kill blk_do_io_stat() helper
  2024-10-03 13:35 [PATCHSET 0/2] Further block iostat cleanups Jens Axboe
  2024-10-03 13:35 ` [PATCH 1/2] block: remove 'req->part' check for stats accounting Jens Axboe
@ 2024-10-03 13:35 ` Jens Axboe
  2024-10-03 13:38   ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2024-10-03 13:35 UTC (permalink / raw)
  To: linux-block; +Cc: Jens Axboe

It's now just checking whether or not RQF_IO_STAT is set, so let's get
rid of it and just open-code the specific flag that is being checked.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-merge.c | 13 ++++++-------
 block/blk-mq.c    |  6 +++---
 block/blk.h       | 11 -----------
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index ad763ec313b6..8b9a9646aed8 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -797,7 +797,7 @@ static inline void blk_update_mixed_merge(struct request *req,
 
 static void blk_account_io_merge_request(struct request *req)
 {
-	if (blk_do_io_stat(req)) {
+	if (req->rq_flags & RQF_IO_STAT) {
 		part_stat_lock();
 		part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
 		part_stat_local_dec(req->part,
@@ -1005,12 +1005,11 @@ enum elv_merge blk_try_merge(struct request *rq, struct bio *bio)
 
 static void blk_account_io_merge_bio(struct request *req)
 {
-	if (!blk_do_io_stat(req))
-		return;
-
-	part_stat_lock();
-	part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
-	part_stat_unlock();
+	if (req->rq_flags & RQF_IO_STAT) {
+		part_stat_lock();
+		part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
+		part_stat_unlock();
+	}
 }
 
 enum bio_merge_status bio_attempt_back_merge(struct request *req,
diff --git a/block/blk-mq.c b/block/blk-mq.c
index f21bd390e07b..8e75e3471ea5 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -92,7 +92,7 @@ static bool blk_mq_check_inflight(struct request *rq, void *priv)
 {
 	struct mq_inflight *mi = priv;
 
-	if (blk_do_io_stat(rq) &&
+	if (rq->rq_flags & RQF_IO_STAT &&
 	    (!bdev_is_partition(mi->part) || rq->part == mi->part) &&
 	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
 		mi->inflight[rq_data_dir(rq)]++;
@@ -762,7 +762,7 @@ EXPORT_SYMBOL(blk_dump_rq_flags);
 
 static void blk_account_io_completion(struct request *req, unsigned int bytes)
 {
-	if (blk_do_io_stat(req)) {
+	if (req->rq_flags & RQF_IO_STAT) {
 		const int sgrp = op_stat_group(req_op(req));
 
 		part_stat_lock();
@@ -980,7 +980,7 @@ static inline void blk_account_io_done(struct request *req, u64 now)
 	 * normal IO on queueing nor completion.  Accounting the
 	 * containing request is enough.
 	 */
-	if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) {
+	if ((req->rq_flags & (RQF_IO_STAT|RQF_FLUSH_SEQ)) == RQF_IO_STAT) {
 		const int sgrp = op_stat_group(req_op(req));
 
 		part_stat_lock();
diff --git a/block/blk.h b/block/blk.h
index 84178e535533..ea926d685e92 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -405,17 +405,6 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi,
 		struct queue_limits *lim);
 int blk_dev_init(void);
 
-/*
- * Contribute to IO statistics IFF:
- *
- *	a) it's attached to a gendisk, and
- *	b) the queue had IO stats enabled when this request was started
- */
-static inline bool blk_do_io_stat(struct request *rq)
-{
-	return rq->rq_flags & RQF_IO_STAT;
-}
-
 void update_io_ticks(struct block_device *part, unsigned long now, bool end);
 unsigned int part_in_flight(struct block_device *part);
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] block: remove 'req->part' check for stats accounting
  2024-10-03 13:35 ` [PATCH 1/2] block: remove 'req->part' check for stats accounting Jens Axboe
@ 2024-10-03 13:38   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-10-03 13:38 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] block: kill blk_do_io_stat() helper
  2024-10-03 13:35 ` [PATCH 2/2] block: kill blk_do_io_stat() helper Jens Axboe
@ 2024-10-03 13:38   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-10-03 13:38 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-03 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 13:35 [PATCHSET 0/2] Further block iostat cleanups Jens Axboe
2024-10-03 13:35 ` [PATCH 1/2] block: remove 'req->part' check for stats accounting Jens Axboe
2024-10-03 13:38   ` Christoph Hellwig
2024-10-03 13:35 ` [PATCH 2/2] block: kill blk_do_io_stat() helper Jens Axboe
2024-10-03 13:38   ` Christoph Hellwig

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).