From patchwork Thu May 31 14:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10441253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6D15602BC for ; Thu, 31 May 2018 14:45:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D38462973B for ; Thu, 31 May 2018 14:45:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7C6229740; Thu, 31 May 2018 14:45:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4540C2973B for ; Thu, 31 May 2018 14:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755415AbeEaOpq (ORCPT ); Thu, 31 May 2018 10:45:46 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51808 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755444AbeEaOpe (ORCPT ); Thu, 31 May 2018 10:45:34 -0400 Received: by mail-wm0-f65.google.com with SMTP id r15-v6so26845712wmc.1 for ; Thu, 31 May 2018 07:45:33 -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; bh=/0Hf7SCJj6Y7ejeDOkPs34vFaFRY+69k50LwZc5XXqI=; b=hOZ+FKI/1edNxA6XLKxJHDCcgDilTJKv/OvhypdNUmRPGexLtBqVdEZajrW70jaIQn Tx72g0l1XvmsARF8mXaaEqJKmT8fz/LfXDbEx1/ncvQjFXjuq7GQjhF19WWHvi2i5+JI KGW+gRaHx2o952O8/7JnndJ0ew29p5hfjH4Ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/0Hf7SCJj6Y7ejeDOkPs34vFaFRY+69k50LwZc5XXqI=; b=FImy6XgG1g0o6nB+scu2LUDmlURlDDyGS2Rh2DIZTgm2JAOAqcCNZQBhrsg8LpywGD To7mvk5Tmn3hDhNLjZn6d7mavLm4HGxdhrASgO7ig2Y6T9qVYJ8y69h9Dw+q+V5dFQmx M8AYUNd1cYN91VKQZOa9EOvxtXJ57tjYoVAPQv+p0lalfGRmXkiCpFeY7ILMQh6SxkPO irH5xhifFiuv3V9oUFXgnqIrW8SUJ0cz9cgQdj+xErihDoux770YaUWKJy1V0jNvAXWR ZNkwXG7ZsahiljJrqAEwfGM4PMBjQ9KHD2qOk3hQU/oU1jH36U33tv7eVbZzK6tjbkgc HZ1w== X-Gm-Message-State: ALKqPwcsFNSJDCvaeRkDsdpGSewbeAVh8QUVJY+6/slPiinkoNzSAFPP E977Udf4IFx7MhZpb9OJrgC8gA== X-Google-Smtp-Source: ADUXVKKh0yA2jR36XpYJNzn2y3jOmuD/6wXIOAGdYlfFin1C4YOuH1bgH/g50tf4Y/61zxGiqN/tVg== X-Received: by 2002:a1c:6a1a:: with SMTP id f26-v6mr179479wmc.1.1527777933040; Thu, 31 May 2018 07:45:33 -0700 (PDT) Received: from localhost.localdomain (146-241-12-84.dyn.eolo.it. [146.241.12.84]) by smtp.gmail.com with ESMTPSA id y45-v6sm36106869wrd.97.2018.05.31.07.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 07:45:32 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, sapienza.dav@gmail.com, 177992@studenti.unimore.it, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENTS 4/4] block, bfq: prevent soft_rt_next_start from being stuck at infinity Date: Thu, 31 May 2018 16:45:08 +0200 Message-Id: <20180531144508.3927-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180531144508.3927-1-paolo.valente@linaro.org> References: <20180531144508.3927-1-paolo.valente@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Davide Sapienza BFQ can deem a bfq_queue as soft real-time only if the queue - periodically becomes completely idle, i.e., empty and with no still-outstanding I/O request; - after becoming idle, gets new I/O only after a special reference time soft_rt_next_start. In this respect, after commit "block, bfq: consider also past I/O in soft real-time detection", the value of soft_rt_next_start can never decrease. This causes a problem with the following special updating case for soft_rt_next_start: to prevent queues that are not completely idle to be wrongly detected as soft real-time (when they become non-empty again), soft_rt_next_start is temporarily set to infinity for empty queues with still outstanding I/O requests. But, if such an update is actually performed, then, because of the above commit, soft_rt_next_start will be stuck at infinity forever, and the queue will have no more chance to be considered soft real-time. On slow systems, this problem does cause actual soft real-time applications to be occasionally not detected as such. This commit addresses this issue by eliminating the pushing of soft_rt_next_start to infinity, and by changing the way non-empty queues are prevented from being wrongly detected as soft real-time. Simply, a queue that becomes non-empty again can now be detected as soft real-time only if it has no outstanding I/O request. Signed-off-by: Davide Sapienza Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 31ce089d54eb..37cadc643c56 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1416,15 +1416,6 @@ static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, return wr_or_deserves_wr; } -/* - * Return the farthest future time instant according to jiffies - * macros. - */ -static unsigned long bfq_greatest_from_now(void) -{ - return jiffies + MAX_JIFFY_OFFSET; -} - /* * Return the farthest past time instant according to jiffies * macros. @@ -1569,7 +1560,8 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, in_burst = bfq_bfqq_in_large_burst(bfqq); soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && !in_burst && - time_is_before_jiffies(bfqq->soft_rt_next_start); + time_is_before_jiffies(bfqq->soft_rt_next_start) && + bfqq->dispatched == 0; *interactive = !in_burst && idle_for_long_time; wr_or_deserves_wr = bfqd->low_latency && (bfqq->wr_coeff > 1 || @@ -3272,23 +3264,6 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, bfqq->soft_rt_next_start = bfq_bfqq_softrt_next_start(bfqd, bfqq); else { - /* - * The application is still waiting for the - * completion of one or more requests: - * prevent it from possibly being incorrectly - * deemed as soft real-time by setting its - * soft_rt_next_start to infinity. In fact, - * without this assignment, the application - * would be incorrectly deemed as soft - * real-time if: - * 1) it issued a new request before the - * completion of all its in-flight - * requests, and - * 2) at that time, its soft_rt_next_start - * happened to be in the past. - */ - bfqq->soft_rt_next_start = - bfq_greatest_from_now(); /* * Schedule an update of soft_rt_next_start to when * the task may be discovered to be isochronous.