Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3434961imu; Sun, 11 Nov 2018 15:02:44 -0800 (PST) X-Google-Smtp-Source: AJdET5e7kgjgMMHuxwCPRoqmegpY9CSRa7eQW+F0dspsOaM1PZAq3C10C8Ab8dFfR780F/iFQOkH X-Received: by 2002:a17:902:3181:: with SMTP id x1-v6mr17620456plb.240.1541977364716; Sun, 11 Nov 2018 15:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977364; cv=none; d=google.com; s=arc-20160816; b=NKR1+zP4S/j7TpaVuQ0tBBHKJDs4VB0Il4SQ7JChvd2warjvlXCI7GPKvrsCQtTWUm 3SFWnWFSe2rO3Vz0AhOprN8q2NsmUGeDKr6hZuEwTQncbMyR5OBfjVAmTcJG1ECZzn85 8HEt05Zjk+w/7UqtUDkQ295EsfmibVReNHTbi9hK38XJV2uf39BWb0ICVWt8dKzCtK3/ v+jJLTyxQ3yqX4rSpDezTYrMuRx3wo89+1BPz6pJ6ZHWMptjXuIjy9lu8c0DgCwQTT86 fPKlaLVw3KxdY1vGGAEYv/faOZUCE2fsl34JppBT1UfbGUdd5xG65Hvkyr6VELHykwTO 3NFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=baKpjWC/SykCckmocOlOpCyYYMIQ7CNitq95rZWo0XI=; b=XAwJhOCsYABpUBOfoNNjJLDlz4IEWsIJwQoz+sWQBMzh+Mknl49PcNXS3JLUHRD90/ Tc96hujgdd8CwcKFe1Mk4LtXEF1Il/JJlQwy189Rc/KWxw9eD+hjKn9dbcwsHQMiXctz HD0i2malgNagMkpAfMVa2eRgIt33NK81t45n+rlcEVL8Q9W7mURtjs/HwhQT2ugK2EAW N6rO8IbLgTUgLvonUge7/ZL5g95iy45zGRH/ZAK0uJjtkGK6fGknM/Q3iXrzUo0mLzeE 07IkGX/W/5D3PBxBkD/8uAfHJiBWmITlUwdyZAGl4p8sHXYXJ7+zELfC9eR5mZH2GM/C I9PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zJ0LHqRT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p189-v6si15887879pfg.235.2018.11.11.15.02.29; Sun, 11 Nov 2018 15:02:44 -0800 (PST) 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=zJ0LHqRT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390645AbeKLIW3 (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:51200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390595AbeKLIW2 (ORCPT ); Mon, 12 Nov 2018 03:22:28 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04D9922419; Sun, 11 Nov 2018 22:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975551; bh=JVPw5LTutQpE5g9YE1u+oFsOuK0mD1Kyz3c0OjIIbGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zJ0LHqRTM0nl0VD6nRZWPnbEmYUfWVK+rJu1sYqLKEREcxmQgX+HIAtshcXxHe2cf BwgsW3nWXSmjmAKIJgKbJLWl419aa1Yz59nGCWXB/EtGTdIPBEMIN8yZIl8o21MMAK bLMMDD8x4CiZ4K9LPGiIkQTZxU8EDflBMHt+oN3U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Valente , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 065/222] block, bfq: correctly charge and reset entity service in all cases Date: Sun, 11 Nov 2018 14:22:42 -0800 Message-Id: <20181111221653.772759356@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- block/bfq-wf2q.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1172,10 +1172,17 @@ bool __bfq_deactivate_entity(struct bfq_ 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);