lkml.org 
[lkml]   [2016]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 1/4] sched/fair: Fix attaching task sched avgs twice when switching to fair or changing task group
On Wed, Jun 15, 2016 at 05:22:17PM +0200, Peter Zijlstra wrote:
> On Wed, Jun 15, 2016 at 09:46:53AM +0200, Vincent Guittot wrote:
> > I still have concerned with this change of the behavior that attaches
> > the task only when it is enqueued. The load avg of the task will not
> > be decayed between the time we move it into its new group until its
> > enqueue. With this change, a task's load can stay high whereas it has
> > slept for the last couple of seconds. Then, its load and utilization
> > is no more accounted anywhere in the mean time just because we have
> > moved the task which will be enqueued on the same rq.
> > A task should always be attached to a cfs_rq and its load/utilization
> > should always be accounted on a cfs_rq and decayed for its sleep
> > period
>
> OK; so I think I agree with that.

Ok, I agree now. I think the following should fix (or sort out) the attach
twice problem Vincent discovered (SMP is needed, maybe move reset() into attach()).

static void task_move_group_fair(struct task_struct *p)
{
detach_task_cfs_rq(p);
set_task_rq(p, task_cpu(p));
attach_task_cfs_rq(p);
/*
* If the cfs_rq's last_update_time is 0, attach the sched avgs
* won't be anything useful, as it will be decayed to 0 when any
* sched_entity is enqueued to that cfs_rq.
*
* On the other hand, if the cfs_rq's last_update_time is 0, we
* must reset the task's last_update_time to ensure we will attach
* the sched avgs when the task is enqueued.
*/
if (!cfs_rq_of(&p->se)->avg.last_update_time)
reset_task_last_update_time(p);
else
attach_entity_load_avg(cfs_rq_of(&p->se), &p->se);
}

Vincent, could you please verify?

> Does the below (completely untested,
> hasn't even been near a compiler) look reasonable?

Goodness. But mine is also fired now. :)

\
 
 \ /
  Last update: 2016-06-16 11:41    [W:0.120 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site