From: Rusty Russell <rusty@rustcorp.com.au>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Make kthread_stop() not oops when passed a bad pointer
Date: Wed, 6 Aug 2008 11:22:58 +1000 [thread overview]
Message-ID: <200808061122.59584.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20080805135559.GQ26461@parisc-linux.org>
On Tuesday 05 August 2008 23:55:59 Matthew Wilcox wrote:
> Make kthread_stop a little more robust against numbskulls
> like me.
>
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Hi Willy,
I really do sympathize with your problem; but the quest is to figure out how
to identify it before the code is run, not to put a non-orthogonal bandaid
here which can hurt other cases.
How about a more ambitious "we've oopsed so break a mutex every 30 seconds of
waiting" patch?
> + if (!k || IS_ERR(k))
> + return -EINVAL;
1) There's no reason that kthread_stop is uniquely difficult to use. Why pick
on that one?
2) I know that kfree() handles NULL, but kthread_create/kthread_run never
return NULL, unlike kmalloc().
3) If we really want to pass a failed kthread_create() through kthread_stop(),
we should return PTR_ERR(k) here. But that should only be done if it made it
harder for the callers to screw up, which I don't think it does.
4) After a successful kthread_run(), kthread_stop() will always return the
value from the threadfn callback. ie. kthread_stop() doesn't ever fail. A
simple semantic, which this patch breaks.
5) Covering up programmer errors is not good policy. I dislike WARN_ON()
because an oops is much harder to miss. Painful for you, but The System
Works.
Sorry,
Rusty.
next prev parent reply other threads:[~2008-08-06 6:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 13:55 [PATCH] Make kthread_stop() not oops when passed a bad pointer Matthew Wilcox
2008-08-05 15:57 ` Stefan Richter
2008-08-05 16:22 ` Andrew Morton
2008-08-06 5:42 ` [PATCH][migration] Trivial cleanup MinChan Kim
2008-08-06 14:25 ` Christoph Lameter
2008-08-06 1:22 ` Rusty Russell [this message]
2008-08-06 12:07 ` [PATCH] Make kthread_stop() not oops when passed a bad pointer Matthew Wilcox
2008-08-06 20:48 ` Rusty Russell
2008-08-08 20:50 ` Matthew Wilcox
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=200808061122.59584.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=torvalds@osdl.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