public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Kajetan Puchalski <kajetan.puchalski@arm.com>
Cc: Jian-Min Liu <jian-min.liu@mediatek.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Vincent Donnefort <vdonnefort@google.com>,
	Quentin Perret <qperret@google.com>,
	Patrick Bellasi <patrick.bellasi@matbug.net>,
	Abhijeet Dharmapurikar <adharmap@quicinc.com>,
	Qais Yousef <qais.yousef@arm.com>,
	linux-kernel@vger.kernel.org,
	Jonathan JMChen <jonathan.jmchen@mediatek.com>
Subject: Re: [RFC PATCH 0/1] sched/pelt: Change PELT halflife at runtime
Date: Mon, 7 Nov 2022 14:41:23 +0100	[thread overview]
Message-ID: <Y2kLA8x40IiBEPYg@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <YzWuq5ShtJC6KWqe@e126311.manchester.arm.com>

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));
 	}




  parent reply	other threads:[~2022-11-07 13:41 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29  5:54 [RFC PATCH 0/1] sched/pelt: Change PELT halflife at runtime Dietmar Eggemann
2022-08-29  5:54 ` [RFC PATCH 1/1] sched/pelt: Introduce PELT multiplier Dietmar Eggemann
2022-08-29  8:08   ` Peter Zijlstra
2022-08-29 10:02     ` Peter Zijlstra
2022-08-29 10:13       ` Vincent Guittot
2022-08-29 14:23         ` Quentin Perret
2022-08-29 14:34           ` Peter Zijlstra
2022-08-29 15:31             ` Quentin Perret
2022-08-29 15:48             ` Quentin Perret
2022-09-02  7:53         ` Dietmar Eggemann
2022-09-02  8:45           ` Peter Zijlstra
2022-09-06  5:49           ` Vincent Guittot
2022-09-08  6:50             ` Dietmar Eggemann
2022-09-02  7:53       ` Dietmar Eggemann
2022-09-02  8:45         ` Peter Zijlstra
2022-09-20 14:07 ` [RFC PATCH 0/1] sched/pelt: Change PELT halflife at runtime Jian-Min Liu
2022-09-28 17:09   ` Dietmar Eggemann
2022-09-29  9:47   ` Peter Zijlstra
2022-09-29 11:07     ` Dietmar Eggemann
2022-09-29 11:10     ` Kajetan Puchalski
2022-09-29 11:21       ` Peter Zijlstra
2022-09-29 14:41         ` Kajetan Puchalski
2022-10-03 22:57           ` Wei Wang
2022-10-04  9:33             ` Dietmar Eggemann
2022-10-05 16:57               ` Wei Wang
2022-11-07 13:41           ` Peter Zijlstra [this message]
2022-11-08 19:48             ` Qais Yousef
2022-11-09 15:49               ` Peter Zijlstra
2022-11-10 13:25                 ` Qais Yousef
2023-02-07 10:29                 ` Dietmar Eggemann
2023-02-09 16:16                   ` Vincent Guittot
2023-02-17 13:54                     ` Dietmar Eggemann
2023-02-20 13:54                       ` Vincent Guittot
2023-02-21  9:29                         ` Vincent Guittot
2023-02-22 20:28                           ` Dietmar Eggemann
2023-03-01 10:24                             ` Vincent Guittot
2023-02-22 20:13                         ` Dietmar Eggemann
2023-03-02 19:36                           ` Dietmar Eggemann
2023-02-20 10:13                     ` Peter Zijlstra
2023-02-20 13:39                       ` Vincent Guittot
2023-02-23 15:37                     ` Qais Yousef
2023-03-01 10:39                       ` Vincent Guittot
2023-03-01 17:24                         ` Qais Yousef
2023-03-02  8:00                           ` Vincent Guittot
2023-03-02 19:39                             ` Dietmar Eggemann
2023-03-06 19:11                             ` Qais Yousef
2023-03-07 13:22                               ` Vincent Guittot
2023-03-11 16:55                                 ` Qais Yousef
2023-03-23 16:29                           ` Dietmar Eggemann
2023-04-03 14:45                             ` Qais Yousef
2023-04-06 15:58                               ` Dietmar Eggemann
2023-04-11 17:51                                 ` Qais Yousef
2022-11-09 15:18             ` Lukasz Luba
2022-11-10 11:16             ` Dietmar Eggemann
2022-11-10 13:05               ` Peter Zijlstra
2022-11-10 14:59                 ` Dietmar Eggemann
2022-11-10 17:51                   ` Peter Zijlstra
2022-11-30 18:14                     ` Dietmar Eggemann
2022-12-01 13:37                       ` Kajetan Puchalski
2022-11-10 12:45             ` Kajetan Puchalski
2022-11-07  9:41     ` Jian-Min Liu (劉建旻)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y2kLA8x40IiBEPYg@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=adharmap@quicinc.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jian-min.liu@mediatek.com \
    --cc=jonathan.jmchen@mediatek.com \
    --cc=kajetan.puchalski@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=morten.rasmussen@arm.com \
    --cc=patrick.bellasi@matbug.net \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --cc=vdonnefort@google.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox