Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1035161pxx; Tue, 27 Oct 2020 06:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/i8HLYSfuig8PoPRc8BB7o6HEv1w48cwDPROIQZYcCNiP1xQMJS9GzYR85/JQPe0VA8ZT X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr2608547ejf.11.1603806683760; Tue, 27 Oct 2020 06:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603806683; cv=none; d=google.com; s=arc-20160816; b=CtRvV3QNvfk74xZmWvBDCf6pUOTA69lwY5dauf56u6L4OfDnSfs1mHeCMbRMin5bKi xnP0PsXE5+FOY9qXHKiDlqK4JlwFZJTD5LGPNl1OOVFAzwDWFLUDS0fDTEU/gsSjq/sj 3b3B9k+XVYU93eQT/8LLq3swwnpPOokCQDgJDriE4VbiHMa7AvZixGjnXRa3xErk+QfI BQ1xbmgBPR0jFq17vke3s0tgE5+7TeDJ3nIqZvBeiZBluniJASEnlTLIPVPkZw5A8uLq y5W2yimlAB5uTXIavglAyC+EbvZmV30bOzoT7T00SPz3cDMXzgcI4R22EKHfR2/Mk2Gd KbvA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MzEGrIBfslvvkQeAuoNUqdXfmcoBxwis7FuDWbE7IIA=; b=iqQ9ROIUSMfaRK5BkumrC4OhWjE16ZOagugLAq+lZzlkjYKaMN78Tdxj8KYYWyOi0t ljwkWRyf7QsiYOM/79hI+e51uqJJIm6OtzsAhPaAQVTmG8PpHu+R+iUHMi/mErYqwwUV n1bmmrwCbRW+rukUfNIncRFcLPlqhSgan615XOiFNqfJCpUo3UKxeIKKZGiK8L89Qn6k O/1vc+/r+SfCUFvyt9mEvnae7hc+PFnkIldDmcN3XXM64YZ2H/4sSjRAZ4NF8IDcmhxc rU0u+A2Tcf5J+WJxcPrUv2gMO0JBsCDLxR8evl6an8wvPBt8ErEJ+R5utS4CMbf7fweG qqmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="G/JQei82"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si952086edl.228.2020.10.27.06.51.01; Tue, 27 Oct 2020 06:51:23 -0700 (PDT) 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="G/JQei82"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502080AbgJ0AjX (ORCPT + 99 others); Mon, 26 Oct 2020 20:39:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:51576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409330AbgJZXvL (ORCPT ); Mon, 26 Oct 2020 19:51:11 -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 B344E20878; Mon, 26 Oct 2020 23:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756271; bh=9+3VoOP+nxTVMDbH4zV35RJX/lzj91BA3Ht3ZiGjQZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/JQei82sTEmJQClUB3HlFlw//547F5HGUk1+CGa8qr6j2Ce2dHKlq+w84z9ZPsce gkxRdU1LrhToWxLv7WY1RrbA76aw9zzlwxIurTgSnFJInil32LLkEW//SOqt/jQWwX 4uZa7sQL1tkBc72SlsXZ3ORuYDXiNG/65mcG6vvU= 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.9 103/147] block: Consider only dispatched requests for inflight statistic Date: Mon, 26 Oct 2020 19:48:21 -0400 Message-Id: <20201026234905.1022767-103-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-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-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 cdced4aca2e81..fd578a0ea67dc 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.25.1