Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp841527pxb; Tue, 3 Nov 2020 14:06:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtVl7uPzU8tPY3Z/K5aOP732fl0TJyTj05Eg3FKQ015EhEBPBtCj+JhkRu0nHqNXl0d987 X-Received: by 2002:a17:906:a018:: with SMTP id p24mr19540981ejy.462.1604441216732; Tue, 03 Nov 2020 14:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441216; cv=none; d=google.com; s=arc-20160816; b=x53t5Wp5RQvPqVo6ANC35Bniv5w9AzgLW3OIDFPhuyqCiLr80vR09lZG+82XqP1KXZ zT4Xg+UeFSw/u3qFEFcYsnAQ/5/ya5VQiVHRuabWl6NAFj3VaWIHu7UOghQNFhN7RfKS /8AHJMQ62WfTIx5IyYTBwppsZ1tbNbvZJgcBsonMkzKOJ08BXl6mmZF5+SgDBehuUU2U O9wJ0/19pMvUy8CQzvn2Rt24PZP/y/WDfVd6+EEIlOONkmbCmJ/Z7hLiSITTl+3aaynd 5884DHTybxyrPW+HIgWkGXvlAtA3H63cwBtTpi7otTvfo8x5X+yWRRHpXUDhTpWmH3j7 KxlA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+UryO4s76e9zk2DMhGNxH5HaO15PlV7wFApefo90D38=; b=EPM1+GHJqtohkHABoC+6qaEup4F6jKJ1Rv5uN6y+iNJzXWDmTHNez41sI4DDD0xG9E 3kQsLmQn0XR6Py1HL7J5IpMqbFNyBdFUk59mkskH7wp/6gRlOuZ9p4yzDFM+nyZYs1o9 zy8GhGAx96XKpOLGRZKn1cPUbqj575SmPqxYiwww6rrCDZBSqey9vuNvrUsMSOAXx/Ap 25HB7VBIrZ2gpftReWxPCGMX83ajOn6wB4hMeaqFDZQiyEYPu2t1rH+WiRLCu0qv1GW8 rzaBiAV5PoREcmoYQNj9CJJz8VgSHzwH5Ads6yWrAg9qPv9ECYLZ7kQMPAO2NuslWJEJ Ejng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E943kb9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si106611ejb.751.2020.11.03.14.06.33; Tue, 03 Nov 2020 14:06:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E943kb9U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730842AbgKCUoN (ORCPT + 99 others); Tue, 3 Nov 2020 15:44:13 -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