From patchwork Wed Oct 31 23:06:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149917 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp123298ljp; Wed, 31 Oct 2018 16:37:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5crScYpXhLs23zINUfes3s3k4jJazIQyBjuxnjkzAZ7KloonUVshP2sL7HFWhk1EIOQrkJV X-Received: by 2002:a62:3384:: with SMTP id z126-v6mr5461043pfz.112.1541029028898; Wed, 31 Oct 2018 16:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029028; cv=none; d=google.com; s=arc-20160816; b=koHx1qm0+1/C3TkaPMHRR/IvouhC/fOTJJfgBaQJuhvSPsABUrdGI4faQ/7eaC2c/Y sganV7+Fc6VZ2lSi1uzysIM6uV2INWCF17nFCr/ZWMfbkSPvBPypqq7Ke1u3d5LjcgRU gDmuidcSYGktAubmugTl57ubH1Hq4Bw0SlrBfwWb2C4MpBbW0jQbRks9Za9uXfrcfqEo /inZ4i4adTIIxmMBlf1PfLWpCXIN/yj6HaAxPse7ng3uk+l2/g1owLeiBzzzvlQiaMy3 UqKRVH42i1JOm1J4pLHVaVZJVv4yPBhmfh6NkXknb53ukmGp2ysg+jPhOCKppz2pPpT0 79gQ== 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=QGIM3sOiqVJ1koZxQUOJYvloVgbVojiep6k8olIQojs=; b=XcEscWVSEGoHVZC3SMcMzr4iuVEHc48dYvsYlvmu2I37zINwRTIMCczVWgq2QWW6PR VCIFR5oDUX6SuysFNLbb4kEwekD2MI5D9Lu/P2pdJ6ZFiNHhlMAeJz2b5sa+k7ztNkBo ge6+Lp6HY1ZL4eDc8voidKpspXehLS7w/4j2vV/TloZjd8KcR3jm/iRe2XIm7/hFA3R3 lnWiI8JL64H1yB2k6kHRFj274SgMZdo+4owmB4eRm7DaOT5zBzeW7Ze+iI7h3qXL9OhI 0K8n5KQqts98+CtgdFKTLgxs4XP/BOPWZZBGXcDeWjsgIx9ucMM4w1CJZbjFQDzOCPi/ Akkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X4iIILmf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c68-v6si30919750pfa.45.2018.10.31.16.37.08; Wed, 31 Oct 2018 16:37:08 -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=@kernel.org header.s=default header.b=X4iIILmf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730053AbeKAIIw (ORCPT + 32 others); Thu, 1 Nov 2018 04:08:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:58216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729855AbeKAIIv (ORCPT ); Thu, 1 Nov 2018 04:08:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A734120847; Wed, 31 Oct 2018 23:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027320; bh=J1w7CfViljGDO58gsaMyV0aNsx6x8XOC1S+PPnA+Mv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4iIILmfF1/1qrjMIIbiMQfbWuoxM2Pk/rRwAnYVNkr9mZLlu1V1qii6ZuJFAQRMl TnoDuSoKKrWmx26RZxxEVX6VX3EoMupyh81FMoEaqxnNNdkP9Iu4rm8HiHE4nzNSws MjnHSAQAYspfG8D0JnN8W1GjXmNaJ+DGvJahfAnc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.18 050/126] block, bfq: correctly charge and reset entity service in all cases Date: Wed, 31 Oct 2018 19:06:38 -0400 Message-Id: <20181031230754.29029-50-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230754.29029-1-sashal@kernel.org> References: <20181031230754.29029-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Valente [ Upstream commit cbeb869a3d1110450186b738199963c5e68c2a71 ] 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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-wf2q.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 4498c43245e2..681498e5d40a 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1178,10 +1178,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);