lkml.org 
[lkml]   [2009]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Should we use preempt_disable() in sleep_on_common()?
From
2009/12/3 liu pf <kernelfans@gmail.com>:
> Hi:
>
> I am puzzled with the following scenario. Could anyone enlighten me?
>
> Thanks
> pfliu
>
>
> static long __sched
> sleep_on_common(wait_queue_head_t *q, int state, long timeout)
> {
> unsigned long flags;
> wait_queue_t wait;
>
> init_waitqueue_entry(&wait, current);
>
> __set_current_state(state);
>
> ==========>suppose that after task A set state=TASK_INTERRUPTIBLE
> , it is preempted by task B.
>
> spin_lock_irqsave(&q->lock, flags);
> ...............................................................
> }
>
> asmlinkage void __sched schedule(void)
> {
> .......................................................................................................
> if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> if (unlikely(signal_pending_state(prev->state, prev)))
> prev->state = TASK_RUNNING;
> else
> deactivate_task(rq, prev, 1);
> =============>This will remove task A from rq, but there are no
> wait queue referring to A, so we lose A.
> switch_count = &prev->nvcsw;
> }

In this case, (preempt_count() & PREEMPT_ACTIVE) == 1(see
preempt_schedule_irq() and other use-cases of PREEMPT_ACTIVE) so we
don't enter this block.

i.e. a preempted task stays on its queue (with state != TASK_RUNNING
but that doesn't really matter).


-- Dmitry


\
 
 \ /
  Last update: 2009-12-03 08:59    [W:0.058 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site