Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp368331rdb; Thu, 30 Nov 2023 07:02:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqBEWfwXGEe+IFXERJl6K48IKmx9j7XySLS5vACOLNhSIkxRveAjn7mfLjKBOwSW2z5zYO X-Received: by 2002:a05:6871:4607:b0:1f9:e940:3a19 with SMTP id nf7-20020a056871460700b001f9e9403a19mr29985879oab.1.1701356549333; Thu, 30 Nov 2023 07:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701356549; cv=none; d=google.com; s=arc-20160816; b=uhlmhChzz/sptjM7B4pdKwxNtcVMZ38DKM8hxM32EPK8iIJzFaipp6RFLiLXd8cVR5 0DTF39nrXm00BQ7PB4NDj6G22IweUxLkDQdFBw0pvtNLouY3S5CvrLXqeqjGwV8Pq61P p1+94B55QN9iEkfeex2KUUgEYZh58ZzvRjJjkWrQcRgmFFUg75Wm/1FGaRw3gBr3oiQ3 chYjq7LB+izFQno9P4j1OiodWpTS4yGtAVIVKEPv0OPtCdQuvZ8Xga1L+h340vTtSL/3 CSaMha5AGx9L1PIjTZD6BVMzIRKHeFdc0qF/kE5GOA5OhsCopnHOapE1ge+EOR1I2TLV jRAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6uE+1XqCxbAKbHngnWjE9Izc6x6SIjBE0R2sOtz+x7s=; fh=JjfoW/1v+l91PEIE5grmMTT+YlyRnm+iAG3+sS94xIE=; b=0ERiIfmpMA01qq+xMNzBDsfskULKA74xJqs6giklRXZ1p2Z1dTIknmDO8No4kdH+y8 NEe3pi28VZzJjFTpGyc2r55C7/Fc8bbvnN8yTnY5AhIARxhrZIe3pAhzT+tStCtFvkV8 mi1YmlbiQ0r2RX81DZv7rjy3L/HUSvGvaRmTihHkqEf3qfBY8jRkHrU0bAqDQkMS47IF 7JGRikAhrAeuSjgY3EtuCX09HXbEhpEJtpPgxEpvPAu+1LdlmZ2+yi2ZMzxP1r4wVjwi AdxxsqYSDMHemsyZE7/UAhp2HA3t8YT7oRrLF+SFbGJvfH+a3GkNnNME4tRUYNYrR/Ll oNMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SYi3x5wn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l10-20020a056870218a00b001fa253f3484si458480oae.199.2023.11.30.07.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:02:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SYi3x5wn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id AAE61803EB95; Thu, 30 Nov 2023 07:02:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346043AbjK3PCL (ORCPT + 99 others); Thu, 30 Nov 2023 10:02:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbjK3PCK (ORCPT ); Thu, 30 Nov 2023 10:02:10 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3661A4 for ; Thu, 30 Nov 2023 07:02:16 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2860f7942b0so1036558a91.2 for ; Thu, 30 Nov 2023 07:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701356536; x=1701961336; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6uE+1XqCxbAKbHngnWjE9Izc6x6SIjBE0R2sOtz+x7s=; b=SYi3x5wnJKWZo6+zb7nAdrcoirNjmrALwiQYrUn3xsDPO3hxEasI5LHgCn0a4Kqah+ fKQjZyQGoij1PAQLab49WqxnkwaepgQ2i/1HsL0vQEUUuBFaJnk5AhnWJEbxm7H/5DmJ YhlgV9xnusBrDwc/ic2vtScTh4c5V+N6JyqxvbsDdS1KKaJAyxzlwBxNhlQVwh7Sn3JK UhaLZEv470p0hjFJvGxFyulo5aIPxb4QuLTSLCCfqnpgfqh5pOwiMVAqil5TLwN4dors p6/zjsqQFWHAkiWpHolP3IyjmNSrFmYmnme5HIvHeSoIGQ7TPxyo9pEMJOSSXylBIQhX 7WCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701356536; x=1701961336; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6uE+1XqCxbAKbHngnWjE9Izc6x6SIjBE0R2sOtz+x7s=; b=ohZnepDVRtPSDvxvUeyPCKl2zVM8s0/sq4P8HpGtS/UTSucNEBDNrUIEpXHdE89EOR KtpHXLEkKgcummJVTK+JLOOPVmc+MUCHv1SCPsBCAfCYL8Y/xPohsmgGgkrqs1zNPQ9h bkraSHTBxRL+F3oFQvveLvHwHtslDCwOCKdVA0lrfYhTqW+c32t9XXmS/0OenTuMhlnl I1i8HVTm35RMlP07Zw5oaugdH2wqC5r9aKkXVCwSOjxJTf0skp0bM3KT7Zydvozr0mph fWSIlQeCdXXjXERRCJ29yUSMTT31mtYoP4BBbQ8ty30TVzhCjEKZ9x6Sspqm+ji1Ie6G taLA== X-Gm-Message-State: AOJu0YyjXRwKZvrLW7+tS4BbpKWT9pMdxYNPe7xqiFL0ZKEzY96oU2ur ln+NMgb/fEitcILkj0PkSurImv8mIJxl0v5Rn/g8pQ== X-Received: by 2002:a17:90b:1e45:b0:285:ade1:cbfa with SMTP id pi5-20020a17090b1e4500b00285ade1cbfamr20761775pjb.16.1701356536256; Thu, 30 Nov 2023 07:02:16 -0800 (PST) MIME-Version: 1.0 References: <20231127143238.1216582-1-vincent.guittot@linaro.org> <20231127143238.1216582-3-vincent.guittot@linaro.org> In-Reply-To: From: Vincent Guittot Date: Thu, 30 Nov 2023 16:02:02 +0100 Message-ID: Subject: Re: [PATCH 2/2] sched/fair: Simplify util_est To: Dietmar Eggemann Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, corbet@lwn.net, alexs@kernel.org, siyanteng@loongson.cn, qyousef@layalina.io, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, lukasz.luba@arm.com, hongyan.xia2@arm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 30 Nov 2023 07:02:26 -0800 (PST) On Thu, 30 Nov 2023 at 14:42, Dietmar Eggemann wrote: > > On 27/11/2023 15:32, Vincent Guittot wrote: > > With UTIL_EST_FASTUP now being permanent, we can take advantage of the > > fact that the ewma jumps directly to a higher utilization at dequeue to > > simplify util_est and remove the enqueued field. > > > > Did some simple test with a ramp-up/ramp_down (10-80-10%) task affine to > a CPU. > > https://nbviewer.org/github/deggeman/lisa/blob/ipynbs/ipynb/scratchpad/util_est_fastup.ipynb > > LGTM. Thanks > > [...] > > > @@ -4879,27 +4865,22 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, > > * 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; > > - 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; > > - } > > + last_ewma_diff = ewma - dequeued; > > + if (last_ewma_diff < UTIL_EST_MARGIN) > > + goto done; > > > > /* > > * To avoid overestimation of actual task utilization, skip updates if > > * we cannot grant there is idle time in this CPU. > > */ > > - if (task_util(p) > arch_scale_cpu_capacity(cpu_of(rq_of(cfs_rq)))) > > + if (dequeued > arch_scale_cpu_capacity(cpu_of(rq_of(cfs_rq)))) > > return; > > Not directly related to the changes: Should we not use `goto done` here > is well to rearm UTIL_AVG_UNCHANGED? I noticed this as well but didn't want to mix 2 topics. > > > /* > > * To avoid underestimate of task utilization, skip updates of EWMA if > > * we cannot grant that thread got all CPU time it wanted. > > */ > > - if ((ue.enqueued + UTIL_EST_MARGIN) < task_runnable(p)) > > + if ((dequeued + UTIL_EST_MARGIN) < task_runnable(p)) > > goto done; > > > > > > @@ -4914,18 +4895,18 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, > > * ewma(t) = w * task_util(p) + (1-w) * ewma(t-1) > > * = w * task_util(p) + ewma(t-1) - w * ewma(t-1) > > * = w * (task_util(p) - ewma(t-1)) + ewma(t-1) > > - * = w * ( last_ewma_diff ) + ewma(t-1) > > - * = w * (last_ewma_diff + ewma(t-1) / w) > > + * = w * ( -last_ewma_diff ) + ewma(t-1) > > + * = w * (-last_ewma_diff + ewma(t-1) / w) > > * > > * Where 'w' is the weight of new samples, which is configured to be > > * 0.25, thus making w=1/4 ( >>= UTIL_EST_WEIGHT_SHIFT) > > */ > > The text above still mentioned ue.enqueued and that we store the current > PELT value ... which isn't the case anymore. argh, I missed this one > > > > - ue.ewma <<= UTIL_EST_WEIGHT_SHIFT; > > - ue.ewma += last_ewma_diff; > > - ue.ewma >>= UTIL_EST_WEIGHT_SHIFT; > > + ewma <<= UTIL_EST_WEIGHT_SHIFT; > > + ewma -= last_ewma_diff; > > + ewma >>= UTIL_EST_WEIGHT_SHIFT; > > done: > > - ue.enqueued |= UTIL_AVG_UNCHANGED; > > - WRITE_ONCE(p->se.avg.util_est, ue); > > + ewma |= UTIL_AVG_UNCHANGED; > > + WRITE_ONCE(p->se.avg.util_est, ewma); > > > > trace_sched_util_est_se_tp(&p->se); > > } > > [...] > > Reviewed-by: Dietmar Eggemann Thanks