From: "Dmitry Adamushko" <dmitry.adamushko@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Nick Piggin" <nickpiggin@yahoo.com.au>,
"Ingo Molnar" <mingo@elte.hu>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Rusty Russel" <rusty@rustcorp.com.au>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
"Andy Whitcroft" <apw@shadowen.org>,
"Peter Zijlstra" <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH, RFC] kthread: (possibly) a missing memory barrier in kthread_stop()
Date: Tue, 19 Feb 2008 14:41:52 +0100 [thread overview]
Message-ID: <b647ffbd0802190541k1428623fv23f000642c75d43b@mail.gmail.com> (raw)
In-Reply-To: <1203413060.10858.82.camel@lappy>
btw.,
(a bit more of 'nit-picking' :-)
to work properly, kthread_stop() should also impose one of the
following requirements on a 'kthread' loop:
- a loop can be interrupted _only_ as a result of
'kthread_should_stop() == true'
and no concurrent kthread_stop() calls are possible;
or
- if it can exit due to another reason, a user has to use additional
synchronization means to make sure than kthread_stop() is never
called/running after a main loop has finished (makes sense as 'struct
task_struct *' can be 'obsolete')
otherwise,
note, the comment in kthread() that says "It might have exited on its
own, w/o kthread_stop. Check."
so let's suppose a 'kthread' is really "exiting on its own" and at the
same time, kthread_stop() is running on another CPU... as a result, we
may end up with kthread_stop() being blocked on
wait_for_completion(&kthread_stop_info.done) without anybody to call
complete().
Although, the requirements above don't seem to be so insane in this case.
static int kthread(void *_create)
{
...
if (!kthread_should_stop())
ret = threadfn(data); <---- our main loop is
inside this function
/* It might have exited on its own, w/o kthread_stop. Check. */
if (kthread_should_stop()) {
kthread_stop_info.err = ret;
complete(&kthread_stop_info.done);
}
return 0;
}
--
Best regards,
Dmitry Adamushko
next prev parent reply other threads:[~2008-02-19 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 23:03 [PATCH, RFC] kthread: (possibly) a missing memory barrier in kthread_stop() Dmitry Adamushko
2008-02-19 6:44 ` Nick Piggin
2008-02-19 9:24 ` Peter Zijlstra
2008-02-19 9:53 ` Dmitry Adamushko
2008-02-19 13:41 ` Dmitry Adamushko [this message]
2008-02-19 22:52 ` Dmitry Adamushko
2008-02-19 13:00 ` Andy Whitcroft
2008-02-19 13:11 ` Dmitry Adamushko
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=b647ffbd0802190541k1428623fv23f000642c75d43b@mail.gmail.com \
--to=dmitry.adamushko@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=apw@shadowen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=nickpiggin@yahoo.com.au \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
/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