From patchwork Mon Jun 21 16:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 464559 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4376544ejk; Mon, 21 Jun 2021 09:45:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKRIERjYQlt+3H2eJJL0QWyBDbpBnWLHA0iNnmlmJwalkGn1VvApKvhmdxWcOywyXOFVDh X-Received: by 2002:a05:6402:4316:: with SMTP id m22mr22895385edc.316.1624293952077; Mon, 21 Jun 2021 09:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293952; cv=none; d=google.com; s=arc-20160816; b=Em2uFtXEIZrikpPecRHm4/nuOkMdZpLiM3Cljb5nxUozZbE+g9yPN5BwVE/ZGP0UFx R9f8XXmlnp1JdVSfVaJsCn+G2+HNurAuA+jCAjtR4gerbHL9rYZMCmo6S/roKC6lYPFk 86a3QPcr17JJBBe7gzfG+Qfc8qZRD5HBNAC3aeDEyMK/nIg7ZSDp40s6OuKUW7BB2D+v WecTr/Qcbm4YWjV3qY+bEuyBloQ0H2JEeTcoYLSuTbxFHiAAJvF15+cFWElmQ/O0O/8E qiuRL6890f6G6yV6AOmADykb99aI/lS09lmfU0o4W/wS+qgkDcFJ/VGjFj9aAGqv4CNO wQtw== 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=ai2xYyF6zFtSOuZ4lVQraahUspCkr+21n1S+uMIIP/Bsz/+PlUZ2sbDJ3/h42Og1Xk 4C6P2doH8dYXCb+K9p2fc8F++1KbLRGZh3Q5Hr9vqq/4UAC/g8bEJ1DlA3GYyLtCKEBg koWImMyNiO6h8G7ixABkxIVZbk4aPmPfa38Wibxu1jKXT3nqbJL+9rMbnMLwnicVCmcR K/8oS/vMTfJuMzmq1DoO506IjqEmdwcjrDfSGfxUUVPHUEomQ59A/QbbimSI4gSwE5da gWZE0kAWFAO4QF+RKSgUzzoFTmNgw62as+vlcYYmFJPncpVfhqyrvWCyZgtd0h8jZFRi rS1Q== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 ml23si6530391ejb.254.2021.06.21.09.45.51; Mon, 21 Jun 2021 09:45:52 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S232283AbhFUQsC (ORCPT + 12 others); Mon, 21 Jun 2021 12:48:02 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.30.2 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);