Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3929170pxj; Mon, 21 Jun 2021 09:34:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUY89UFoBqzgUdFpg6GZ5qAD3OLovanG0yDHJ6xYOZdyFk+B1RxxYnVmpPMwbk5+xn7wfw X-Received: by 2002:a05:6638:24d0:: with SMTP id y16mr18406275jat.41.1624293289061; Mon, 21 Jun 2021 09:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293289; cv=none; d=google.com; s=arc-20160816; b=0dwWbM/BlkCtNvcklLxNJaIBuDxg7INyUhjTFm45Kda+JfMl3GsSI+tuP/RW2LFkTK rE+W6GC4uy6c/rIMZqeWnF2KNOOVW3ovmcxRZEmd91vEu9S/Ma+bsogdx3uxriL6EOzA G8QzGs08IHAI+63O9OXyjopmTcAvoXMhHQlz5ZrwfSADnBRn7knZd97DBEGB0M/+zZHt PNIybTeJ3U9r9JoCs8pZ2EU0gOgRzXyr/myJEgpt/rLc1UkwdDS18gNiOxlQMawbBbY5 9GOYP1AzROqFcxFsOXUTzt7Up51SfkRVr8DQCcUnNrj0w3LL3nncw/2WJu2RiJ2DxV7v YIDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vGKpusJXHqCa3eSabogw/idMAymOhnh6RnElxp/telc=; b=W6q/wGv8pExupwZ+SQrvgIJ7GL19wkphKEPEVQXekIr+4TjsqA66Kf3jlzTGVkkYE+ y26Njmv9tff6/22BHokvMzA0GTxqB6v2wg4rVsPbWXC1tD5xKWxFKL0WJawNJ+/CRNeW vRx7d8tbHUtSkOAaR19lXSEnyWlK3cAvut32xQUa2TSuiUVyG3rZankeUMWepqlvhLzz tve34jj8Oi+hqO7FJJ04Z4gljKlwHaiF6YpzoNgx9UQI4VguYqksYv86UAoNcecCa4C1 CQB95csBXC7Dsh6bZpF29DWdZj0hPgF9/PIy0ie+W1tUpzmnmRS5N9y1Ykuu8x0YO8iE Rtiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TIY03PMZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si12676816ilq.68.2021.06.21.09.34.32; Mon, 21 Jun 2021 09:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TIY03PMZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231148AbhFUQgB (ORCPT + 99 others); Mon, 21 Jun 2021 12:36:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:54924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbhFUQcE (ORCPT ); Mon, 21 Jun 2021 12:32:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EAB2C61408; Mon, 21 Jun 2021 16:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292751; bh=xBVlUaKeBfgoVvMvOGT6OdGSFsRM915ESXJTPKiib0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TIY03PMZfoNW3pUwE3lDvZJlKGdYDeHrWR3c7s1Jav0UdmZKfq954+p4XUYBLXg2h 3HZ6djqOxwXNcnhispRibdmnyzaDuju0waeVmvs7QlKuVZTUyxNQ174+pcybeBFjje ZHvU/ln3/vd8dNNHZ8g8mD+GM4HqxVCrf5S+fof8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Guittot , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.10 083/146] sched/pelt: Ensure that *_sum is always synced with *_avg Date: Mon, 21 Jun 2021 18:15:13 +0200 Message-Id: <20210621154916.297306183@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot [ Upstream commit fcf6631f3736985ec89bdd76392d3c7bfb60119f ] Rounding in PELT calculation happening when entities are attached/detached of a cfs_rq can result into situations where util/runnable_avg is not null but util/runnable_sum is. This is normally not possible so we need to ensure that util/runnable_sum stays synced with util/runnable_avg. detach_entity_load_avg() is the last place where we don't sync util/runnable_sum with util/runnbale_avg when moving some sched_entities Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20210601085832.12626-1-vincent.guittot@linaro.org Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ff8a172a69ca..d6e1c90de570 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3767,11 +3767,17 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s */ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { + /* + * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. + * See ___update_load_avg() for details. + */ + u32 divider = get_pelt_divider(&cfs_rq->avg); + dequeue_load_avg(cfs_rq, se); sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); - sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); - sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); + cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); -- 2.30.2