lkml.org 
[lkml]   [2010]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 5/5] sched: Reduce ttwu rq->lock contention
On Sat, Dec 18, 2010 at 09:08:50PM +0100, Oleg Nesterov wrote:
> On 12/18, Yong Zhang wrote:
> >
> > On Sat, Dec 18, 2010 at 2:15 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > static int
> > > try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> > > {
> > > ? ? ? ?unsigned long flags;
> > > ? ? ? ?int cpu, ret = 0;
> > >
> > > ? ? ? ?smp_wmb();
> > > ? ? ? ?raw_spin_lock_irqsave(&p->pi_lock, flags);
> > >
> > > ? ? ? ?if (!(p->state & state))
> > > ? ? ? ? ? ? ? ?goto unlock;
> > >
> > > ? ? ? ?ret = 1; /* we qualify as a proper wakeup now */
> >
> > Could below happen in this __window__?
> >
> > p is going through wake_event
>
> I don't think this can happen with wait_event/wake_up/etc,
> wait_queue_head_t->lock adds the necessary synchronization.

Actually I don't take different sight into wait_event/wake_up
and sleep/wake_up_process, beause nothing prevent the user
from using wake_up_process on an added-to-wait_queue sleeper
though we know that it's not recommended.

And you're right wait_queue_head_t->lock privide necessary
synchronization with wait_event/wake_up.

>
> But, in general,
>
> > and it first set TASK_UNINTERRUPTIBLE,
> > then waker see that and above if (!(p->state & state)) passed.
> > But at this time condition == true for p, and p return to run and
> > intend to sleep:
> > p->state == XXX;
> > sleep;
> >
> > then we could wake up a process which has wrong state, no?
>
> I think this is possible, and this is possible whatever we do.
> Afaics, this patch changes nothing in this sense. Consider:
>
> set_current_state(TASK_INTERRUPTIBLE);
>
> set_current_state(TASK_UNINTERRUPTIBLE);
> schedule();
>
> wake_up_state(TASK_INTERRUPTIBLE) in between can in fact wakeup
> this task in TASK_UNINTERRUPTIBLE state.

Hmmm, yeah. I missed that.

>
> I do not think this is the problem. The user of wake_up_process()
> should take care and write the correct code ;)

Fair enough ;)

> And in any case,
> any wait-event-like code should handle the spurious wakeups
> correctly.

Yup.

Thanks,
Yong


\
 
 \ /
  Last update: 2010-12-19 12:23    [W:0.124 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site