[PATCH] sched/schedutil : optimize utilization scaling for guest kernel

From: Vincent Guittot
Date: Wed Aug 29 2018 - 04:51:54 EST


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@xxxxxxxxx>
Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
---
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