Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3484341imu; Sun, 11 Nov 2018 16:09:02 -0800 (PST) X-Google-Smtp-Source: AJdET5fsvW0VmQX7H64D7czAH/aOQkVwxZDO0Of3NKSwUuaq7U5nyahPhz5lQWRFkowpEGwsC50B X-Received: by 2002:a17:902:4165:: with SMTP id e92-v6mr18133439pld.209.1541981342928; Sun, 11 Nov 2018 16:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981342; cv=none; d=google.com; s=arc-20160816; b=QmvCtOWN3e1TgCBVuRDle2zM2tc1lDrtTO4YzCY3dHOTM1cg8SQRUZRGLlTl/3Wr99 5fMys6+I8bE62DjnHlLJOneINuTa+/oHIt/AGDB9pZzxtTod9dCZi4aw+PtjARsIM3uA uKtvoMffEAFW26D1A9PlHTEeuqaFElK9UtpsECPaIDFDsxU37XXdCdnO5GYhDboD6/bB tUiLiXjaGk3XDy/fS1f7QnszyzvXdr/sMqiABd6pdihHT+Y/cV718Z0hT+6LZ/YcUxpc rhnzwS9I33/7kqClHgd1CYb0wXUsc39v7UkJh3IVC3QG1TgGJqquugA24HLH1rKSiQ+z YacA== 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=kzqdVDSGV8K7mDk6nz2KeFyZEDMsHLmeFbg+ZYChsb4=; b=Cgzmh3J7NFkA0qrKZAfE9WfHERPmbIMesrrG4F7ksJZJ5+oBJk8TLL5i898eT8cnKV Utpis2W5WKaQjReTEbfIZx5xZOaV+odFAga1pVYu6QnRxpGNE2Lqa0W9lCG8lT6Fr/Xj +YrIla2DyL+PVSBzJnGPeaeaoMTuoB97sg9puexyVQNhZDZXP1pX1K2BbIhqsXITOHfs t34kzMDvhf05J+qvC/RpoguEQzhg6cn9ldwYAmD0sHAEKHgLFVZXtl3XxcFX/Ofs/diT xZyPYndq1voG9i6CZdhHpIeaQBCEyCzCXdF/EGIekPOlFryNGpyqJiZbjgmqLKAo0UkD qj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O6T4j2IZ; 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 f7-v6si14331157pgh.159.2018.11.11.16.08.47; Sun, 11 Nov 2018 16:09:02 -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=O6T4j2IZ; 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 S1731433AbeKLIRc (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:59904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731346AbeKLIRc (ORCPT ); Mon, 12 Nov 2018 03:17:32 -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 54D5521582; Sun, 11 Nov 2018 22:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975256; bh=LkjJpHgTvDCfd0UDe8qV77EyY+UyJiKrBEBdJEhZ+Sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6T4j2IZN2p6QSe4Zys1hXI82te6I4/y1rN3RYECFVRgX3g0+npxJBar1c/7/6iWm zjDSCpaIAgvXQk3ZiyMP6sSt0X54u8MNtVsiUMPTaX6I7SutwVHDteTpbbWXXudL85 j6gQQYtmcOgRhIJlfkrEBh+pEF0Xdl+V0k/IvdtQ= 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.19 103/361] block, bfq: correctly charge and reset entity service in all cases Date: Sun, 11 Nov 2018 14:17:30 -0800 Message-Id: <20181111221634.096490080@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -1181,10 +1181,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);