lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <563a732e0912030001p11a9388o5efd836912e0cad9@mail.gmail.com>
Date:	Thu, 3 Dec 2009 16:01:38 +0800
From:	liu pf <kernelfans@...il.com>
To:	Dmitry Adamushko <dmitry.adamushko@...il.com>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Should we use preempt_disable() in sleep_on_common()?

On Thu, Dec 3, 2009 at 3:57 PM, Dmitry Adamushko
<dmitry.adamushko@...il.com> wrote:
> 2009/12/3 liu pf <kernelfans@...il.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
>


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ