Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2534788pxj; Mon, 10 May 2021 05:23:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlm2E36PStl9hFHfYuSeU9NCKQMQtRwvhsVoOH0RFibvf1rNXN88jwYPyXvhHJ8VVTkW8u X-Received: by 2002:a6b:d606:: with SMTP id w6mr17859423ioa.37.1620649396183; Mon, 10 May 2021 05:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620649396; cv=none; d=google.com; s=arc-20160816; b=E5cxLK+pyUcVs/k6+AmUZXcTVWG5z55jpoFLF1ZwXKVOengdjqnNM6okWQ5zFmrItP hEpxRDR6zmc7TPW3Kxop7ON1jQrtQa6/dKh54qw0ch2SnBhjjbAqc/jZICUCdA/OoJoz nlZLvTB60UljeDZQbN/li9t9I+51ycDYLKLT7/Dtg9Hr+OFOvL0HwMIe06doGC5aDBYS sWDcQHF6D7o5iENYqNHOwfymsH8NAzaxqgZl1+Jr5rCxSf/b9DG0Co6KaKF11p7WSFNA zx27pY5W91IJL4qo7dkxTnviJugee/CvGTOnRQJEzUydD4LwN6Aht8iFPrwdzd4hYLiS 4qNA== 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=4QU+U00CIHDs7M7k4YZP0qJgzNfIiMLnFL99mkGQyy8=; b=mbwarUgV9dA5L9xMpe96EcH+3QJcRrtWxqzu2mdl238msXFKEbr8B8Oqt7AgG/KhVr 3Mehrw5pLuoX4NjBiApmxoMb6TUMjN5zNAG28ILTA3FVYTISrKxJEfJgBWaqMimRlAe6 eIeDfS7kDY1JmcDO+l8NAV7Z6WVGZnoOt7ySBiUUh4vyX7eAHuEXZHl7zcHCViBtH81K v5MLkGoEQPc842v83G3P+BLjngH2rE0HEYIX0qx5gbysR3c0tA7C7Vf77POVNWOTfgcx TkAgf+a3IgOaLfkoxgPMv9rPgA/0/h1RyvcfJLKU0xqQd0EwSjYvVO3M0LjY8FJY9X5Q VCFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aKQmF6Ox; 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 n6si16761714jal.41.2021.05.10.05.23.02; Mon, 10 May 2021 05:23:16 -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=aKQmF6Ox; 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 S238704AbhEJMRr (ORCPT + 99 others); Mon, 10 May 2021 08:17:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:45870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236754AbhEJLIl (ORCPT ); Mon, 10 May 2021 07:08:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9F0B6142D; Mon, 10 May 2021 11:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644632; bh=JMheqsyEfXy+44rATLLzsT4x/MHGF6ef774zlWLaA0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKQmF6OxlP8X6XtKZrvz3aAoq99tXcdLARtpdihKERNoyicGyWibzwYxHkPP0ps26 pE33n2N0CscfeyTR3IHdqjdA/dcHpwNzhA2mFrPAXvntVjerVHFCyXRSW+zq7bOb0l 5qkDv+HTCK9IbK5cv6/Lr+rt6zc93w3PwokgqFTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Donnefort , "Peter Zijlstra (Intel)" , Ingo Molnar , Dietmar Eggemann , Vincent Guittot , Sasha Levin Subject: [PATCH 5.12 162/384] sched/pelt: Fix task util_est update filtering Date: Mon, 10 May 2021 12:19:11 +0200 Message-Id: <20210510102020.220689200@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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 Donnefort [ Upstream commit b89997aa88f0b07d8a6414c908af75062103b8c9 ] Being called for each dequeue, util_est reduces the number of its updates by filtering out when the EWMA signal is different from the task util_avg by less than 1%. It is a problem for a sudden util_avg ramp-up. Due to the decay from a previous high util_avg, EWMA might now be close enough to the new util_avg. No update would then happen while it would leave ue.enqueued with an out-of-date value. Taking into consideration the two util_est members, EWMA and enqueued for the filtering, ensures, for both, an up-to-date value. This is for now an issue only for the trace probe that might return the stale value. Functional-wise, it isn't a problem, as the value is always accessed through max(enqueued, ewma). This problem has been observed using LISA's UtilConvergence:test_means on the sd845c board. No regression observed with Hackbench on sd845c and Perf-bench sched pipe on hikey/hikey960. Signed-off-by: Vincent Donnefort Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Dietmar Eggemann Reviewed-by: Vincent Guittot Link: https://lkml.kernel.org/r/20210225165820.1377125-1-vincent.donnefort@arm.com Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e3c2dcb1b015..2a4041e3178f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3941,6 +3941,8 @@ static inline void util_est_dequeue(struct cfs_rq *cfs_rq, trace_sched_util_est_cfs_tp(cfs_rq); } +#define UTIL_EST_MARGIN (SCHED_CAPACITY_SCALE / 100) + /* * Check if a (signed) value is within a specified (unsigned) margin, * based on the observation that: @@ -3958,7 +3960,7 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep) { - long last_ewma_diff; + long last_ewma_diff, last_enqueued_diff; struct util_est ue; if (!sched_feat(UTIL_EST)) @@ -3979,6 +3981,8 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, if (ue.enqueued & UTIL_AVG_UNCHANGED) return; + last_enqueued_diff = ue.enqueued; + /* * Reset EWMA on utilization increases, the moving average is used only * to smooth utilization decreases. @@ -3992,12 +3996,17 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, } /* - * Skip update of task's estimated utilization when its EWMA is + * Skip update of task's estimated utilization when its members are * already ~1% close to its last activation value. */ last_ewma_diff = ue.enqueued - ue.ewma; - if (within_margin(last_ewma_diff, (SCHED_CAPACITY_SCALE / 100))) + last_enqueued_diff -= ue.enqueued; + if (within_margin(last_ewma_diff, UTIL_EST_MARGIN)) { + if (!within_margin(last_enqueued_diff, UTIL_EST_MARGIN)) + goto done; + return; + } /* * To avoid overestimation of actual task utilization, skip updates if -- 2.30.2