From patchwork Wed Oct 31 23:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149903 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp101033ljp; Wed, 31 Oct 2018 16:10:19 -0700 (PDT) X-Google-Smtp-Source: AJdET5dw3fexDS8aiLvCfazGHPwX0qrzWpkLnZTYbhHYRkC9v9RxgVODCB9Mdew+plkY7ThbrUBv X-Received: by 2002:a63:5102:: with SMTP id f2-v6mr4870570pgb.31.1541027419266; Wed, 31 Oct 2018 16:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541027419; cv=none; d=google.com; s=arc-20160816; b=pYYlPVcHCxDMnaqOuliGlrutbur7nt1JMa8D+CWgEMhwWWBSOXQAXtFoKFTb36BaqQ pAkiVTVyFFYPmKwediAV9XOzhZnQs0fBHeQ5OX7Uz3KMN8F6+yz1X0PIilI22a76F0PK Sq6oi6weoZJnRjwlZX0TrJ7MIRmKk2vrekAbJaaGSCbicFHC86kya65oxd3Wcazn3PA3 4q8s7S2sE7rCgY8jt+axvO0AvDuaAAcH6iyiHJHsOBjG7E0GZKNmEeFp1HpTpR7MAyck jpx3E6uIRPoloKKzYSmepNGIS8+VISExs64UxStBgpayCj7AQmYXp/pHugJ8w6N7uFVX 9X/Q== 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=eWpjtI/DnnAc3TU255pgFPllH7PpXNcJQxzN92DAXts=; b=rBtBf0e2TPd6JjBv6e/q4PYXKkjMimtNOO9RrLVMJPhvDlQu1XhDoriCso2q1KhyKP xsJIHgm+xeSTRyu6QtUTIT9+qdqtrdDgPX+LCG/z9uJFIqW5GWQ7XBmWoZQht/R6tXug KHxAPK02p+wFMI9Wrjd5vV5DDLB3+8begQ4WHn5E+bwACpcF2m7uzojyLIWwOWOJyWHF 7wCRH1edlsPyBnaJToj76AFjnq8eojzx6S7qluLnLaEO/GxbNOUUSDaeWntgkx2xEIuq QIHutcC99YCcuO15vpdCNXApjLL+47uYVWv9KQnJ+HACSWb1aZwm+GQQ/ZPUeZMwiJ96 EFOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+cm+BRS; 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 z14-v6si25277901pge.225.2018.10.31.16.10.18; Wed, 31 Oct 2018 16:10:19 -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=l+cm+BRS; 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 S1731041AbeKAIK1 (ORCPT + 32 others); Thu, 1 Nov 2018 04:10:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:32972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731001AbeKAIK1 (ORCPT ); Thu, 1 Nov 2018 04:10:27 -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 7FEC92084A; Wed, 31 Oct 2018 23:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027415; bh=2FMjQxYq/l7GYTY6uzZ29YFm2uYqiuIcHfDB+fyomzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+cm+BRSCAxzvidk8g8N/bZF/s2jKX6hwiEFWhEhi4A8rwhaBKi6efDJyD1ULPXGL efuhNs4bn7fWJ/AnvtlJAeVRDCsOEnB+Xp3REcHzPxcRRoalZwW6PhyFIdfovbMPp+ +8fXzZMjINRavQSm0F+F2phNKzpDfReryfQHatRY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.14 29/73] block, bfq: correctly charge and reset entity service in all cases Date: Wed, 31 Oct 2018 19:09:04 -0400 Message-Id: <20181031230948.29203-29-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230948.29203-1-sashal@kernel.org> References: <20181031230948.29203-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 414ba686a847..c1727604ad14 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1172,10 +1172,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);