linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-iocost: skip empty flush bio in iocost
@ 2023-07-20 12:14 chengming.zhou
  2023-07-20 19:59 ` Tejun Heo
  2023-07-20 20:02 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: chengming.zhou @ 2023-07-20 12:14 UTC (permalink / raw)
  To: tj, josef; +Cc: axboe, cgroups, linux-block, linux-kernel, zhouchengming

From: Chengming Zhou <zhouchengming@bytedance.com>

The flush bio may have data, may have no data (empty flush), we couldn't
calculate cost for empty flush bio. So we'd better just skip it for now.

Another side effect is that empty flush bio's bio_end_sector() is 0, cause
iocg->cursor reset to 0, may break the cost calculation of other bios.

This isn't good enough, since flush bio still consume the device bandwidth,
but flush request is special, can be merged randomly in the flush state
machine, we don't know how to calculate cost for it for now.

Its completion time also has flaws, which may include the pre-flush or
post-flush completion time, but I don't know if we need to fix that and
how to fix it.

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
 block/blk-iocost.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 6084a9519883..e735b3e9997c 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2516,6 +2516,10 @@ static void calc_vtime_cost_builtin(struct bio *bio, struct ioc_gq *iocg,
 	u64 seek_pages = 0;
 	u64 cost = 0;
 
+	/* Can't calculate cost for empty bio */
+	if (!bio->bi_iter.bi_size)
+		goto out;
+
 	switch (bio_op(bio)) {
 	case REQ_OP_READ:
 		coef_seqio	= ioc->params.lcoefs[LCOEF_RSEQIO];
-- 
2.41.0


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

* Re: [PATCH] blk-iocost: skip empty flush bio in iocost
  2023-07-20 12:14 [PATCH] blk-iocost: skip empty flush bio in iocost chengming.zhou
@ 2023-07-20 19:59 ` Tejun Heo
  2023-07-20 20:02 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2023-07-20 19:59 UTC (permalink / raw)
  To: chengming.zhou
  Cc: josef, axboe, cgroups, linux-block, linux-kernel, zhouchengming

On Thu, Jul 20, 2023 at 08:14:41PM +0800, chengming.zhou@linux.dev wrote:
> From: Chengming Zhou <zhouchengming@bytedance.com>
> 
> The flush bio may have data, may have no data (empty flush), we couldn't
> calculate cost for empty flush bio. So we'd better just skip it for now.
> 
> Another side effect is that empty flush bio's bio_end_sector() is 0, cause
> iocg->cursor reset to 0, may break the cost calculation of other bios.
> 
> This isn't good enough, since flush bio still consume the device bandwidth,
> but flush request is special, can be merged randomly in the flush state
> machine, we don't know how to calculate cost for it for now.
> 
> Its completion time also has flaws, which may include the pre-flush or
> post-flush completion time, but I don't know if we need to fix that and
> how to fix it.
> 
> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>

It's unlikely that this will change behaviors in an observable way in most
cases. That said, yeah, ignoring it in terms of cost calculation is likely
the better thing to do.

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [PATCH] blk-iocost: skip empty flush bio in iocost
  2023-07-20 12:14 [PATCH] blk-iocost: skip empty flush bio in iocost chengming.zhou
  2023-07-20 19:59 ` Tejun Heo
@ 2023-07-20 20:02 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-07-20 20:02 UTC (permalink / raw)
  To: tj, josef, chengming.zhou
  Cc: cgroups, linux-block, linux-kernel, zhouchengming


On Thu, 20 Jul 2023 20:14:41 +0800, chengming.zhou@linux.dev wrote:
> The flush bio may have data, may have no data (empty flush), we couldn't
> calculate cost for empty flush bio. So we'd better just skip it for now.
> 
> Another side effect is that empty flush bio's bio_end_sector() is 0, cause
> iocg->cursor reset to 0, may break the cost calculation of other bios.
> 
> This isn't good enough, since flush bio still consume the device bandwidth,
> but flush request is special, can be merged randomly in the flush state
> machine, we don't know how to calculate cost for it for now.
> 
> [...]

Applied, thanks!

[1/1] blk-iocost: skip empty flush bio in iocost
      commit: 013adcbef165c3eaf73e297b7482290593815ab8

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-07-20 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-20 12:14 [PATCH] blk-iocost: skip empty flush bio in iocost chengming.zhou
2023-07-20 19:59 ` Tejun Heo
2023-07-20 20:02 ` Jens Axboe

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