cpufreq / sched: SCHED_CPUFREQ_IOWAIT flag to indicate iowait condition
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 9 Sep 2016 21:59:33 +0000 (23:59 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 13 Sep 2016 21:36:01 +0000 (23:36 +0200)
Testing indicates that it is possible to improve performace
significantly without increasing energy consumption too much by
teaching cpufreq governors to bump up the CPU performance level if
the in_iowait flag is set for the task in enqueue_task_fair().

For this purpose, define a new cpufreq_update_util() flag
SCHED_CPUFREQ_IOWAIT and modify enqueue_task_fair() to pass that
flag to cpufreq_update_util() in the in_iowait case.  That generally
requires cpufreq_update_util() to be called directly from there,
because update_load_avg() may not be invoked in that case.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Looks-good-to: Steve Muckle <smuckle@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
include/linux/sched.h
kernel/sched/fair.c

index b0fa726..98fe95f 100644 (file)
@@ -3471,6 +3471,7 @@ static inline unsigned long rlimit_max(unsigned int limit)
 
 #define SCHED_CPUFREQ_RT       (1U << 0)
 #define SCHED_CPUFREQ_DL       (1U << 1)
 
 #define SCHED_CPUFREQ_RT       (1U << 0)
 #define SCHED_CPUFREQ_DL       (1U << 1)
+#define SCHED_CPUFREQ_IOWAIT   (1U << 2)
 
 #define SCHED_CPUFREQ_RT_DL    (SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL)
 
 
 #define SCHED_CPUFREQ_RT_DL    (SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL)
 
index 5d558cc..a5cd07b 100644 (file)
@@ -4500,6 +4500,14 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
        struct cfs_rq *cfs_rq;
        struct sched_entity *se = &p->se;
 
        struct cfs_rq *cfs_rq;
        struct sched_entity *se = &p->se;
 
+       /*
+        * If in_iowait is set, the code below may not trigger any cpufreq
+        * utilization updates, so do it here explicitly with the IOWAIT flag
+        * passed.
+        */
+       if (p->in_iowait)
+               cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_IOWAIT);
+
        for_each_sched_entity(se) {
                if (se->on_rq)
                        break;
        for_each_sched_entity(se) {
                if (se->on_rq)
                        break;