From: liu pf <kernelfans@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Should we use preempt_disable() in sleep_on_common()?
Date: Thu, 3 Dec 2009 14:49:14 +0800 [thread overview]
Message-ID: <563a732e0912022249y1e831c6cv7f2d5d376b8a5f63@mail.gmail.com> (raw)
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;
}
..................................................................................................
}
next reply other threads:[~2009-12-03 6:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-03 6:49 liu pf [this message]
2009-12-03 7:07 ` Arjan van de Ven
2009-12-03 7:12 ` Dmitry Torokhov
2009-12-03 7:15 ` Dmitry Torokhov
2009-12-03 8:15 ` liu pf
2009-12-03 8:22 ` Dmitry Torokhov
2009-12-03 8:53 ` liu pf
2009-12-03 7:57 ` Dmitry Adamushko
2009-12-03 8:01 ` liu pf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=563a732e0912022249y1e831c6cv7f2d5d376b8a5f63@mail.gmail.com \
--to=kernelfans@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®