Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9466277rwp; Thu, 20 Jul 2023 05:31:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDfp7AdZbJjgZs2vUgkTpT+/G2cN/kbYVOr5afhNe1W10k+XRuqyNNtKWq/BS39aUUGPaM X-Received: by 2002:a17:90a:d818:b0:262:ce9e:8a25 with SMTP id a24-20020a17090ad81800b00262ce9e8a25mr7108118pjv.22.1689856306212; Thu, 20 Jul 2023 05:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689856306; cv=none; d=google.com; s=arc-20160816; b=AxeTKxftfDM5jS83Lk2WtpTRBieDbpn+blZbBdL8P3u4nDCoRwIsgo67xhKsSO4MPO GA526n4H/QyFlYyMyRlFRNYCjM4SNJNJ0nj54/Hacqo5xwbBuP66N3pSab9nWlcz/2fv 1tLomzju9pnQx1d2ltZV3xjiM0A+CoA5x8lcpkn0rC8Qlw/oLdrPYJfZc/n7mhnwZ21L +3uRSmxWF5hIvsZOVekeBP4s6hG13V+fAHQ1ePJ1MjgMh3RgQeKN6Z+p0K2fkpberfUP YCsK319eQiVQed++QF6jAMs7eGvofywIXXiAC5cE7mgCoziRqOOFhbb++gEclqLNQBZ2 7k4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1qUoKI3SbOAj4JugO0eFEKpo/XtZkaAZd4jHbDGRCXI=; fh=rsN/xsvOz3oAeEJIYh7x9snPKN/HWt0tOPCClmAeQRU=; b=sZ+hEDoR6eqYIk6GWeTBMrvHPTvnOLcdsUengpFMaVMAYhAM1YFBEQ+erBgmikvSAZ MFYmh6nX0D9j0UN94HezWNU/J3HM9pk4/Fr4UlLGwMxQ5eprzpePghT9l+mfanyz5bsg mlqG6M1FKcIQebLlFtM5ssYqMQvj+a/WoW5xc7qVPLNK6PQpDg5yY3CDLYrd0GvulIMG t2Yj32uhNBBe2FYR4NE3NRBOXuO3XhMLhDmv61XXXW6m3LFiuL5xD+C1+tFtfMuK04jD 5MbTNb/I8rprLZv9s8FBoVcRrwrlauk9tZEqqb5oM4r51Sic5QmCnROnDvkR1W2ouITb nr4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=UYRVGSJe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d32-20020a17090a6f2300b002632c1fc68dsi3460973pjk.72.2023.07.20.05.31.32; Thu, 20 Jul 2023 05:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=UYRVGSJe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbjGTMQF (ORCPT + 99 others); Thu, 20 Jul 2023 08:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjGTMQD (ORCPT ); Thu, 20 Jul 2023 08:16:03 -0400 Received: from out-5.mta1.migadu.com (out-5.mta1.migadu.com [IPv6:2001:41d0:203:375::5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0391BC6 for ; Thu, 20 Jul 2023 05:16:01 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689855359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1qUoKI3SbOAj4JugO0eFEKpo/XtZkaAZd4jHbDGRCXI=; b=UYRVGSJeMWgVT/Cmj35t2ZweiX0f74MUBaOSw4MLtDmMy3IiuQrHv8RU4qRm/+sTXZG3zj +eK1+VPGThdCpfSCGWbopKgw5Dw3dyzfnI+h4Dk0lnIiYvGH6rNedI6u3cchFohjzDfaRp UtcGfRKuKFeW1oGmtQWsxdDyRcpHit4= From: chengming.zhou@linux.dev To: tj@kernel.org, josef@toxicpanda.com Cc: axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH] blk-iocost: skip empty flush bio in iocost Date: Thu, 20 Jul 2023 20:14:41 +0800 Message-ID: <20230720121441.1408522-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengming Zhou 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 --- 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