Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9983428ybi; Wed, 24 Jul 2019 13:31:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8/pVq400dbsKdSlVqejbYBAxcbsRlI8vXu+MpsHHacepPdqkHoaeVqjSrLJDUJqGJ2fpD X-Received: by 2002:a65:5584:: with SMTP id j4mr52594815pgs.258.1564000305319; Wed, 24 Jul 2019 13:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000305; cv=none; d=google.com; s=arc-20160816; b=lwL14BMA7OxOrGwynl+cmZ6ddV5beuBjD12FRPVlP1TlDjPXnRiZbAHLCAtcDiXbUB AQc9fKZQZADxtgJe50jDfahHzjkH59DnRuQrwerAkY0OBk87wxYJAKNsFvg3mHnc3qRg pJ62PMjepjya+mk7McnywmC2BiBnox2m8KIIrLnIKxy8rd2AP+JG94hFRQCPmZJMwpoc 6zMqa44zCKjfFPjqYVCzPq/p2nBgUaIcOkDVyc3P7X1mBrAZa727zCIsfn0RmSXz5DeO nQ2zaJ2jgpJynEHKfTpxBu5bY7xnQOscetvrJOFiMNh5dUCT4arR9fbZMwNg45D4CrO1 UEzw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tWYii94dG0r3GaySxqfZEPuyQjw+t0bHgRB3IOBKqmM=; b=DWIWls1dZ4x7CI+AqfLm/5WlbuaUr2wtaIItHgOo+vJt0yvp5+mI3Hscu+D+dfIC5N WZLL49T3KQOEO/vVFkX0sO+4ymmfHg8L1h7LYJeaP7rsv/na+/z01RB7wKxcOrUUOA5f OoHP688QR1xpLWhY91tx89W1mAiXcsBCfsnATFYcJ+8eqjgD63oYIHT0Rer0MNYbwlik itHVYAlKhJAnv6trbex+Ci2Q5P4qLum/HdIevbnmVVRmHMvvwMdqmTviu97sKDw7ZSiz yCuvK2tgwvNRQ32ciHvRMzGgc/YucyW3fd7wDYZ3U1btwD68e0Ya6VHuVXOP16nBLFa2 ExdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h9PnxGZy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si17753020pfi.253.2019.07.24.13.31.30; Wed, 24 Jul 2019 13:31:45 -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=h9PnxGZy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389577AbfGXUaW (ORCPT + 99 others); Wed, 24 Jul 2019 16:30:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:53220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388578AbfGXTcA (ORCPT ); Wed, 24 Jul 2019 15:32:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E9F4120659; Wed, 24 Jul 2019 19:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996719; bh=itHkwzy14prMZAQ3zT5j6ipj75mgLGxrkFLJacMNN9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h9PnxGZyEuh2XPnHEdNpqHtklBFOQnegu3LO7q2asbAJCvHDGQSjmSnRyPDdkc0mz PmnODB22faZ6e3b045VDn4xOPds/H8A5GmXR0/B7ZkbKfQZuyjTZPgpITjYLjFz0m4 MeCNtxWbsc6Spl9zo+2OYN41unpw1jBb8J6IcYM8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Srivatsa S. Bhat (VMware)" , Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH 5.2 166/413] block, bfq: fix rq_in_driver check in bfq_update_inject_limit Date: Wed, 24 Jul 2019 21:17:37 +0200 Message-Id: <20190724191746.906791848@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit db599f9ed9bd31b018b6c48ad7c6b21d5b790ecf ] One of the cases where the parameters for injection may be updated is when there are no more in-flight I/O requests. The number of in-flight requests is stored in the field bfqd->rq_in_driver of the descriptor bfqd of the device. So, the controlled condition is bfqd->rq_in_driver == 0. Unfortunately, this is wrong because, the instruction that checks this condition is in the code path that handles the completion of a request, and, in particular, the instruction is executed before bfqd->rq_in_driver is decremented in such a code path. This commit fixes this issue by just replacing 0 with 1 in the comparison. Reported-by: Srivatsa S. Bhat (VMware) Tested-by: Srivatsa S. Bhat (VMware) Signed-off-by: Paolo Valente Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index e5db3856b194..404e776aa36d 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5398,8 +5398,14 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd, * total service time, and there seem to be the right * conditions to do it, or we can lower the last base value * computed. + * + * NOTE: (bfqd->rq_in_driver == 1) means that there is no I/O + * request in flight, because this function is in the code + * path that handles the completion of a request of bfqq, and, + * in particular, this function is executed before + * bfqd->rq_in_driver is decremented in such a code path. */ - if ((bfqq->last_serv_time_ns == 0 && bfqd->rq_in_driver == 0) || + if ((bfqq->last_serv_time_ns == 0 && bfqd->rq_in_driver == 1) || tot_time_ns < bfqq->last_serv_time_ns) { bfqq->last_serv_time_ns = tot_time_ns; /* -- 2.20.1