linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Bellasi <patrick.bellasi@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
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 12:57:56 +0100	[thread overview]
Message-ID: <20180410115756.GI14248@e110439-lin> (raw)
In-Reply-To: <20180410105606.GH7671@vireshk-i7>

On 10-Apr 16:26, Viresh Kumar wrote:
> 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.

Yes, that's possible... althought it's in the same scope of the
optimization you suggested for the next function, bail out ASAP to
avoid other branches.

> > 			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.

Yes, maybe... I think we still get the benefit to consolidate all the
iowait boost code into just these two function, while instead
currently the reset is in sugov_next_freq_shared().

Moreoverer, IMO it's easy to read and with a documentation more
aligned... but, lemme post a v2 and then we will see if it still makes
sense or I should just drop it.

-- 
#include <best/regards.h>

Patrick Bellasi

      reply	other threads:[~2018-04-10 11:58 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
2018-04-10 11:57       ` Patrick Bellasi [this message]

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=20180410115756.GI14248@e110439-lin \
    --to=patrick.bellasi@arm.com \
    --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=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=smuckle@google.com \
    --cc=tkjos@android.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@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;
as well as URLs for NNTP newsgroup(s).