Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5644094img; Wed, 27 Mar 2019 12:19:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwm6y2oaY+7+Ie6voWKp1nZQdGsyXWvbNduXGzrun/5OcacgHjCWLd92DWaNOzBr0EJPvOn X-Received: by 2002:a17:902:8a84:: with SMTP id p4mr37926303plo.2.1553714346895; Wed, 27 Mar 2019 12:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714346; cv=none; d=google.com; s=arc-20160816; b=h2SpbXVJMF63WpPtuOu8Zk4C7m5kojAx2mzoGSuQyhGxBL7HNIv+ljPiAykXkWNuih oas4bxLb93fxyuYnxsFUBUpNxjqMQX6bS72tfzMxYx8YVtnqXakYMDNO+5ZAhBDKE7d6 wQpxgaum6FwrL3DmFJghnTZ90VRoj1IIh60nMRar/049L9aX5a797AeZzltd7yvZ3/Ax BTp8iF2WPx5LSmIZBJhTDF6TLqhvB43aINXxgLFRzYA1e1NpjTnAV/0F8OJs7pPx9+fd WxW42IiGnmVVa3x+Atpb2lR4ArOmbPWsaQtm9kU8uDZaINwgrqb+koXcdgyLYZ5x4G9j Yisg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fCzAsT96jPlFV3IXMM/fGd70gcKHvWdEBqkI2DqNCEw=; b=jF8JgFi4TaM5APt8EMu8YFU+quS3jL2z8un64nwvPjd20iJl22WnBQJkDL6feXUnwM wKZJHwC+97HQRxez9A7rp5bGwDanX9jC3herihr9VpXhb+D81H7zRafqi4o6nmX3ZxCT vX00nBVN3RT66HBPaDruoS8pl/MmNTfphHIk1zOlJF3b2OScjh30FK+5MAA6CNdpu4aa 1KDSQ1tQAuRbStCtcEqjidosyfRg+ojVIvC+CcLNJfncXhUg+dVkWOdW4au4bCr4UAeK hYHA7X0aznMoiW9ETJ2RTYo4lJgowEVys3n0Y1XivfaNOG5UxrOfCBOwT6zuH0khYVEs TJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hv9I5NzA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id t16si7891891plr.63.2019.03.27.12.18.51; Wed, 27 Mar 2019 12:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hv9I5NzA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2388219AbfC0TSH (ORCPT + 99 others); Wed, 27 Mar 2019 15:18:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:50312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbfC0SI3 (ORCPT ); Wed, 27 Mar 2019 14:08:29 -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 C00732063F; Wed, 27 Mar 2019 18:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710108; bh=M7gpAwpicE9RVF3LMLloeqU6+OyvD7pICDKzU6ZWqH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hv9I5NzAwgLex21NJugYx9hIAcSWTMeEIfW9HCUND6jliamRG7f/omP5apFSbZJFk St8ZgSv15PSTIIU5heCQYz9wkmebDcJCWr7R4Kppez9GVYva/6+TXI3ZmK+pFx/nJ5 3qHPF4Psf0PE5deC3qmkqQOPS/RvouuJgeG7CIcg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Paolo Valente , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 198/262] block, bfq: fix in-service-queue check for queue merging Date: Wed, 27 Mar 2019 14:00:53 -0400 Message-Id: <20190327180158.10245-198-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Valente [ Upstream commit 058fdecc6de7cdecbf4c59b851e80eb2d6c5295f ] When a new I/O request arrives for a bfq_queue, say Q, bfq checks whether that request is close to (a) the head request of some other queue waiting to be served, or (b) the last request dispatched for the in-service queue (in case Q itself is not the in-service queue) If a queue, say Q2, is found for which the above condition holds, then bfq merges Q and Q2, to hopefully get a more sequential I/O in the resulting merged queue, and thus a possibly higher throughput. Case (b) is checked by comparing the new request for Q with the last request dispatched, assuming that the latter necessarily belonged to the in-service queue. Unfortunately, this assumption is no longer always correct, since commit d0edc2473be9 ("block, bfq: inject other-queue I/O into seeky idle queues on NCQ flash"). When the assumption does not hold, queues that must not be merged may be merged, causing unexpected loss of control on per-queue service guarantees. This commit solves this problem by adding an extra field, which stores the actual last request dispatched for the in-service queue, and by using this new field to correctly check case (b). Signed-off-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 5 ++++- block/bfq-iosched.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index cd307767a134..f010810c095f 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2224,7 +2224,8 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, if (in_service_bfqq && in_service_bfqq != bfqq && likely(in_service_bfqq != &bfqd->oom_bfqq) && - bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) && + bfq_rq_close_to_sector(io_struct, request, + bfqd->in_serv_last_pos) && bfqq->entity.parent == in_service_bfqq->entity.parent && bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) { new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq); @@ -2764,6 +2765,8 @@ static void bfq_update_peak_rate(struct bfq_data *bfqd, struct request *rq) bfq_update_rate_reset(bfqd, rq); update_last_values: bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); + if (RQ_BFQQ(rq) == bfqd->in_service_queue) + bfqd->in_serv_last_pos = bfqd->last_position; bfqd->last_dispatch = now_ns; } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 0b02bf302de0..746bd570b85a 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -537,6 +537,9 @@ struct bfq_data { /* on-disk position of the last served request */ sector_t last_position; + /* position of the last served request for the in-service queue */ + sector_t in_serv_last_pos; + /* time of last request completion (ns) */ u64 last_completion; -- 2.19.1