From: Rusty Russell <rusty@rustcorp.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: keventd_create_kthread
Date: Thu, 19 Feb 2004 10:12:01 +1100 [thread overview]
Message-ID: <20040218231322.35EE92C05F@lists.samba.org> (raw)
In-Reply-To: Your message of "Wed, 18 Feb 2004 00:46:48 -0800." <20040218004648.7471bb37.akpm@osdl.org>
In message <20040218004648.7471bb37.akpm@osdl.org> you write:
> wait_task_inactive() will return due to the preemption?
>
> perhaps wait_task_inactive() should wait until the target task leaves state
> TASK_RUNNING.
That's not enough: it can set that and then get preemted. It really
want to return when the task is off the runqueue. The original
wait_task_inactive() does an incredible complicated and AFAICT useless
dance wrt not locking and disabling preempt explicitly. Ingo, how's
this replacement? (And who wrote this code?)
/*
* wait_task_inactive - wait for a thread to unschedule.
*
* The caller must ensure that the task *will* unschedule sometime soon,
* else this function might spin for a *long* time. This function can't
* be called with interrupts off, or it may introduce deadlock with
* smp_call_function() if an IPI is sent by the same process we are
* waiting to become inactive.
*/
void wait_task_inactive(task_t * p)
{
unsigned long flags;
runqueue_t *rq;
repeat:
rq = task_rq_lock(p, &flags);
/* Must be off runqueue entirely, not preempted. */
if (unlikely(p->array)) {
task_rq_unlock(rq, &flags);
cpu_relax();
/* If it's preempted: yield. It could be a while. */
if (!task_running(p))
yield();
goto repeat;
}
task_rq_unlock(rq, &flags);
}
Untested BTW.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next parent reply other threads:[~2004-02-18 23:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040218004648.7471bb37.akpm@osdl.org>
2004-02-18 23:12 ` Rusty Russell [this message]
2004-02-19 7:46 ` keventd_create_kthread Ingo Molnar
2004-02-19 8:10 ` keventd_create_kthread Andrew Morton
2004-02-19 8:16 ` keventd_create_kthread Ingo Molnar
2004-02-19 10:05 ` keventd_create_kthread Srivatsa Vaddagiri
2004-02-19 10:10 ` keventd_create_kthread Andrew Morton
2004-02-19 9:46 ` keventd_create_kthread Rusty Russell
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=20040218231322.35EE92C05F@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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®