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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 27888C2D0A3 for ; Tue, 27 Oct 2020 00:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3646207DE for ; Tue, 27 Oct 2020 00:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603758224; bh=yDvzrYTvHdXk70NDohiR7SvD6wB+nbWX2pF8bVKrvus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PYbuSBJIAYqCm8afFiZCwjcLH5EG2jJefXgziQq+q70f5HVc8N2uPIy0GCqCD7Qai Qz9BL32ov7nLuUp54c6ER/Fh+krom1t80/yr9HIQTsxQUK2MGejNA3KbcyutZC+GV4 a5SmDDLPkIV9v0gJq2+EsU03AGfkVpCJ/yP2xQgE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2410302AbgJZXyF (ORCPT ); Mon, 26 Oct 2020 19:54:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:59320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410288AbgJZXyD (ORCPT ); Mon, 26 Oct 2020 19:54:03 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA96521655; Mon, 26 Oct 2020 23:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756442; bh=yDvzrYTvHdXk70NDohiR7SvD6wB+nbWX2pF8bVKrvus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MNiAtmT3JO18FIz7UvmOzZP0XZLKe2f+yt+1BQud64Xkld09W88N4ZfWYdCqNP3BD y9M+Qaifz/0kk3ihrvDrxK6mQbbFy1d4GV3FQ/WoLrCw/muHIKRlO7vdtZxKoD3VLX Nqj70vB09as5zi/jSv4zM1tb0lxxUYEe0P2aV5IU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gabriel Krisman Bertazi , Omar Sandoval , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 095/132] block: Consider only dispatched requests for inflight statistic Date: Mon, 26 Oct 2020 19:51:27 -0400 Message-Id: <20201026235205.1023962-95-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235205.1023962-1-sashal@kernel.org> References: <20201026235205.1023962-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-block@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 8e623e0282757..88b0dc0034cff 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -103,7 +103,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.25.1