linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/schedutil : optimize utilization scaling for guest kernel
@ 2018-08-29  8:51 Vincent Guittot
  2018-08-29 12:45 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Guittot @ 2018-08-29  8:51 UTC (permalink / raw)
  To: peterz, mingo, linux-kernel, kernellwp; +Cc: Vincent Guittot

Scaling the utilization of CPUs with irq util_avg in schedutil doesn't give
any benefit and just waste CPU cycles when irq time is not accounted but
only steal time.
Add an internal _scale_irq_capacity() for scale_rt_capacity but scale
cpu utilization in schedutil only if we are accounting irq time.

Suggested-by: Wanpeng Li <kernellwp@gmail.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 kernel/sched/fair.c  |  2 +-
 kernel/sched/sched.h | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 309c93f..c1334be 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7501,7 +7501,7 @@ static unsigned long scale_rt_capacity(int cpu)
 
 	free = max - used;
 
-	return scale_irq_capacity(free, irq, max);
+	return _scale_irq_capacity(free, irq, max);
 }
 
 static void update_cpu_capacity(struct sched_domain *sd, int cpu)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 4a2e8ca..1003d69 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2221,14 +2221,14 @@ static inline unsigned long cpu_util_irq(struct rq *rq)
 }
 
 static inline
-unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
+unsigned long _scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
 {
 	util *= (max - irq);
 	util /= max;
 
 	return util;
-
 }
+
 #else
 static inline unsigned long cpu_util_irq(struct rq *rq)
 {
@@ -2236,8 +2236,26 @@ static inline unsigned long cpu_util_irq(struct rq *rq)
 }
 
 static inline
+unsigned long _scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
+{
+	return util;
+}
+#endif
+
+/*
+ * scale_irq_capacity is used by schedutil to scale utilization only when
+ * irq time is accounted. This scaling is not necessary when only virtual time
+ * is accounted as guest doesn't have access to frequency scaling.
+ */
+#ifdef CONFIG_IRQ_TIME_ACCOUNTING
+
+#define scale_irq_capacity _scale_irq_capacity
+
+#else
+static inline
 unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
 {
 	return util;
 }
 #endif
+
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/schedutil : optimize utilization scaling for guest kernel
  2018-08-29  8:51 [PATCH] sched/schedutil : optimize utilization scaling for guest kernel Vincent Guittot
@ 2018-08-29 12:45 ` Peter Zijlstra
  2018-08-29 14:06   ` Vincent Guittot
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2018-08-29 12:45 UTC (permalink / raw)
  To: Vincent Guittot; +Cc: mingo, linux-kernel, kernellwp

On Wed, Aug 29, 2018 at 10:51:42AM +0200, Vincent Guittot wrote:
> Scaling the utilization of CPUs with irq util_avg in schedutil doesn't give
> any benefit and just waste CPU cycles when irq time is not accounted but
> only steal time.
> Add an internal _scale_irq_capacity() for scale_rt_capacity but scale
> cpu utilization in schedutil only if we are accounting irq time.

This makes a mess of things; also it doesn't really do what it says.

Even if we have CONFIG_IRQ_TIME_ACCOUNTING, that doesn't mean we do it,
just that it is capable.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/schedutil : optimize utilization scaling for guest kernel
  2018-08-29 12:45 ` Peter Zijlstra
@ 2018-08-29 14:06   ` Vincent Guittot
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Guittot @ 2018-08-29 14:06 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel, kernellwp

Le Wednesday 29 Aug 2018 à 14:45:03 (+0200), Peter Zijlstra a écrit :
> On Wed, Aug 29, 2018 at 10:51:42AM +0200, Vincent Guittot wrote:
> > Scaling the utilization of CPUs with irq util_avg in schedutil doesn't give
> > any benefit and just waste CPU cycles when irq time is not accounted but
> > only steal time.
> > Add an internal _scale_irq_capacity() for scale_rt_capacity but scale
> > cpu utilization in schedutil only if we are accounting irq time.
> 
> This makes a mess of things; also it doesn't really do what it says.

you're right. I forgot to not add irq util_avg in this case.
What about the below instead ?

sched/schedutil : optimize computation of utilization in schedutil
    
Scaling the utilization of CPUs with irq util_avg in schedutil doesn't give
any benefit and just waste CPU cycles when irq time is not accounted but
only steal time.
Skip the irq scaling when irq time is not accounted

Suggested-by: Wanpeng Li <kernellwp@gmail.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>

---
 kernel/sched/cpufreq_schedutil.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 3fffad3..edbc4d2 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -238,6 +238,7 @@ static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu)
 	if ((util + cpu_util_dl(rq)) >= max)
 		return max;
 
+#ifdef CONFIG_IRQ_TIME_ACCOUNTING
 	/*
 	 * There is still idle time; further improve the number by using the
 	 * irq metric. Because IRQ/steal time is hidden from the task clock we
@@ -249,6 +250,7 @@ static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu)
 	 */
 	util = scale_irq_capacity(util, irq, max);
 	util += irq;
+#endif
 
 	/*
 	 * Bandwidth required by DEADLINE must always be granted while, for
-- 
2.7.4

> 
> Even if we have CONFIG_IRQ_TIME_ACCOUNTING, that doesn't mean we do it,
> just that it is capable.
> 
> 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-29 14:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  8:51 [PATCH] sched/schedutil : optimize utilization scaling for guest kernel Vincent Guittot
2018-08-29 12:45 ` Peter Zijlstra
2018-08-29 14:06   ` Vincent Guittot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).