mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Morten Rasmussen <morten.rasmussen@arm.com>
To: "bsegall@google.com" <bsegall@google.com>
Cc: "peterz@infradead.org" <peterz@infradead.org>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Paul Turner <pjt@google.com>
Subject: Re: [PATCH] sched: Update task group load contributions during active load-balancing
Date: Wed, 17 Sep 2014 18:57:41 +0100	[thread overview]
Message-ID: <20140917175741.GA9854@e103034-lin> (raw)
In-Reply-To: <xm26sijrqwv9.fsf@sword-of-the-dawn.mtv.corp.google.com>

On Tue, Sep 16, 2014 at 06:49:14PM +0100, bsegall@google.com wrote:
> Morten Rasmussen <morten.rasmussen@arm.com> writes:
> 
> > Task group load-contributions are not updated when tasks belonging to
> > task groups are migrated by active load-balancing. If no other task
> > belonging to the same task group is already queued at the destination
> > cpu the group sched_entity will be enqueued with load_avg_contrib=0.
> > Hence, weighted_cpuload() won't reflect the newly added load.
> >
> > The load may remain invisible until the next tick, when the sched_entity
> > load_avg_contrib and task group contributions are reevaluated.
> >
> > The enqueue loop
> >
> > 	for_each_entity(se) {
> > 	   enqueue_entity(cfs_rq,se)
> > 	      ...
> > 	      enqueue_entity_load_avg(cfs_rq,se)
> > 	         ...
> > 	         update_entity_load_avg(se)
> > 		    ...
> > 		    __update_entity_load_avg_contrib(se)
> > 		    ...
> > 		 ...
> > 	         update_cfs_rq_blocked_load(cfs_rq)
> > 		    ...
> > 		    __update_cfs_rq_tg_load_contrib(cfs_rq)
> > 		    ...
> > 	}
> >
> > currently skips __update_entity_load_avg_contrib() and
> > __update_cfs_rq_tg_load_contrib() for group entities for active
> > load-balance migrations. The former updates the sched_entity
> > load_avg_contrib, and the latter updates the task group contribution
> > which is needed by the former. They must both be called to ensure that
> > load doesn't temporarily disappear.
> >
> > cc: Paul Turner <pjt@google.com>
> > cc: Ben Segall <bsegall@google.com>
> >
> > Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
> > ---
> >  kernel/sched/fair.c |    7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index be9e97b..2b6e2eb 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -2521,7 +2521,8 @@ static inline void update_entity_load_avg(struct sched_entity *se,
> >  	else
> >  		now = cfs_rq_clock_task(group_cfs_rq(se));
> >  
> > -	if (!__update_entity_runnable_avg(now, &se->avg, se->on_rq))
> > +	if (!__update_entity_runnable_avg(now, &se->avg, se->on_rq) &&
> > +							entity_is_task(se))
> >  		return;
> >  
> >  	contrib_delta = __update_entity_load_avg_contrib(se);
> > @@ -2609,6 +2610,10 @@ static inline void enqueue_entity_load_avg(struct cfs_rq *cfs_rq,
> >  	cfs_rq->runnable_load_avg += se->avg.load_avg_contrib;
> >  	/* we force update consideration on load-balancer moves */
> >  	update_cfs_rq_blocked_load(cfs_rq, !wakeup);
> > +
> > +	/* We force update group contributions on load-balancer moves */
> > +	if (wakeup && !entity_is_task(se))
> > +		__update_cfs_rq_tg_load_contrib(cfs_rq, 0);
> >  }
> >  
> >  /*
> 
> It should probably be clearer that what this actually means is that we
> always update tg_load_contrib for any group-of-group (which is weird),

Would it not only update groups entities if they aren't already on a
runqueue? I'm clearly missing something.

> so that we update the entire tree on load-balancer moves (which is
> sensible and what we care about, because it determines each se.load_avg_contrib).
> 
> Wouldn't we need this on dequeue as well?

Yes. The problem is there too I think. It is not as visible though. If
the last task of a particular group is migrated away from a cpu, the
group entities will be dequeued and we should be fine. However, if there
are other tasks left in the group or any parent group the load of that
group will be off, I think. I need to verify that.

> 
> I believe the reason for both of these ratelimits was performance on
> sleep/wake (where blocked_load_avg means tg_load_contrib should not have
> changed), it would be good to know how much this hurts. Given the
> fast-exit in __update_cfs_rq_tg_load_contrib, it seems like it might be
> fine, but the group-entity __update_entity_load_avg_contrib is less
> free when div_u64 is expensive, and is currently only called 1/ms.

Right. Is there a suitable group scheduling benchmark I can use to test
this?

> 
> It seems like it would be a bit of a mess to force an update of the
> entire path in migrate, but it would certainly dodge the performance
> concerns if they wind up being an issue. (I suppose we could have
> ENQUEUE/DEQUEUE_MIGRATE or something...)

Yes, I had the same thought. We might have to do something like that
anyway to fix the dequeue path. It seems less straightforward to fix,
but I need to take a closer look.

Morten

  reply	other threads:[~2014-09-17 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  0:07 Morten Rasmussen
2014-09-16 17:49 ` bsegall
2014-09-17 17:57   ` Morten Rasmussen [this message]
2014-09-17 18:06     ` bsegall

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=20140917175741.GA9854@e103034-lin \
    --to=morten.rasmussen@arm.com \
    --cc=bsegall@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pjt@google.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

all inboxes | Powered by JetHome®