From patchwork Mon Jun 24 19:40:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 167636 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4615086ilk; Mon, 24 Jun 2019 12:41:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIIM+93XBU2bhzPR8GO2EPyidOEeFiHr1MmEvTU4wEour5uIAq9/y7eQexasox5Is/ktGK X-Received: by 2002:a63:4f46:: with SMTP id p6mr3048366pgl.268.1561405272787; Mon, 24 Jun 2019 12:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561405272; cv=none; d=google.com; s=arc-20160816; b=EcWDgvzo4O9ChRwnBBmrhrpZEPpTBtvryHPt+19mRdMnchu5qloYLayADtKf3Fp16o /B4Zj9vA5+g9UJdFvweAtnJ6h+xnpM3ib6Hi5t0EpsL5mLKGyEPzfHLo1nPgLQ6LjO0z tIFYbcyD4FomHV9vueM0JIkdAje4tYZjT/TDaKaPSVr8GmrmzmZADZAv3rrtTqRKrxmN R3yJdIlS+ascNNXOJoJhjy3gZqgV1dVf4wjxaclHjofzjSb0gz3zUZ21zpx77wwyWsFf LX2rGjf0wxRUzPjK4MLlUF5C7eVeT93s4Vqt37tjUIDgi1LxhA579Z+itgCrkL+bSI6n PSGg== 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=atnBayrLpc2AX2svhMGsm60ysNZ9T7b+BNR7ZDTK0cg=; b=FWDT67Qh3Me+DKpAQNEFpX6DxLfGpNksx6+OmN1MIXIzYoPM6M34TSRb9rFCjw4ToO 3gIO2pDW3nAVZfL0mAn51Yd9KOg1dQE9/TcSrjTV/T4JZ6oFwMdzSWCk0FILV+dEEYvm +/EmH5Q3jiS4s7V7crfwZxbxzAAyZOmYDha/UBqI3wjhSl6//1Mt2SUotfYRynsSyiff K9gveRIKxjgsXs5jaVc+fDuHF3IJqNcuS+gHexteoiHRFYTBYcR/tA7TmsiDy/mZJMi/ +QH5FE6gXYijqLuFYORe/SKJR2M/BYZutzf6siTywQ4NkGB1GM4r14yCzjrpfroiOzVS 9O1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=loOF0OsD; 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 w21si12071187pff.263.2019.06.24.12.41.12; Mon, 24 Jun 2019 12:41:12 -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=@linaro.org header.s=google header.b=loOF0OsD; 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 S1730658AbfFXTlL (ORCPT + 30 others); Mon, 24 Jun 2019 15:41:11 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45003 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730403AbfFXTlJ (ORCPT ); Mon, 24 Jun 2019 15:41:09 -0400 Received: by mail-wr1-f65.google.com with SMTP id r16so15136613wrl.11 for ; Mon, 24 Jun 2019 12:41:08 -0700 (PDT) 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=atnBayrLpc2AX2svhMGsm60ysNZ9T7b+BNR7ZDTK0cg=; b=loOF0OsDukaQjB4gzqEHf33xXpdkbvyUk80B+5eIPhILYl3VwyDSvqJO1sDzZPH6vR rYRmMEWXgZZ+gLv5AELdm+O8YH2kQdVu5DaDMI8iW08rgE1dfcsAHgsEalivjQKP7Jk5 ccts3YWXMX9OGdxCu3hjcf8sqVTErfRXU8/mZo9lefPBvJg7DWfUfAEC10ylbMWRFaoO +xisJCFcz4ITFGyNEpO6/c8P6ktheNpleL+RrZ09eT0srbMUAvnBR3usvSU1419Bmp9e GDd6dNe/u6Axk6UZpZxbMgrpyHrxioQvGQOnpNn7WlkjsFbxeTQA/5Wg4ZJTcbJlMJlA 7stA== 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=atnBayrLpc2AX2svhMGsm60ysNZ9T7b+BNR7ZDTK0cg=; b=LA4+D327dght5JSdzEziXRzCyzzGBOxVZVxhzYp0/0B7GP/UlXBwLkMnl7K5spAi9n d4gH4r/Ehc5qZ25Bzl1aZ3wMuqgyN1XPvddMs5zFTkyRR9MW6iG4C0+7hLJZS2R6aL1f jo5ViM0TI5tXdwoebPG/W/xQDk6FX8SfkXJxq6VQ2Umyc2QuQapQa/78Hz48yZy13dD0 rsYUaeyvQIF9gptIfNIg8QgGYSf/rWiqE659KQyAa/eFqG9Fq3qfOaT8ek4I1c+mR8QA MdVsKnZnNGIqf4qTlN9NmzGKRpJGI/9SjF22i7+wYVSqn7LX0FnziEKdI7P37b/FVXA7 PgbQ== X-Gm-Message-State: APjAAAWYQW5XgwIEzj7V+ErNosnpfc9aJJUFYElJ+ooDI3pEbtALMHNo jZaYrVPgq1/vPav8orCNpXQMJg== X-Received: by 2002:adf:ec4c:: with SMTP id w12mr34579834wrn.160.1561405267903; Mon, 24 Jun 2019 12:41:07 -0700 (PDT) Received: from localhost.localdomain (146-241-101-27.dyn.eolo.it. [146.241.101.27]) by smtp.gmail.com with ESMTPSA id q25sm17615395wrc.68.2019.06.24.12.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 12:41:07 -0700 (PDT) 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, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, bottura.nicola95@gmail.com, srivatsa@csail.mit.edu, Paolo Valente Subject: [PATCH BUGFIX IMPROVEMENT 2/7] block, bfq: fix rq_in_driver check in bfq_update_inject_limit Date: Mon, 24 Jun 2019 21:40:37 +0200 Message-Id: <20190624194042.38747-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624194042.38747-1-paolo.valente@linaro.org> References: <20190624194042.38747-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 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. Tested-by: Srivatsa S. Bhat Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 9bc10198ddff..05041f84b8da 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5481,8 +5481,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; /*