From patchwork Tue Jan 29 11:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 156958 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4522528jaa; Tue, 29 Jan 2019 03:07:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5BUc+WSZmMnuKWylBglc6DYjiaEM7JxkPWh38X0eN9KQrLftzfGKBxXziPtrix4w9zuDE0 X-Received: by 2002:a63:5402:: with SMTP id i2mr22691155pgb.79.1548760028468; Tue, 29 Jan 2019 03:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548760028; cv=none; d=google.com; s=arc-20160816; b=jjlaJQWwmk3s0XySukG5VGqcYd6eLovxbM70QfgDzMT6wJ/Bcpi6+7EQrfqerC2GYa a1vUFTDubLSv1JFp5C3CgnX9RZ4wC6HOEp9X10M3tgtlFc1wkYTAr6qe8whJWLaRR/7O F5yoNAhuWgLIXiFK3KdeOE3dgmVS1qfzoflmtJYa9/CJFGOpjlNDW+N/chrllc00zeAM 8exxNYVH8zzylgo9cyFpVZXQdX5zSJZ1koikFVe6fUAnRPft08b7U3hInri2Jlg/U/Zh on+szC3WChte/cHKMziAJmJFS4ariAKZ8roUaH7htt82HUzmm4cJeunm3LXQMY6sJ3TD Zw8A== 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=gAUJ5pwSD9lzILEQVJ0hCKATJxbw5gWvL06xocd7ofI=; b=yGFkEInnCest1TlQUZ2X7lH4Ros966f4jQxjYdIIOGDhGSD+zTl2HOk1gLGUiIC0MC hcZ5Hx7p1CuAr0WL62O/hC/1Lw94NxzkIHTKYGUc8VMiqQigj5sZtKRa6uesLkDge+TF 0qtX2Xxd4Ln6WGfjpqOSXK9Y6rHg035wfiu1+aR53Xx+X/jk3J5H5h3NYPnbOwEecgfE CHA3C0PDfOZ64SJtCV9/ps9LfzFOJtQ7v0hYPogzj7TA+dcRpoVZdlOtklTKRLMOyXDg +dwj5nziz3mSP+zzRDnuJOTqez23g9bkoZbsev/6Y6bGoiqtwstvMMfIIYG6mkJE9VGX bmiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QvbYcrkZ; 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 187si11085318pfv.238.2019.01.29.03.07.08; Tue, 29 Jan 2019 03:07:08 -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=QvbYcrkZ; 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 S1728366AbfA2LHG (ORCPT + 31 others); Tue, 29 Jan 2019 06:07:06 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46972 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbfA2LHB (ORCPT ); Tue, 29 Jan 2019 06:07:01 -0500 Received: by mail-wr1-f67.google.com with SMTP id l9so21486017wrt.13 for ; Tue, 29 Jan 2019 03:07:00 -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=gAUJ5pwSD9lzILEQVJ0hCKATJxbw5gWvL06xocd7ofI=; b=QvbYcrkZ78lOm1jmQmedgdRvvGotGVNAELS2tmY8vO3gAAYJdENhs+i6K5OIIS+aBo xUCOofevIfoCvVZg2QYNSy+FXYOWoznVsUprE60jpyQfKtFMCKboVcVrfLJ5xT07Nnt9 1ToHzHBJJd9kTtBhEl43pS4OGRudDsvoqg7rY= 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=gAUJ5pwSD9lzILEQVJ0hCKATJxbw5gWvL06xocd7ofI=; b=eMRqut/2j2KY0b/jR6e2dIOn72oNGh8CxsFOph8wBMborLTn7f2ozoi8yQwaJIWIze svVSOMWPvLB567w1YuuRa8FZJ93YEncDRRLip+wFDQnFvhlKvmwnnwmfEkL6dl8xZ0WM ezJj0F/+YSzRAMvbvft5IVIhORfRp7CLTs+jsLoOmuHqJNS7Za+yq3d5WU8LfXn7Gsnd IsjkwzwBL5nkVhSEg14+i7sBgb7yEDKiCTYkkoZRoC6RfJ6E3FbhddB/4gohwvl43ZQ/ P1ninS3OFmD1tpe0+1auWjFwsq+QWBUOu8Xdki3/QU8JSx6I1lhysoY1DyAW+vix/k+B h8mg== X-Gm-Message-State: AHQUAuYc7uI1mIFDughRTWd1123PH0bMXCCntYCBAkQm0Y8JdMMouPTW l5S+E7isUgti6P7GJD3dWiitGQ== X-Received: by 2002:a5d:4046:: with SMTP id w6mr4707214wrp.92.1548760019712; Tue, 29 Jan 2019 03:06:59 -0800 (PST) Received: from localhost.localdomain ([88.147.67.218]) by smtp.gmail.com with ESMTPSA id s132sm2066112wmf.28.2019.01.29.03.06.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 03:06:59 -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 02/14] block, bfq: avoid selecting a queue w/o budget Date: Tue, 29 Jan 2019 12:06:26 +0100 Message-Id: <20190129110638.12652-3-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 To boost throughput on devices with internal queueing and in scenarios where device idling is not strictly needed, bfq immediately starts serving a new bfq_queue if the in-service bfq_queue remains without pending I/O, even if new I/O may arrive soon for the latter queue. Then, if such I/O actually arrives soon, bfq preempts the new in-service bfq_queue so as to give the previous queue a chance to go on being served (in case the previous queue should actually be the one to be served, according to its timestamps). However, the in-service bfq_queue, say Q, may also be without further budget when it remains also pending I/O. Since bfq changes budgets dynamically to fit the needs of bfq_queues, this happens more often than one may expect. If this happens, then there is no point in trying to go on serving Q when new I/O arrives for it soon: Q would be expired immediately after being selected for service. This would only cause useless overhead. This commit avoids such a useless selection. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index c7a4a15c7c19..9ea2c4f42501 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1380,7 +1380,15 @@ static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, { struct bfq_entity *entity = &bfqq->entity; - if (bfq_bfqq_non_blocking_wait_rq(bfqq) && arrived_in_time) { + /* + * In the next compound condition, we check also whether there + * is some budget left, because otherwise there is no point in + * trying to go on serving bfqq with this same budget: bfqq + * would be expired immediately after being selected for + * service. This would only cause useless overhead. + */ + if (bfq_bfqq_non_blocking_wait_rq(bfqq) && arrived_in_time && + bfq_bfqq_budget_left(bfqq) > 0) { /* * We do not clear the flag non_blocking_wait_rq here, as * the latter is used in bfq_activate_bfqq to signal