From patchwork Thu Jul 20 12:14:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 123234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3083602vqt; Thu, 20 Jul 2023 05:33:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzMbgJIO6nj642vGm0yAlSLun59hhggLfwHvVFsriV+XoeLuQUjggNmVHImTjB99F9vomr X-Received: by 2002:a17:90b:2241:b0:263:f73d:9f50 with SMTP id hk1-20020a17090b224100b00263f73d9f50mr7429459pjb.19.1689856384395; Thu, 20 Jul 2023 05:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689856384; cv=none; d=google.com; s=arc-20160816; b=hMaKb6Niz0vJkAGg6mjYibVkXBUUr2qnpHr2ikEWCzTHEbR++0Cv/+O2yWk2PyoRgL 0BNTqpLEHkkid04QdhSlmjbSNhlGoQ8vYKude965lyAi22CahueUEiytwNfjQnbATmA9 PaxcHixbkYeupiRXfKuFrz664+zxDlZNDRRs9qixIlViqjYTdwMlg5O7mMRpe89rRoJ8 pq6BNCQq742im12bYl4CKJx2KJoUVXn+82bQ+hT2OPxmfJ9EFIxbbETpWVRcluiX84ap SLvULeWTNjZZDZdgmKjQbQj3FQebKVsXXkF/sy1/5WUdoA0vKXhyCZrET2uCrLTxfBfI SSuQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a170902db0400b001b87b17cfb4si898320plx.392.2023.07.20.05.32.43; Thu, 20 Jul 2023 05:33:04 -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 S231138AbjGTMQF (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771942848084880464 X-GMAIL-MSGID: 1771942848084880464 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 Acked-by: Tejun Heo --- 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];