linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Wang <wvw@google.com>
To: unlisted-recipients:; (no To-header on input)
Cc: wei.vince.wang@gmail.com, qais.yousef@arm.com,
	dietmar.eggemann@arm.com, valentin.schneider@arm.com,
	chris.redpath@arm.com, qperret@google.com,
	Wei Wang <wvw@google.com>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] [RFC] sched: restrict iowait boost for boosted task only
Date: Thu, 23 Jan 2020 16:28:10 -0800	[thread overview]
Message-ID: <20200124002811.228334-1-wvw@google.com> (raw)

Currently iowait doesn't distinguish background/foreground tasks.
This may not be a problem in servers but could impact devices that
are more sensitive on energy consumption. [1]
In Android world, we have seen many cases where device run to high and
inefficient frequency unnecessarily when running some background task
which are interacting I/O.

The ultimate goal is to only apply iowait boost on UX related tasks and
leave the rest for EAS scheduler for better efficiency.

This patch limits iowait boost for tasks which are associated with boost
signal from user land. On Android specifically, those are foreground or
top app tasks.

[1] ANDROID discussion:
https://android-review.googlesource.com/c/kernel/common/+/1215695

Signed-off-by: Wei Wang <wvw@google.com>
---
 kernel/sched/fair.c  |  4 +++-
 kernel/sched/sched.h | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ba749f579714..221c0fbcea0e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5220,8 +5220,10 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
 	 * 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 CONFIG_ENERGY_MODEL and CONFIG_UCLAMP_TASK are both configured,
+	 * only boost for tasks set with non-null min-clamp.
 	 */
-	if (p->in_iowait)
+	if (iowait_boosted(p))
 		cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT);
 
 	for_each_sched_entity(se) {
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 280a3c735935..a13d49d835ed 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2341,6 +2341,18 @@ static inline unsigned int uclamp_util(struct rq *rq, unsigned int util)
 }
 #endif /* CONFIG_UCLAMP_TASK */
 
+#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_UCLAMP_TASK)
+static inline bool iowait_boosted(struct task_struct *p)
+{
+	return p->in_iowait && uclamp_eff_value(p, UCLAMP_MIN) > 0;
+}
+#else /* defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_UCLAMP_TASK) */
+static inline bool iowait_boosted(struct task_struct *p)
+{
+	return p->in_iowait;
+}
+#endif /* defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_UCLAMP_TASK) */
+
 #ifdef arch_scale_freq_capacity
 # ifndef arch_scale_freq_invariant
 #  define arch_scale_freq_invariant()	true
-- 
2.25.0.341.g760bfbb309-goog


             reply	other threads:[~2020-01-24  0:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  0:28 Wei Wang [this message]
2020-01-24  2:52 ` [PATCH] [RFC] sched: restrict iowait boost for boosted task only Qais Yousef
2020-01-24  9:51   ` Quentin Perret
2020-01-24 11:01     ` Valentin Schneider
2020-01-24 11:30       ` Qais Yousef
2020-01-24 20:55         ` Wei Wang
2020-01-25 23:59           ` Qais Yousef
2020-01-26  0:25             ` Qais Yousef
2020-01-26  6:41             ` Wei Wang
2020-01-24 19:12       ` Wei Wang

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=20200124002811.228334-1-wvw@google.com \
    --to=wvw@google.com \
    --cc=bsegall@google.com \
    --cc=chris.redpath@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --cc=rostedt@goodmis.org \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=wei.vince.wang@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).