Linux Power Management development
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Juri Lelli <juri.lelli@redhat.com>, Todd Kjos <tkjos@android.com>,
	Joel Fernandes <joelaf@google.com>,
	Steve Muckle <smuckle@google.com>
Subject: Re: [PATCH] cpufreq/schedutil: Cleanup and document iowait boost
Date: Tue, 10 Apr 2018 16:26:06 +0530	[thread overview]
Message-ID: <20180410105606.GH7671@vireshk-i7> (raw)
In-Reply-To: <20180410104349.GE14248@e110439-lin>

On 10-04-18, 11:43, Patrick Bellasi wrote:
> On 05-Apr 15:28, Viresh Kumar wrote:
> What about this new version for the two functions,
> just compile tested:
> 
> ---8<---
> 
> static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
> 				   unsigned int flags)
> {
> 	bool iowait = flags & SCHED_CPUFREQ_IOWAIT;
> 
> 	/* Reset boost if the CPU appears to have been idle enough */
> 	if (sg_cpu->iowait_boost) {
> 		s64 delta_ns = time - sg_cpu->last_update;
> 
> 		if (delta_ns > TICK_NSEC) {
> 			sg_cpu->iowait_boost = iowait
> 				? sg_cpu->sg_policy->policy->min : 0;

Yeah, I see you are trying to optimize it a bit here but this makes
things more confusing I would say :)

I would just set iowait_boost to 0 and drop the return; from below and
let the code fall through and reach the end of this routine.

> 			sg_cpu->iowait_boost_pending = iowait;
> 			return;
> 		}
> 	}
> 
> 	/* Boost only tasks waking up after IO */
> 	if (!iowait)
> 		return;
> 
> 	/* Ensure IO boost doubles only one time at each frequency increase */
> 	if (sg_cpu->iowait_boost_pending)
> 		return;
> 	sg_cpu->iowait_boost_pending = true;
> 
> 	/* Double the IO boost at each frequency increase */
> 	if (sg_cpu->iowait_boost) {
> 		sg_cpu->iowait_boost <<= 1;
> 		if (sg_cpu->iowait_boost > sg_cpu->iowait_boost_max)
> 			sg_cpu->iowait_boost = sg_cpu->iowait_boost_max;
> 		return;
> 	}
> 
> 	/* At first wakeup after IO, start with minimum boost */
> 	sg_cpu->iowait_boost = sg_cpu->sg_policy->policy->min;
> }
> 
> static void sugov_iowait_boost(struct sugov_cpu *sg_cpu,
> 			       unsigned long *util, unsigned long *max)
> {
> 	unsigned int boost_util, boost_max;
> 
>         /* No IOWait boost active */
>         if (!sg_cpu->iowait_boost)
>                 return;
> 
> 	/* An IO waiting task has just woken up, use the boost value */
> 	if (sg_cpu->iowait_boost_pending) {
> 		sg_cpu->iowait_boost_pending = false;
> 	} else {
> 		/* Reduce the boost value otherwise */
> 		sg_cpu->iowait_boost >>= 1;
> 		if (sg_cpu->iowait_boost < sg_cpu->sg_policy->policy->min) {
> 			sg_cpu->iowait_boost = 0;
> 			return;
> 		}
> 	}
> 
> 	boost_util = sg_cpu->iowait_boost;
> 	boost_max = sg_cpu->iowait_boost_max;
> 
> 	/*
> 	 * A CPU is boosted only if its current utilization is smaller then
> 	 * the current IO boost level.
> 	 */
> 	if (*util * boost_max < *max * boost_util) {
> 		*util = boost_util;
> 		*max = boost_max;
> 	}
> }

So this is quite different than what you proposed, it is only fixing
the existing problem which I pointed out to. Looks fine, not much
changed really from the current state of code.

-- 
viresh

  reply	other threads:[~2018-04-10 10:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28  9:07 [PATCH] cpufreq/schedutil: Cleanup and document iowait boost Patrick Bellasi
2018-04-05  9:58 ` Viresh Kumar
2018-04-10 10:43   ` Patrick Bellasi
2018-04-10 10:56     ` Viresh Kumar [this message]
2018-04-10 11:57       ` Patrick Bellasi

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=20180410105606.GH7671@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelaf@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=patrick.bellasi@arm.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=smuckle@google.com \
    --cc=tkjos@android.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