From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5AA5C2D0A3 for ; Tue, 3 Nov 2020 20:44:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A30A6223C6 for ; Tue, 3 Nov 2020 20:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436255; bh=O18V/B1uPA6UmIdoBoEGVsjQvG52VQilORM5dHDeLiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bofQ0TdYdRcj0LSHeAl8SkRweTMfaWcNpGzFz3sorVyOT2RYcGHRXgKnBHUKW4VGT qQFELx2DcBtcdsoGl4rboa+wHJm39ofrObaA1c1Jyet8YrKPVRRcBAazKTAvkPIUsH zHhgqGRFI3duxX8uaZq31qCPFs7E2AG63aRVkr1M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728621AbgKCUoO (ORCPT ); Tue, 3 Nov 2020 15:44:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:59084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730837AbgKCUoL (ORCPT ); Tue, 3 Nov 2020 15:44:11 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C31D9223EA; Tue, 3 Nov 2020 20:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436251; bh=O18V/B1uPA6UmIdoBoEGVsjQvG52VQilORM5dHDeLiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E943kb9UEB7xhkGM/iQAZkLqGCrBt84jwizVuYu672bNVpU7ezNYS4++H/ySPGOYI 69O42IwMPWUpT/d6VqnitzIy8VvDftJju6qvqFLW94yPjhKeaZWbt++5l3idkv7rCK NfiTNGgBjHLtsdPPkDCjuKnCsTw+mluJdGB2arso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gabriel Krisman Bertazi , Omar Sandoval , Jens Axboe , Sasha Levin Subject: [PATCH 5.9 141/391] block: Consider only dispatched requests for inflight statistic Date: Tue, 3 Nov 2020 21:33:12 +0100 Message-Id: <20201103203356.346165802@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gabriel Krisman Bertazi [ Upstream commit a926c7afffcc0f2e35e6acbccb16921bacf34617 ] According to Documentation/block/stat.rst, inflight should not include I/O requests that are in the queue but not yet dispatched to the device, but blk-mq identifies as inflight any request that has a tag allocated, which, for queues without elevator, happens at request allocation time and before it is queued in the ctx (default case in blk_mq_submit_bio). In addition, current behavior is different for queues with elevator from queues without it, since for the former the driver tag is allocated at dispatch time. A more precise approach would be to only consider requests with state MQ_RQ_IN_FLIGHT. This effectively reverts commit 6131837b1de6 ("blk-mq: count allocated but not started requests in iostats inflight") to consolidate blk-mq behavior with itself (elevator case) and with original documentation, but it differs from the behavior used by the legacy path. This version differs from v1 by using blk_mq_rq_state to access the state attribute. Avoid using blk_mq_request_started, which was suggested, since we don't want to include MQ_RQ_COMPLETE. Signed-off-by: Gabriel Krisman Bertazi Cc: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 94a53d779c12b..ca2fdb58e7af5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -105,7 +105,7 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, { struct mq_inflight *mi = priv; - if (rq->part == mi->part) + if (rq->part == mi->part && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) mi->inflight[rq_data_dir(rq)]++; return true; -- 2.27.0