Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp858279imm; Fri, 14 Sep 2018 07:24:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJ7jDd62tLOHVwvdqDuGQX8tkw02mmIPZgFbuqmvx55wVOhfkhgzl6x+dC+gpHOTTOJ1EY X-Received: by 2002:a62:6948:: with SMTP id e69-v6mr12874770pfc.166.1536935041584; Fri, 14 Sep 2018 07:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536935041; cv=none; d=google.com; s=arc-20160816; b=gSjPQWZuXIATeDy0FZeQqBU9squmWVGi/X52fxUTJYD6YEV3yx9osw7+JZ44v0WHks L6S1xg/o2jOgf1pGAjfsAn0pSihUA/QQCYS8aygOdDKQmxRy5m0AftAs7UoZT+UX+sTr QMZv4sebxs1ARUNPiqVF2jiry98rdX42Q1mq5GsLZ25krho0yOVMGqfJ7hs2bbQx0D+V 9Fca1HKgB6557znjlh95Jri/qoj2h41jBuWUkdDIx/raClCOmpbwBT1jX47T5RHuLJWv 6pBAXEcSxNE0FZ1/3efE7ho5/g18uoA/wtW6MnnkaNmQbdD5MIRArls407X5S8vlMwo9 0Hag== 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 3-v6si6831570plx.173.2018.09.14.07.23.40; Fri, 14 Sep 2018 07:24:01 -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 S1728221AbeINTiE (ORCPT + 99 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(-) 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); -- 2.16.1