From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 319F1C76186 for ; Wed, 24 Jul 2019 20:30:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07C7D21734 for ; Wed, 24 Jul 2019 20:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564000228; bh=itHkwzy14prMZAQ3zT5j6ipj75mgLGxrkFLJacMNN9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TJtAOKzkZU1xRUzRWyCn0biZHZvmgJNMYDw/b9HbCdtKxI2f+9GNzVMvFDV5ATr6N hm2xTf2W/7qHflyOdbVsnYGKLJG8SmS3Lma7xmgjSL7l7P+aUNkSJjNUZr43PkUHPx h/AS+vyVrAX3mGl4YtgiUAxRFHdigivCM+fOOSY0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388842AbfGXUaT (ORCPT ); Wed, 24 Jul 2019 16:30:19 -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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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