lkml.org 
[lkml]   [2016]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] sched,fair: Fix PELT integrity for new tasks
On Fri, Jun 17, 2016 at 02:01:40PM +0200, Peter Zijlstra wrote:
> @@ -8219,6 +8254,19 @@ static int cpu_cgroup_can_attach(struct
> if (task->sched_class != &fair_sched_class)
> return -EINVAL;
> #endif
> + /*
> + * Serialize against wake_up_new_task() such
> + * that if its running, we're sure to observe
> + * its full state.
> + */
> + raw_spin_unlock_wait(&task->pi_lock);
> + /*
> + * Avoid calling sched_move_task() before wake_up_new_task()
> + * has happened. This would lead to problems with PELT. See
> + * XXX.
> + */
> + if (task->state == TASK_NEW)
> + return -EINVAL;
> }
> return 0;
> }

So I think that's backwards; we want:

if (task->state == TASK_NEW)
return -EINVAL;
raw_spin_unlock_wait(&task->pi_lock);

Because failing the attach is 'safe', but if we do not observe NEW we
must be absolutely sure to observe the full wakeup_new.

But since its not critical I'll change it to more obvious code:

raw_spin_lock_irq(&task->pi_lock);
if (task->state == TASK_NEW)
ret = -EINVAL;
raw_spin_unlock_irq(&task->pi_lock);

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