linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Byungchul Park <byungchul.park@lge.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, yuyang.du@intel.com
Subject: Re: [PATCH] sched: sync with the cfs_rq when changing sched class
Date: Thu, 13 Aug 2015 17:21:27 +0900	[thread overview]
Message-ID: <20150813082127.GO3956@byungchulpark-X58A-UD3R> (raw)
In-Reply-To: <20150813074600.GB16853@twins.programming.kicks-ass.net>

On Thu, Aug 13, 2015 at 09:46:00AM +0200, Peter Zijlstra wrote:
> On Thu, Aug 13, 2015 at 02:55:55PM +0900, byungchul.park@lge.com wrote:
> > @@ -8023,16 +8036,7 @@ static void task_move_group_fair(struct task_struct *p, int queued)
> >  
> >  #ifdef CONFIG_SMP
> >  	/* synchronize task with its prev cfs_rq */
> > -	if (!queued)
> > -		__update_load_avg(cfs_rq->avg.last_update_time, cpu_of(rq_of(cfs_rq)),
> > -				&se->avg, se->on_rq * scale_load_down(se->load.weight),
> > -				cfs_rq->curr == se, NULL);
> > -
> > -	/* remove our load when we leave */
> > -	cfs_rq->avg.load_avg = max_t(long, cfs_rq->avg.load_avg - se->avg.load_avg, 0);
> > -	cfs_rq->avg.load_sum = max_t(s64, cfs_rq->avg.load_sum - se->avg.load_sum, 0);
> > -	cfs_rq->avg.util_avg = max_t(long, cfs_rq->avg.util_avg - se->avg.util_avg, 0);
> > -	cfs_rq->avg.util_sum = max_t(s32, cfs_rq->avg.util_sum - se->avg.util_sum, 0);
> > +	detach_entity_load_avg(cfs_rq, se);
> >  #endif
> >  	set_task_rq(p, task_cpu(p));
> >  	se->depth = se->parent ? se->parent->depth + 1 : 0;
> > @@ -8042,11 +8046,7 @@ static void task_move_group_fair(struct task_struct *p, int queued)
> >  
> >  #ifdef CONFIG_SMP
> >  	/* Virtually synchronize task with its new cfs_rq */
> > -	p->se.avg.last_update_time = cfs_rq->avg.last_update_time;
> > -	cfs_rq->avg.load_avg += p->se.avg.load_avg;
> > -	cfs_rq->avg.load_sum += p->se.avg.load_sum;
> > -	cfs_rq->avg.util_avg += p->se.avg.util_avg;
> > -	cfs_rq->avg.util_sum += p->se.avg.util_sum;
> > +	attach_entity_load_avg(cfs_rq, se);
> >  #endif
> >  }
> 
> Can't we go one further and do:
> 
> static void task_move_group_fair(struct task_struct *p)
> {
> 	struct rq *rq = task_rq(p);
> 
> 	switched_from_fair(rq, p);
> 	set_task_rq(p, task_cpu(p);
> 	switched_to_fair(rq, p);
> }

it looks nice, but i will think more..

> 
> switched_from already does the vruntime and load_avg thing,
> switched_to should do the reverse, although it currently doesn't appear
> to put the load_avg back.

yuyang said that switched_to don't need to consider task's load because it
can have meaningless value. but i think considering task's load is better
than leaving it unattended at all. and we can also use switched_to if we 
consider task's load in switched_to.

thanks,
byungchul

> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2015-08-13  8:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13  5:55 [PATCH] sched: sync with the cfs_rq when changing sched class byungchul.park
2015-08-12 22:41 ` Yuyang Du
2015-08-13  7:19   ` Byungchul Park
2015-08-13  2:30     ` Yuyang Du
2015-08-13  7:46 ` Peter Zijlstra
2015-08-13  8:21   ` Byungchul Park [this message]
2015-08-13  2:15     ` Yuyang Du
2015-08-13 10:56       ` Byungchul Park
2015-08-13 15:22       ` Peter Zijlstra
2015-08-13 23:20         ` Yuyang Du
2015-08-14  8:46           ` Peter Zijlstra
2015-08-15  6:52         ` Byungchul Park
2015-08-15  7:16           ` Byungchul Park
2015-08-13  8:42   ` Byungchul Park
2015-08-14 12:59 ` T. Zhou
2015-08-15  4:24   ` Byungchul Park
2015-08-15 12:34     ` T. Zhou

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=20150813082127.GO3956@byungchulpark-X58A-UD3R \
    --to=byungchul.park@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).