From patchwork Thu Aug 31 06:46:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 9931289 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 2EB5B60362 for ; Thu, 31 Aug 2017 06:47:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2242A28856 for ; Thu, 31 Aug 2017 06:47:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12B8128858; Thu, 31 Aug 2017 06:47:38 +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 961D228857 for ; Thu, 31 Aug 2017 06:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751393AbdHaGrX (ORCPT ); Thu, 31 Aug 2017 02:47:23 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:35946 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751191AbdHaGqs (ORCPT ); Thu, 31 Aug 2017 02:46:48 -0400 Received: by mail-wr0-f170.google.com with SMTP id p14so23747719wrg.3 for ; Wed, 30 Aug 2017 23:46:48 -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=YjEtdvjfb9xLDIrEUJbj7IcmuE/lWWeOhnohyU29UQs=; b=YrMmmocJZ+6DIre4qYxdCrrbIK1M5cUEECkjgcW6lAbmIjEw2yMQnc7Pu6tMUm1H9M UN7aolGANHACoS796jnkAsyduS0e8vYTsrPBcgo1nVTKMhea1PJEfJNxDpZ1PZjHvC2+ 7iUtj4dlWf6GAB4FhhJqNb7MJ+ZRuNiKfk6Qc= 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=YjEtdvjfb9xLDIrEUJbj7IcmuE/lWWeOhnohyU29UQs=; b=umEblsCkX0hkraPaOU9kRB7SFklRmLomZ4h6OQdzA9bsv6XtV+2eAy8P+2uHe4YQ/v kHz6BoWNS/9u3dxC7eeCvy1BbtNCL3hHUPjNuUCmFASFmv2DF2lpVtlNbr14jiC10ww9 x+8FmDb/EuT+HbA7dBENpv9CAdjlAkPkW6OD5VYx74Xs8+0WeuDu9T6iOzyT3vBr77g2 YfmWGQ2wwobf9JAOcPxh7KXiwsHyukehsA/sGD3gLMgMD5+p7EMWp0FEWE1tLNK2L3nf V3tIq7Yq2j+6iDEd4LvcorjgAG5KKlxbzWZ/z0tC82NkL57yJb6J/CGVYXW1s3ywk3YK uu6w== X-Gm-Message-State: AHYfb5jkdBOO6+a44A0DpDKkJk1pdzCCXl9pGjTQqcAwxsI4CCUh02Lb iGEHer2ohC8gG/ib X-Received: by 10.223.148.101 with SMTP id 92mr2259847wrq.182.1504162007481; Wed, 30 Aug 2017 23:46:47 -0700 (PDT) Received: from localhost.localdomain ([185.14.8.94]) by smtp.gmail.com with ESMTPSA id s15sm6497667wrg.84.2017.08.30.23.46.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 30 Aug 2017 23:46:46 -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 V2 2/3] block, bfq: remove direct switch to an entity in higher class Date: Thu, 31 Aug 2017 08:46:30 +0200 Message-Id: <20170831064631.2223-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170831064631.2223-1-paolo.valente@linaro.org> References: <20170831064631.2223-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: Oleksandr 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)