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: 111363 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp2107424qge; Wed, 30 Aug 2017 23:47:29 -0700 (PDT) X-Received: by 10.98.200.218 with SMTP id i87mr1263516pfk.85.1504162049091; Wed, 30 Aug 2017 23:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504162049; cv=none; d=google.com; s=arc-20160816; b=Q657wi3nGgHAhIPgmNUUiCGWLpGJBUPCN4JoZdatYeTBcBgaof6j+AMyF4cGgT1HVf n33TraRY0x8XzSNJdU717cErM/TH4qf7p+4nDioFuBPwZllPBQf6zJ0jGecOdt3SeBzx pZTSYQt7Xnj+PcEjmMxNjhjLd4TOBsYX+UhMpuSOqmmfKcrGjHXoYC3Ju8Qctf1uLYYc XY1rp1L94GR05po3WY0GhHXeKvlUs7x3+HyDNVsgdYl6XsGpPaZL9owpTUL7AEB5enjR k2J5G0Yj9Vg2MyrL1G88hhnusroL//qXvI2wn8bKKno6sjrF3pnNoRD6syVOjwIVbcZ4 SRow== 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=YjEtdvjfb9xLDIrEUJbj7IcmuE/lWWeOhnohyU29UQs=; b=S26OWKLYsDThtU/s7jS6gNTRFNs2AP60HMnbSsUUGX0EDcpJH0OKfxlIoOluHcAXH0 1qh1J8wgUqDY6hl2fLk2F4qunGxedSzRKm/xh66hhNnTDVOcCMChOief9KqezhbhLHrc R+GZKY7xQ9oFOk8CQGzS143VvAVs6FTlSEE1wolvYSg2HHLSFQJQC7v4J1yHwRWrmnsh s6NImukP9Mgyo8KI0zllQm70MdG0qqJCq9aTaVZ5OaqXoPfzUcCC7h/32CmNJL8mcMgP 26zahGJ2EznyqAk/aaHNGns95Loq6hOGJdXBL+8mdscnf235mTGifceTnC2nHeHnGMWn yKEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YrMmmocJ; 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 d21si3588136pgn.394.2017.08.30.23.47.28; Wed, 30 Aug 2017 23:47:29 -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=YrMmmocJ; 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 S1751431AbdHaGrY (ORCPT + 26 others); Thu, 31 Aug 2017 02:47:24 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:33733 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751205AbdHaGqs (ORCPT ); Thu, 31 Aug 2017 02:46:48 -0400 Received: by mail-wr0-f170.google.com with SMTP id k94so23705598wrc.0 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=D8sAHHDZNKQ1SkxD3faV7e+oQ+R9kCOkdxlAR+Rzm8OwyvndlKGlpHFIFjVeZEZNRS LfPHPDgeTb65ASntN+ZbYbA0/uOpFEv0xZKDQr6Euw30X7OWbGLX9ePX8B7hg5NJIb3+ ipXP9eYpboGqWeZf90f7BuXV9tSy2o6c1itfF2w3Kz415X+CptMY38MdOWS3pS/wfwLx lmzzHMJUXx6pXZgaf+0IKhZ0VSUCooxKG7s0oJwTKyKIYvaM5MpGC9lVhnKXIHy2zlZu DHvyIS7VLQYOFmm5+sMBrNEOtEjr+525qeQkACJCJs4NahwzOtNaQ4dCBcrQ3wvkfDKO q4YQ== X-Gm-Message-State: AHYfb5hXppngXNxNgfVbUjcaCglWlMPN6P0VTDTpHx0PnbUo31mpDuXp b2MQIoXDMzenHX94 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-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: Oleksandr 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)