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: 111357 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp2072458qge; Wed, 30 Aug 2017 23:11:03 -0700 (PDT) X-Received: by 10.84.194.131 with SMTP id h3mr1401426pld.196.1504159863333; Wed, 30 Aug 2017 23:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504159863; cv=none; d=google.com; s=arc-20160816; b=ZX/CfpuF6QEEctLUHbZH9BGEQw8+8FZYibL84wURDUkS7lVcFfbiSBmMkaKvoDxzwT VWT98pw0mxhDjA/c1qsSCvBtxYiZRnsXuYt5J7ozUfk0byYWW3FCorlJTtV6UCkbxOrN r4G4K89lquEZADCU2VDBS4qlp5EjJDDwprX0hE985GRib1A2kdrcBxVcq/ClA+iejESD Z15Vo0sG0F8XQAZssiPVgHKj1nr5Glm9BEosL1cp4my1HEfyfhinN/XCVkCT/Iz1MMxW dg19AVqJFUhuOvQUjkkkN4p3lXO51WUkcW2mmNbCZPFXDBvEwiQqWDF3EIN+5qrGQ5UI ZWpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Q+NJI0nO1+RlOxxT55ldhSl+HqyGd2iiyCvFJqV6zZc=; b=Vx4rlFwKtR18utzXfA/9hEtu2LqPXm0GwmzFfS6Pau58hWsRraqO896YV9sKn7HIuR FJEUJbnz6oIrEdX06Q0rsB0jVkvbJFItRU136uQIFa7MigDSzWouNGvjAxi1cRno86XL siApUWHxGrduIojWcHUM4VZOPr17dVK1FBk9Bm0MKuLnM0ISVscDRDkPGGlu22EQAJYl K7DpnAkaxa2uiFPIBc99DIkTEF/Y8Bel8+vjCGpESCEuawXWn2SkHuuJ9s8ZwFhXwON5 hs9rdx8zxnOnuSZKlZCrySqh76eEujrCeH3CyFVOvDH3mK2FpLIbwD0NK5vMrTZAYo33 vNnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNfQ/vbY; 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 g12si6167747pln.291.2017.08.30.23.11.02; Wed, 30 Aug 2017 23:11:03 -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=cNfQ/vbY; 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 S1751483AbdHaGK7 (ORCPT + 26 others); Thu, 31 Aug 2017 02:10:59 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35480 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751397AbdHaGKx (ORCPT ); Thu, 31 Aug 2017 02:10:53 -0400 Received: by mail-wm0-f51.google.com with SMTP id a80so21720202wma.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=ssbmCW/Cvt2bkM4RKMaLG4dHZdmRsBhaB4S4RdF/tcsTW/M2oH29Ock22w+ZEuOFaf 2HJOG0m0iE5OVRafbDa9la/ZTJAKF1CEoNt8bHAzka1j77sclhAps4bw6c7bQocnK226 GFk5ARP/JbCDugGKX+mLP16V1Xet2v68g5TRvsxa8iro41V4iGnul59Opv0z6ZpYLgYu ZdLtZUj2aELTTBO5hDPmj+737Ca0Ae54w98QPDA9uxud3js0S2jmSEHniliDK+D1+jt0 ksyp2zY59XLLRX/2IPHGDxBblXHwzASY3ACOcmPY0rIOWZHe556+1pCLA6nSDfI+NuAx S8Ew== X-Gm-Message-State: AHYfb5i3f/DJHQCEHrtqZda/4JNlbBZAKAvaIDqfDtlBJyeFXW4EHg0t IL4Fh5Ix6NlPRxiOzj1nnw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.10.0 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)