Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3940511pxj; Mon, 21 Jun 2021 09:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd9fBMwBndFfajeWoCQwbn55ZO9N5GKNyVghWKsrhI4L08oy5SjB4iIVnGzf7YV5eNI5FL X-Received: by 2002:a17:907:728a:: with SMTP id dt10mr3732812ejc.280.1624294179628; Mon, 21 Jun 2021 09:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294179; cv=none; d=google.com; s=arc-20160816; b=ebv/o7XDNPnyTjBX+cw21/Ecu1Jr/5CKYdnHM9BXpmFSCDrx/X9k0nuYt+eW5vjXVc +nYLy40cwUB+hlVjmIWuJnIWMf8+NCTxvyzyElBhXCQ6HThjcAgMwM6vZsoMPAnc2XId p9nU1I+9QOcR8v3kiXBSUYwAM7FilHXHbECZLut1wt0LB9Jg8NJ+3rPPao9Gfx+0Roig nrUfThdCkoyY7UsJGRCOoQ7hEoWsvtp5JLTco08Ybmt+bOCCnxHSGfnwpMolcF6onvYT s6LwQLu3f8wC0OIpy+DzYccKTeQH7BSikYW8Iq1TXUieiUOf9LM2yRz/f0fFu0G+PxVP MQWw== 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=abKGikwWVCGlngACmerGAAz1PdSThVsDvNxNogpYYdI=; b=bBBnvBpy+Rg4mbeOIm2Zfpk5zeBqd40PQAydhCII9TGz/IVi74OHqGWk9L7Eid/oP6 ZH/ge5yMJznvtG6wDOwYg7ogzavHCkdTDNn/Hr/wyMHvZi0rx2ExWw0KJnWye7naGpM7 US90vAxBLy5G66V7FOR+fRNAIrTHJXQIH0I6Qzvsm/f788netxP8IYeuB+Sb2SkhajoV 2ujyl1/KPWKRm+KCUvFriAgrFO3lHaIR+cqirtJxwkD/sQhrSty9FFvnurpNqbhYnY/a Ys4nu4ZIDfakRNUGNyJnK+YH3QcvQeVpVmxATxUd+c9iMpvqFNdzPu9fSaK7H/2YWWWb sKcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xx5I5ghL; 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 jx4si10718548ejc.513.2021.06.21.09.49.17; Mon, 21 Jun 2021 09:49:39 -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=xx5I5ghL; 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 S231131AbhFUQuP (ORCPT + 99 others); Mon, 21 Jun 2021 12:50:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:37672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234027AbhFUQqA (ORCPT ); Mon, 21 Jun 2021 12:46:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E8E2613B2; Mon, 21 Jun 2021 16:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293189; bh=6FbYkhJMn2N0WyVHtkjTZp2t6XKY0Cc1Iu8MvkMCgdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xx5I5ghLDnzSTHcI6wAi8TJymUF4mdfZP4/2vlqrB3jm/CIBMu+ytKCz5UXLSMGLB OJvla+GwaQXH/wGuhvth5E5PfHi5YFU28VUQzz+SqPix378qEt+ikGtRmi/eT4tBaW p3XdHYpz7Semkxh25YQU3kz4FS9R/5dHoA+uNoXk= 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.12 098/178] sched/pelt: Ensure that *_sum is always synced with *_avg Date: Mon, 21 Jun 2021 18:15:12 +0200 Message-Id: <20210621154926.100007082@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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 487312a5ceab..47fcc3fe9dc5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3760,11 +3760,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