From patchwork Thu Aug 31 06:10:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 9931243 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 5EB2D603FB for ; Thu, 31 Aug 2017 06:11:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5553428831 for ; Thu, 31 Aug 2017 06:11:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A5852884E; Thu, 31 Aug 2017 06:11:43 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 8F78628853 for ; Thu, 31 Aug 2017 06:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbdHaGKy (ORCPT ); Thu, 31 Aug 2017 02:10:54 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35480 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbdHaGKx (ORCPT ); Thu, 31 Aug 2017 02:10:53 -0400 Received: by mail-wm0-f50.google.com with SMTP id a80so21720201wma.0 for ; Wed, 30 Aug 2017 23:10:52 -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=Q+NJI0nO1+RlOxxT55ldhSl+HqyGd2iiyCvFJqV6zZc=; b=cNfQ/vbYxS62EN/kaUrFzeBGf8WR7plGCp/58EE/Sdic5dRrnuay2h8DFqV9UfmfPG BVdYyCcCbR8QpjFFvoxWM7EdsqefD5cM1Uz8b+qNRZvGNN7xyyfz0swa9DnBy+q08Ym8 gQm2glBNyYxhOJc23PIewieXPjr+U7MYB0lps= 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; bh=Q+NJI0nO1+RlOxxT55ldhSl+HqyGd2iiyCvFJqV6zZc=; b=kTcq8w8sU3c6IvN+dxcIaNYWGDxZauL7bSfYqAuZniJW8u6NC8a/0+1E49Q+g060L2 f0zFuJhhD7bkuxwMPtsr5owh9NLGk0pZfbrZRG9Gqlt9eHEn122P+2iE5llmKS7ZIhHB OJnZj3GnsOfz5K6JzLjdFmkUZRSfaChCp9Rhe6zQeukOn71zm1qw1s6wwzU2bS0sLjsF P3yGuNbL94rXTtTWgixBvTYSKr9SJqqrYJMYM9CM8XkCSJuYXXE/pKBsnen30pPDBqje VD1lJorCqc3ancTlfoUiuI9Ym8M9wdfNh8ZjesBjLJzH9GuO0q7qYIu+N+Yuw0+K5jVx 3nWA== X-Gm-Message-State: AHYfb5goBUSE7EqWXZQyicmNFafvGdbo2ZONXXLio21f3Gsq+3ILyBmb wRds2htY7FYTiL9Z X-Received: by 10.28.12.206 with SMTP id 197mr2920987wmm.18.1504159852258; Wed, 30 Aug 2017 23:10:52 -0700 (PDT) Received: from localhost.localdomain ([185.14.8.94]) by smtp.gmail.com with ESMTPSA id t8sm6676897wrg.21.2017.08.30.23.10.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 30 Aug 2017 23:10:51 -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, mgorman@techsingularity.net, lee.tibbert@gmail.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 2/3] block, bfq: remove direct switch to an entity in higher class Date: Thu, 31 Aug 2017 08:10:19 +0200 Message-Id: <20170831061020.4426-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170831061020.4426-1-paolo.valente@linaro.org> References: <20170831061020.4426-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 If the function bfq_update_next_in_service is invoked as a consequence of the activation or requeueing of an entity, say E, and finds out that E belongs to a higher-priority class than that of the current next-in-service entity, then it sets next_in_service directly to E. But this may lead to anomalous schedules, because E may happen not be eligible for service, because its virtual start time is higher than the system virtual time for its service tree. This commit addresses this issue by simply removing this direct switch. Signed-off-by: Paolo Valente Tested-by: Lee Tibbert Tested-by: Oleksander Natalenko --- block/bfq-wf2q.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 138732e..eeaf326 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -86,9 +86,8 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, * or repositiong of an entity that does not coincide with * sd->next_in_service, then a full lookup in the active tree * can be avoided. In fact, it is enough to check whether the - * just-modified entity has a higher priority than - * sd->next_in_service, or, even if it has the same priority - * as sd->next_in_service, is eligible and has a lower virtual + * just-modified entity has the same priority as + * sd->next_in_service, is eligible and has a lower virtual * finish time than sd->next_in_service. If this compound * condition holds, then the new entity becomes the new * next_in_service. Otherwise no change is needed. @@ -104,9 +103,8 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, /* * If there is already a next_in_service candidate - * entity, then compare class priorities or timestamps - * to decide whether to replace sd->service_tree with - * new_entity. + * entity, then compare timestamps to decide whether + * to replace sd->service_tree with new_entity. */ if (next_in_service) { unsigned int new_entity_class_idx = @@ -114,10 +112,6 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, struct bfq_service_tree *st = sd->service_tree + new_entity_class_idx; - /* - * For efficiency, evaluate the most likely - * sub-condition first. - */ replace_next = (new_entity_class_idx == bfq_class_idx(next_in_service) @@ -125,10 +119,7 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, !bfq_gt(new_entity->start, st->vtime) && bfq_gt(next_in_service->finish, - new_entity->finish)) - || - new_entity_class_idx < - bfq_class_idx(next_in_service); + new_entity->finish)); } if (replace_next)