From patchwork Fri Sep 14 14:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 146700 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp772819ljw; Fri, 14 Sep 2018 07:23:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaW8Qkx8JBPqWeash1v/ShKfKMyoUqWGYmWMPJt+xrolZ+ySdProGN+5C8Nye6yLTEm0qU5 X-Received: by 2002:a63:5261:: with SMTP id s33-v6mr12123081pgl.313.1536935003967; Fri, 14 Sep 2018 07:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536935003; cv=none; d=google.com; s=arc-20160816; b=GBcQVDr2d5ojiKOQc/7LWzB3lnf5ZzMH5VGdGzHDv24gqAMm85majXS9vYXZUWjIzL dn45GzQG3M5zNxDiBb5RZVw3eiNt9Fm9pm/DRUAc+FsZrpSyp2QDgyF5RENf6iMSNoq2 Pa1S2je0g/M74GhuL0+0pXuXxeTP6RTEkBQfdIEuKcQvdbmexkfdJhNsh2yMFkv5uMUt lJQWuL5iKKM0jahVe1hx82+NwjXKpkiHVRGMJESio2OVowwE4304ArW27WyKOuce64nA y9OksaIgkJ90HZ5738Lx9Jybk9GcqgwXQ1ppQTL1vNuhBFvAvrkkjs9z1BKAI8tnpo7I ltHg== 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; bh=rd8R49tSHe6GNNdxrka86f7ThsGMCBdbsdSM4u5ch9U=; b=AOSM4QM4OlFZUjV9CJWFX74B+Xs+Qh09Gysi3fApWAZY5fe+3RRMnhdo0LEfVPzbGN fDz44kjtkg1MiDS/2g1uld5WYyK8oVrSUrlFXCFEywDemTlTsAUttlE9qNFFOR+DI0Iy k2v7U0PsZmnKXgvbh38z1VGs72B2NZZMKo65qG7RhtLESnUKWF+7E6EJMN3FqGoAQ540 xLYpDzU38+PYfsnCda7Q57I0DPJqrRxzuRVxxEABZ0hj5uYQw+v6cCwRdC1IeindOqlU sEJr9IEisp7aUU5NnibtPUNvjx1qbVrTq4RLiNmtFDROfOSg7ZWgKFQaFsWbWZ8iDORA 4a5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTmY+DOv; 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 b66-v6si7452161pga.60.2018.09.14.07.23.23; Fri, 14 Sep 2018 07:23:23 -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=BTmY+DOv; 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 S1728230AbeINTiE (ORCPT + 32 others); Fri, 14 Sep 2018 15:38:04 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44538 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728199AbeINTiE (ORCPT ); Fri, 14 Sep 2018 15:38:04 -0400 Received: by mail-wr1-f67.google.com with SMTP id v16-v6so10804355wro.11 for ; Fri, 14 Sep 2018 07:23:20 -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=rd8R49tSHe6GNNdxrka86f7ThsGMCBdbsdSM4u5ch9U=; b=BTmY+DOv8DiEIzGEBJX4RYWfTk/ZOXAwxG1eXFr6KPaJviJ3QBqi3DStYle0FMgmrL r7Ng47lpJf0ENMgzgGhvvVGCn3wy5zudPNNvoFs9PCymWb340uzsaMV6UN1y2JIakczL T7mbwvShfpS27whef0OAcbAhlzy+NF4PCSlJ0= 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=rd8R49tSHe6GNNdxrka86f7ThsGMCBdbsdSM4u5ch9U=; b=ZrmKh1E6Np9Y2EdXtUXc3Tnt6g3P5v3BtUbme/rANsoUtT205b0VCYtoiE5RWVugUt MTucwTShw/fslFfY8MXdDerOqOglS6Q2TlPJkOpcblAIEtdMmJqCWnCS+y5s4AM/ZOOn KcIUCD9JUvRelt+qVWZXB17SWgU29rRjfvoWwOSMVpwvF3vFFt1IEx+qX8FDPJzh4gib 23Qu+N7EDtrrSwv7nTXwFwgYRAR5yjCVBYqycoAzniTWre08uEGMXCqnAWX9TQ8KrP0T c15l0qWkCTYuLbpS+T2emV8q1E5cUbQKnKLJde2Sy4OkjyczmaObUL6DU0QJXKW0zoPb NGvg== X-Gm-Message-State: APzg51BaDb7Uu5rrvr3WFywUhsK+qrkDRVQSoWsAcgY6UvHO4ITvtJom 2G3mjYLoY9GP7usKP6M8jjeZow== X-Received: by 2002:a5d:448d:: with SMTP id j13-v6mr10052504wrq.236.1536934999666; Fri, 14 Sep 2018 07:23:19 -0700 (PDT) Received: from wifi-122_dhcprange-84.wifi.unimo.it (wifi-122_dhcprange-84.wifi.unimo.it. [155.185.122.84]) by smtp.gmail.com with ESMTPSA id k35-v6sm17084888wrc.14.2018.09.14.07.23.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 07:23:18 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 1/3] block, bfq: correctly charge and reset entity service in all cases Date: Fri, 14 Sep 2018 16:23:07 +0200 Message-Id: <20180914142309.6789-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180914142309.6789-1-paolo.valente@linaro.org> References: <20180914142309.6789-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BFQ schedules entities (which represent either per-process queues or groups of queues) as a function of their timestamps. In particular, as a function of their (virtual) finish times. The finish time of an entity is computed as a function of the budget assigned to the entity, assuming, tentatively, that the entity, once in service, will receive an amount of service equal to its budget. Then, when the entity is expired because it finishes to be served, this finish time is updated as a function of the actual service received by the entity. This allows the entity to be correctly charged with only the service received, and then to be correctly re-scheduled. Yet an entity may receive service also while not being the entity in service (in the scheduling environment of its parent entity), for several reasons. If the entity remains with no backlog while receiving this 'unofficial' service, then it is expired. Also on such an expiration, the finish time of the entity should be updated to account for only the service actually received by the entity. Unfortunately, such an update is not performed for an entity expiring without being the entity in service. In a similar vein, the service counter of the entity in service is reset when the entity is expired, to be ready to be used for next service cycle. This reset too should be performed also in case an entity is expired because it remains empty after receiving service while not being the entity in service. But in this case the reset is not performed. This commit performs the above update of the finish time and reset of the service received, also for an entity expiring while not being the entity in service. Signed-off-by: Paolo Valente --- block/bfq-wf2q.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.16.1 diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index ae52bff43ce4..ff7c2d470bb8 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1181,10 +1181,17 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) st = bfq_entity_service_tree(entity); is_in_service = entity == sd->in_service_entity; - if (is_in_service) { - bfq_calc_finish(entity, entity->service); + bfq_calc_finish(entity, entity->service); + + if (is_in_service) sd->in_service_entity = NULL; - } + else + /* + * Non in-service entity: nobody will take care of + * resetting its service counter on expiration. Do it + * now. + */ + entity->service = 0; if (entity->tree == &st->active) bfq_active_extract(st, entity);