From patchwork Tue Jan 29 11:06:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 156962 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4522748jaa; Tue, 29 Jan 2019 03:07:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7MicuHmj1V7JJGMab/4yf5Q8KMOVsFhjxwZX3HUiXLvsmuQYy5xRjdDCgd6ovqVCGJimqO X-Received: by 2002:a17:902:24e7:: with SMTP id l36mr25701754plg.61.1548760042399; Tue, 29 Jan 2019 03:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548760042; cv=none; d=google.com; s=arc-20160816; b=KiNMF1f9E/uqTcAtIED0skrQgAlQBoecfBGWte/RdtpfarQ8/tkcw4BflXLbbfhhvW n7H/ocpeFXExhN+rLTXaSys7zydK+Yv/7hwNMi5oi+lOps5XBQor9/lIKX85q0r7fOH2 vhYqi9LDJoZAso79VM2ccIcdI+5GjvMEatMCl/A/4R2b3Aa40va4l6MifKUJ7OMK6SCf WrpTMFENQRK+bhyb6gFyKf7nSt9Fq1rE2/DSvss/2EJU8xhO1CNbtIkj04NHqiXdqMfz kZkCeCG3270Xmvc/dM5sWmOzB4AZvqrjzhliUabVPGJxaHGiYf/a4w7OpAMFWdYT8gNZ GlOQ== 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=C6mbkxYARjOVWPicsF+8F1IWlVh58inCJzHv80eeZ00=; b=QglaLWng2ITitR+36w9FjF3V97XwkKYOcFMDmWkMAkfdvG4WcAiAOPC8XBmdtiUG5C 6pBM0JdvnrVMOCHohc3vpDeKsU3gOADWnIDwTGtVUSR5zzgUdQOYarEXTMw8X6Lom3B0 ZDBcJpW1RrWlUGqnGQ9t4RUViGj2/0Ne8CPilH1kQPNnupPc4avWBufqGbwa1mQpogq6 +VMSHaF581mjzMgc9FMPM1VNL2nzxLu/8eKcgo4AUFsI2UQ5Ok48z88389/Rp2a//Y3E L2fT7v6U4vDvn5O9XrpzPZV9CRyy+NUqv4dSdtMw9PvGm+5ykvyBWiVu9qbNA3n3yw5D CAJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaAV8QPF; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si7692080pgh.92.2019.01.29.03.07.21; Tue, 29 Jan 2019 03:07:22 -0800 (PST) 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=@linaro.org header.s=google header.b=WaAV8QPF; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728640AbfA2LHU (ORCPT + 31 others); Tue, 29 Jan 2019 06:07:20 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37874 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbfA2LHQ (ORCPT ); Tue, 29 Jan 2019 06:07:16 -0500 Received: by mail-wm1-f65.google.com with SMTP id g67so17261902wmd.2 for ; Tue, 29 Jan 2019 03:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C6mbkxYARjOVWPicsF+8F1IWlVh58inCJzHv80eeZ00=; b=WaAV8QPFZ1BYtgx4VTqu89ErSb86GwumiYIkwW57mgQfl7Nl8icwCI+CpZ6V/iKbv0 99j6c8j7vc8VEpAnOX39pOSRzg09Sv85zsy1n2cOa9URAETvg/4YZ621WnoNUPCzDTCp ATa00BVE+iqnjy+Teq0mqD9PtsCE6+Kx6VCCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C6mbkxYARjOVWPicsF+8F1IWlVh58inCJzHv80eeZ00=; b=LaTeTPT8BO+B1jJ48JRXV+6w2Lt1naKDLzRXVyXFQSt0fC5kkMq/A9F4Py/pmJwXtz QC4l1kAxkBcmU/VfwKdY78lpOL+tUsxWuxZNpW3ku4xSPbVabSHtP5Ux1UOZ2HMKmU2x wjSlFK0wJE+2W28ZEs31+/egs7cakXMkdHJTQ8flqBobKb4lpsZYbUAq2sKqo63VrFwC lZeQQNAhrKae1+TGhxi+Fa9w77EFonZgD3WaqrLyCMFJgrGuneXJk0/zmjPZ1uGhKD+g loDJJCo8QdvXTwH8Djnf85CBU6B+4QM7JDAqr1qKvsBBEakjgOvQ47znqm/v5peNiib/ KECA== X-Gm-Message-State: AJcUukeSCMuCUNSP94ZngrnTzEdc26MUYtPthMxmHaRZiVRlEGT+jsdt bo+gr0UZLdorNBHUipztQJgRgw== X-Received: by 2002:a1c:ef11:: with SMTP id n17mr20436112wmh.112.1548760035222; Tue, 29 Jan 2019 03:07:15 -0800 (PST) Received: from localhost.localdomain ([88.147.67.218]) by smtp.gmail.com with ESMTPSA id s132sm2066112wmf.28.2019.01.29.03.07.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 03:07:14 -0800 (PST) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, mancha@tower-research.com, Paolo Valente Subject: [PATCH BUGFIX IMPROVEMENT 14/14] block, bfq: fix in-service-queue check for queue merging Date: Tue, 29 Jan 2019 12:06:38 +0100 Message-Id: <20190129110638.12652-15-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129110638.12652-1-paolo.valente@linaro.org> References: <20190129110638.12652-1-paolo.valente@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- block/bfq-iosched.c | 5 ++++- block/bfq-iosched.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 06268449d2ca..4c592496a16a 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2251,7 +2251,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); @@ -2791,6 +2792,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 30be669be465..062e1c4787f4 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -538,6 +538,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;