From patchwork Wed Oct 31 23:04:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 149921 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp133795ljp; Wed, 31 Oct 2018 16:49:56 -0700 (PDT) X-Google-Smtp-Source: AJdET5dUyidoFsYZIN75pxrlXVYyoiAgYwL0DdZg40+CeXpwwabPxIkWxaG/THUWmhvF+ULmT8uG X-Received: by 2002:a62:1e83:: with SMTP id e125-v6mr5294386pfe.231.1541029795956; Wed, 31 Oct 2018 16:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029795; cv=none; d=google.com; s=arc-20160816; b=IyYOp6qo52orOqZWm3fZ9J00oYPXQLYH7O+wM63xTyqFbYjadsq2E1m+Dru0E2HRNo 6+6KH5vM4R0Vn5qG+m0CD++UHjzD3BbiFJsqGABzkUh6FbYbEqiF6VyHWu21bE0RQnSg 8+qIMH2OnTUDu6zGr7PAKfWMql0hsAD/kGKpDA+QSz0iDQDJHy0+EuU8P1WPtx27N3VR eZSAQPE5kyBGPW/XYhDwGuYvYGBrn/R1Mgvi1UiA6yOW5qGQ+QtjZKOHNXl3OSMpfbDC NbvJgoWfcjZXEIh2Y7dsjWUaPt/rd0dX14bXwEqjkuBi4KWxuFfq3qjY3NNu+1ioAQRJ Empg== 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=+UN9WAlyAEd1rHaVjk5i/P+7oFV9Y7nahZa5UfGhzjk=; b=Z78WlqFXvRFIuOs8HyTPqieZVf0PR5dsaZ2FgRb/EESrxxIx4RMvG/EH9IcvkasR97 /8FiXOapx+hw7P6hE6NB+CYgQdENIoau2o2jry54YaRKFtKpmdAS+8P5kP9LgtroW6hn LeMdNpbbcxr90WUvIFs0ipk6K+vPBHm723FU8PDO9f4RWK75RZxUWCwq8KiQ9efat32L B9qqdua/87UO1BHj3/9H9aFdpWMhStazLiWgb0zDisioXJnfq8BmawKD0Q30kVQYJjHW 9/1UBgW4WT1jHFNZPEDG5GNIivbi1QWVngknM+P0oFcLGJvK5IC05yrP7AYWF1jMkh2C Vu3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DNlNTCbV; 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 i25-v6si28306445pgi.426.2018.10.31.16.49.55; Wed, 31 Oct 2018 16:49:55 -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=DNlNTCbV; 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 S1728521AbeKAIuQ (ORCPT + 32 others); Thu, 1 Nov 2018 04:50:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728302AbeKAIGp (ORCPT ); Thu, 1 Nov 2018 04:06:45 -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 5492720847; Wed, 31 Oct 2018 23:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027194; bh=d/cCpngJZP2Z64V1gm6LunSqQ1BiPpcrNH28VDpTI8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNlNTCbVeSmqNvVrOKWPSkGp+DeTA3mw05MVwGQJgnNFsxOaBkDGucJV009l2FKnb iBGwxENdgPuKX8+stYa8Q/kV+x+NpoPGuWbovnOFM9TStMC2JERafBZiLFQlGmHTer CTjCiwBc4R/rtIHTGzWIFAcOmoSU3dj8wpY1zT8o= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.19 058/146] block, bfq: correctly charge and reset entity service in all cases Date: Wed, 31 Oct 2018 19:04:13 -0400 Message-Id: <20181031230541.28822-58-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-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 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);