public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Yuyang Du <yuyang.du@intel.com>
Cc: byungchul.park@lge.com, mingo@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/5] sched: sync a se with its cfs_rq when switching sched class to fair class
Date: Thu, 20 Aug 2015 23:13:23 +0200	[thread overview]
Message-ID: <20150820211323.GD3161@worktop.event.rightround.com> (raw)
In-Reply-To: <20150819201106.GA27777@intel.com>

On Thu, Aug 20, 2015 at 04:11:06AM +0800, Yuyang Du wrote:
> On Wed, Aug 19, 2015 at 07:12:41PM +0200, Peter Zijlstra wrote:
> > On Wed, Aug 19, 2015 at 03:47:15PM +0900, byungchul.park@lge.com wrote:
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index 1be042a..3419f6c 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -2711,6 +2711,17 @@ static inline void update_load_avg(struct sched_entity *se, int update_tg)
> > >  
> > >  static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
> > >  {
> > > +	/*
> > > +	 * in case of migration and cgroup-change, more care should be taken
> > > +	 * because se's cfs_rq was changed, that means calling __update_load_avg
> > > +	 * with new cfs_rq->avg.last_update_time is meaningless. so we skip the
> > > +	 * update here. we have to update it with prev cfs_rq just before changing
> > > +	 * se's cfs_rq, and get here soon.
> > > +	 */
> > > +	if (se->avg.last_update_time)
> > > +		__update_load_avg(cfs_rq->avg.last_update_time, cpu_of(rq_of(cfs_rq)),
> > > +				&se->avg, 0, 0, NULL);
> > > +
> > >  	se->avg.last_update_time = cfs_rq->avg.last_update_time;
> > >  	cfs_rq->avg.load_avg += se->avg.load_avg;
> > >  	cfs_rq->avg.load_sum += se->avg.load_sum;
> > 
> > you seem to have forgotten to remove the same logic from
> > enqueue_entity_load_avg(), which will now call __update_load_avg()
> > twice.
> 
> In case of enqueue_entity_load_avg(), that seems to be ok.
> 
> However, the problem is that he made it "entangled":
> 
> In enqueue_entity_load_avg():
> 
> 	if (migrated)
> 		attach_entity_load_avg();
> 
> while in attach_entity_load_avg():
> 
> 	if (!migrated)
> 		__update_load_avg();
> 
> so, if attach() is called from enqueue(), that if() is never true.

Right, I noticed the same yesterday when I took a second look at that
stuff. It was a little confusing indeed.

  parent reply	other threads:[~2015-08-20 21:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  6:47 [PATCH v3 0/5] sync a se with its cfs_rq when att(det)aching it byungchul.park
2015-08-19  6:47 ` [PATCH v3 1/5] sched: add two functions adjusting cfs_rq's load when att(det)aching a se byungchul.park
2015-08-19  6:47 ` [PATCH v3 2/5] sched: make task_move_group_fair adjust cfs_rq's load in case of queued byungchul.park
2015-08-19  6:47 ` [PATCH v3 3/5] sched: sync a se with prev cfs_rq when changing cgroup byungchul.park
2015-08-19  6:47 ` [PATCH v3 4/5] sched: sync a se with its cfs_rq when switching sched class to fair class byungchul.park
2015-08-19 17:12   ` Peter Zijlstra
2015-08-19 20:11     ` Yuyang Du
2015-08-20  6:12       ` Byungchul Park
2015-08-20 21:13       ` Peter Zijlstra [this message]
2015-08-20 23:56         ` Byungchul Park
2015-08-20  5:23     ` Byungchul Park
2015-08-19  6:47 ` [PATCH v3 5/5] sched: add two functions for att(det)aching a task to(from) a cfs_rq byungchul.park
2015-08-19  6:59 ` [PATCH v3 0/5] sync a se with its cfs_rq when att(det)aching it Byungchul Park
2015-08-20  1:17 ` Peter Zijlstra
2015-08-20  5:26   ` Byungchul Park
2015-08-20  8:38   ` Byungchul Park
2015-08-20 10:46     ` Byungchul Park
2015-08-20 21:11       ` Peter Zijlstra
2015-08-21  0:01         ` Byungchul Park

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=20150820211323.GD3161@worktop.event.rightround.com \
    --to=peterz@infradead.org \
    --cc=byungchul.park@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=yuyang.du@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