linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Bellasi <patrick.bellasi@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Quentin Perret <quentin.perret@arm.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Juri Lelli <juri.lelli@redhat.com>, Todd Kjos <tkjos@google.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Aaron Lu <aaron.lu@intel.com>,
	Ye Xiaolong <xiaolong.ye@intel.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] sched/fair: util_est: fix cpu_util_wake for execl
Date: Fri, 2 Nov 2018 09:53:14 +0000	[thread overview]
Message-ID: <20181102095314.GB31275@e110439-lin> (raw)
In-Reply-To: <20181031184527.GA3178@hirez.programming.kicks-ass.net>

On 31-Oct 19:45, Peter Zijlstra wrote:
> On Tue, Oct 30, 2018 at 04:09:47PM +0000, Patrick Bellasi wrote:
> 
> > Let's fix this by ensuring to always discount the task estimated
> > utilization from the CPU's estimated utilization when the task is also
> > the current one. The same benchmark of the bug report, executed on a
> > dual socket 40 CPUs Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz machine,
> > reports these "Execl Throughput" figures (higher the better):
> 
> Before this we have:
> 
> 	/* Discount task's blocked util from CPU's util */
> 	util -= min_t(unsigned int, util, task_util(p));
> 
> at the very least that comment is now inaccurate, since @p might not be
> blocked.

Right... will fix this too.

> > @@ -6258,8 +6267,17 @@ static unsigned long cpu_util_wake(int cpu, struct task_struct *p)
> >  	 * covered by the following code when estimated utilization is
> >  	 * enabled.
> >  	 */
> > -	if (sched_feat(UTIL_EST))
> > -		util = max(util, READ_ONCE(cfs_rq->avg.util_est.enqueued));
> > +	if (sched_feat(UTIL_EST)) {
> > +		unsigned int estimated =
> > +			READ_ONCE(cfs_rq->avg.util_est.enqueued);
> > +
> > +		if (unlikely(current == p || task_on_rq_queued(p))) {
> 
> I'm confused by the need for 'current == p', afaict task_on_rq_queued(p)
> is sufficient -- we've already established task_cpu(p) == cpu earlier.

Mmm... you right, I've got confused by the fact that current is
removed from the RBTree, but we keep tracking it as:

    on_rq = TASK_ON_RQ_QUEUED

... unless, select_task_rq_fair() races with LB's:

    detach_task()
      p->on_rq = TASK_ON_RQ_MIGRATING;
      -----------------------------------A
      deactivate_task()                   \
        dequeue_task()                     +- RaceTime
          util_est_dequeue()              /
      -----------------------------------B
      set_task_cpu()
        migrate_task_rq{_fair}()
          detach_entity_cfs_rq()

where, in [A..B] we will still avoid to discount *p's estimated
utilization. :/

Do you think we can live with that for the time being, maybe by just
adding a comment, or should we try to close that too ?

Eventually, the (current == p) check, maybe moved to the right of the
OR condition above, should certainly close the race window for the
specific UnixBench's execl case. Assuming for example the execl is
executed by a misfit task which is target of an active load balance...


> > +			estimated -= min_t(unsigned int, estimated,
> > +				(_task_util_est(p) | UTIL_AVG_UNCHANGED));
> > +		}
> > +
> > +		util = max(util, estimated);
> > +	}
> 
> Also, I think it is about time we find a suitable name for:
> 
> #define xxx(_var, _val) do { \

   remove_contrib(_var, _val) ?

> 	typeof(_var) var = (_var); \
> 	typeof(_var) val = (_val); \
> 	typeof(_var) res = var - val; \
> 	if (res > var) \
> 		res = 0; \
> 	(_var) = res; \
> } while (0)
> 
> Which is basically sub_positive() but without the READ_ONCE/WRITE_ONCE
> stuff.

Perhaps there are still some paths in where sub_positive() can be
recycled... will look better into that and see what we can do on that
polishing side. However, I'll keep all that in a different patch.

> We do that:
> 
> 	var -= min_t(typeof(var), var, val);
> 
> pattern _all_ over.

Cheers Patrick

-- 
#include <best/regards.h>

Patrick Bellasi

      reply	other threads:[~2018-11-02  9:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 16:09 [PATCH] sched/fair: util_est: fix cpu_util_wake for execl Patrick Bellasi
2018-10-31 18:45 ` Peter Zijlstra
2018-11-02  9:53   ` 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=20181102095314.GB31275@e110439-lin \
    --to=patrick.bellasi@arm.com \
    --cc=aaron.lu@intel.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=quentin.perret@arm.com \
    --cc=surenb@google.com \
    --cc=tkjos@google.com \
    --cc=xiaolong.ye@intel.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).