Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp314247rdb; Thu, 30 Nov 2023 05:43:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcG4twg3U1CKwWogTp8zVJJ3K4OKzFdT5aR65JQnEHZNN4KKdDf7usZENHR9m/bvvmfZNl X-Received: by 2002:a05:6808:1645:b0:3b5:ae0d:b1f5 with SMTP id az5-20020a056808164500b003b5ae0db1f5mr22481148oib.50.1701351801519; Thu, 30 Nov 2023 05:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701351801; cv=none; d=google.com; s=arc-20160816; b=HGni8yWlrtKGyajLv9GY7TrkndbZUekaLMv5iPi8Wl6fQ1iHm0F21oy26/cfz0qkl/ v4OFaz8FfHsu5EGk4DR/ZiiXBtN0rx9ubbdVzYpUV/6RweWyHtkjzpv+Uz7TB4Z0Q43K /cab5AX2dZpL4ErtUMKphtKSYbEa+ebDbt8hZTYMJJOMHqGiiWhfPq6bFPYUIyncs6q5 F8fb468QZUMlchBkgOSqwmNo0jxUeiT3YqrOeDFHV0iv54WrS9jwOqjFcTDGc+rCaq+F /eOtkaF8rsGVecPkEVbFhktkv0DPk+YBDxVrZan7nRS03u3xFB2EcD0V50bHccqsco+S 73jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=wOufIf5TScRjHDgLNFt11xZAuUL8VyfsHk3W0b6ATCc=; fh=Aa6ZoNXkVUHeiyLDtQhDJgDF2KWAXd+oTWILTGiCZ3U=; b=OFntV/rIXtFnIMO5s3RU13DJLA75cO9eMrMl6RIjeiqovVwysBVXBzZvcgAHxHgCis PIAHl3z+GXmbczSsU0s50+1Uz6jakkTZdpJ6L48IjPTqA3hF1DyUX/c5IVzJBtFznjL2 jftMeavS82Uw1r64oo74tuUtuIycbhZeSESlr/jj7AWQkEySq7lWgh03Eqi+9Gs5/Mt1 4E1lARWCkkPNe0ianVnbzkmm4pw0qQ0tKxkf0jQMf2hbz/bXoG5/sRvFcxWUAQPGvOfR MbJDhK7r9YArQQBMYHSH9Ppp7avLS6cpDzzJYzP9+5vFGRyJrGLtlCYMFz3y388PXduC Xy4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x191-20020a6386c8000000b005849fe1d3aesi1310304pgd.458.2023.11.30.05.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8463480CD710; Thu, 30 Nov 2023 05:43:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345624AbjK3Nmn (ORCPT + 99 others); Thu, 30 Nov 2023 08:42:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345645AbjK3Nml (ORCPT ); Thu, 30 Nov 2023 08:42:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 26F8619F; Thu, 30 Nov 2023 05:42:46 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7ABAE143D; Thu, 30 Nov 2023 05:43:32 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 608C93F5A1; Thu, 30 Nov 2023 05:42:43 -0800 (PST) Message-ID: Date: Thu, 30 Nov 2023 14:42:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] sched/fair: Simplify util_est Content-Language: en-US To: Vincent Guittot , 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 Cc: lukasz.luba@arm.com, hongyan.xia2@arm.com References: <20231127143238.1216582-1-vincent.guittot@linaro.org> <20231127143238.1216582-3-vincent.guittot@linaro.org> From: Dietmar Eggemann In-Reply-To: <20231127143238.1216582-3-vincent.guittot@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 30 Nov 2023 05:43:15 -0800 (PST) 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. [...] > @@ -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? > /* > * 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. > - 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