Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1939357rwb; Mon, 7 Nov 2022 07:26:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5yHEOWU2YYpebeooIBVAyPk8ogBpGbrkEz+gcUHjf4djSQgPjmvs4cQ2AwUxEteY+6W9m5 X-Received: by 2002:a62:79c2:0:b0:56e:dca8:8a2a with SMTP id u185-20020a6279c2000000b0056edca88a2amr11205226pfc.54.1667834767406; Mon, 07 Nov 2022 07:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667834767; cv=none; d=google.com; s=arc-20160816; b=w25iY6PLyT0yx7WkNb/XlhBBo6VDPr6I1a8CpgUljR0m871mvpM0HOdT3+wHyl5W8U 0TrY7PV4L8Ey8Y7Y+W+vxPuYx95w6K1I10tRcvuNROFn76mtF6c5rJ87Y3hQRfhn0r7P rza44GWcWrefzpPbfn/hxqxEPLiDkDcQ0MzFoLAdNr8amAYda6vtQE0ORp6kD1+WU5RH VYcUMQBXXoAZLnVurXtkGppenW4jm314YeSICk9ifkrBOVOkA+xkDgbrtM2dnVxfdbM9 Koz6pf41cfJkHpv2uP8WWN56GgiY3ghNe50jnjppj2vGwS0sEZDbyv/sDfyN096kT03Q CUpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=frCwEg8y6Fhh91OaqNQd+dRhCvdE2X6bvJRY1xroZJs=; b=IlfzqacNWJ8/YywktYayhdA9w2N0vA/tUQErAx+E/2WJdy7/qgb2qNFV5m5tb1TCL7 SzcozqmVmRObqJgzXbhht30yY7ucdSD6E/QMQDa9oUcdw5MblWVOf/pQEdgZnEQM+VmA P69aWaSiurZxKNGRy2nt61rIDdwr6euQLqViCs0Y8U1aZ5XPLa2E+v9Th7jwpMRDgAwD Eyr2WYFPT0YvOuRSeJuzus1n6b6PuGpt3K5h/UTaC+EQo/F9o72YRpY/M2KPrjq5NMz7 d4CGRDMQgOo8vM4xU4PutKj0+C1Yn/wUJ6Gh84fXW4H3wz0yn6xKvZAK0ViqtnRdJg9y Sjjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=oaMTdDpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a63570b000000b00457dc916cd8si10372811pgb.152.2022.11.07.07.25.54; Mon, 07 Nov 2022 07:26:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=oaMTdDpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbiKGNlz (ORCPT + 93 others); Mon, 7 Nov 2022 08:41:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiKGNly (ORCPT ); Mon, 7 Nov 2022 08:41:54 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E67531CB31 for ; Mon, 7 Nov 2022 05:41:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=frCwEg8y6Fhh91OaqNQd+dRhCvdE2X6bvJRY1xroZJs=; b=oaMTdDpdeCX5Xy30tDrJm9TS6N bTM2oMyh/Or3UD2vwOUleKB4CwlPMOFlnyXqS1aXc3sIZL0etpn7Gg5xY0pP5WAI4F6asJW7sYg1I LcKLkGXacnoI3z3DaLTaGIjrdec6w8AW2vhAqJ2qwtcluiDck4hk8Zs78l7fjVg4WEQp+QR8K7CTk uLgc61t+gvkBmSDmmefbVbkKGy73bv6mFk5MX1mArAuEbg6nHYVjwpaPTImfsi9RavK7lUVpX5n18 0AJUWfkM/aiKS3ahZJ6atTIh035j57UGe03e7DCiQDRtI4uYRxjhP89whXnOyW7hAfmERK7d+QTZN Xktev++A==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1os2NR-009ks1-6J; Mon, 07 Nov 2022 13:41:25 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E4A0830026A; Mon, 7 Nov 2022 14:41:23 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CA90020298A51; Mon, 7 Nov 2022 14:41:23 +0100 (CET) Date: Mon, 7 Nov 2022 14:41:23 +0100 From: Peter Zijlstra To: Kajetan Puchalski Cc: Jian-Min Liu , Dietmar Eggemann , Ingo Molnar , Vincent Guittot , Morten Rasmussen , Vincent Donnefort , Quentin Perret , Patrick Bellasi , Abhijeet Dharmapurikar , Qais Yousef , linux-kernel@vger.kernel.org, Jonathan JMChen Subject: Re: [RFC PATCH 0/1] sched/pelt: Change PELT halflife at runtime Message-ID: References: <20220829055450.1703092-1-dietmar.eggemann@arm.com> <0f82011994be68502fd9833e499749866539c3df.camel@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 03:41:47PM +0100, Kajetan Puchalski wrote: > Based on all the tests we've seen, jankbench or otherwise, the > improvement can mainly be attributed to the faster ramp up of frequency > caused by the shorter PELT window while using schedutil. Would something terrible like the below help some? If not, I suppose it could be modified to take the current state as history. But basically it runs a faster pelt sum along side the regular signal just for ramping up the frequency. diff --git a/kernel/sched/features.h b/kernel/sched/features.h index ee7f23c76bd3..9ba07a1d19f6 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -96,6 +96,7 @@ SCHED_FEAT(WA_BIAS, true) */ SCHED_FEAT(UTIL_EST, true) SCHED_FEAT(UTIL_EST_FASTUP, true) +SCHED_FEAT(UTIL_EST_FASTER, true) SCHED_FEAT(LATENCY_WARN, false) diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index 0f310768260c..13cd9e27ce3e 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -148,6 +148,22 @@ accumulate_sum(u64 delta, struct sched_avg *sa, return periods; } +/* + * Compute a pelt util_avg assuming no history and @delta runtime. + */ +unsigned long faster_est_approx(u64 delta) +{ + unsigned long contrib = (unsigned long)delta; /* p == 0 -> delta < 1024 */ + u64 periods = delta / 1024; + + if (periods) { + delta %= 1024; + contrib = __accumulate_pelt_segments(periods, 1024, delta); + } + + return (contrib << SCHED_CAPACITY_SHIFT) / PELT_MIN_DIVIDER; +} + /* * We can represent the historical contribution to runnable average as the * coefficients of a geometric series. To do this we sub-divide our runnable diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index a4a20046e586..99827d5dda27 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2922,6 +2922,8 @@ static inline unsigned long cpu_util_dl(struct rq *rq) return READ_ONCE(rq->avg_dl.util_avg); } +extern unsigned long faster_est_approx(u64 runtime); + /** * cpu_util_cfs() - Estimates the amount of CPU capacity used by CFS tasks. * @cpu: the CPU to get the utilization for. @@ -2956,13 +2958,26 @@ static inline unsigned long cpu_util_dl(struct rq *rq) */ static inline unsigned long cpu_util_cfs(int cpu) { + struct rq *rq = cpu_rq(cpu); struct cfs_rq *cfs_rq; unsigned long util; - cfs_rq = &cpu_rq(cpu)->cfs; + cfs_rq = &rq->cfs; util = READ_ONCE(cfs_rq->avg.util_avg); if (sched_feat(UTIL_EST)) { + if (sched_feat(UTIL_EST_FASTER)) { + struct task_struct *curr; + + rcu_read_lock(); + curr = rcu_dereference(rq->curr); + if (likely(curr->sched_class == &fair_sched_class)) { + u64 runtime = curr->se.sum_exec_runtime - curr->se.exec_start; + util = max_t(unsigned long, util, + faster_est_approx(runtime * 2)); + } + rcu_read_unlock(); + } util = max_t(unsigned long, util, READ_ONCE(cfs_rq->avg.util_est.enqueued)); }