From: Rusty Russell <rusty@rustcorp.com.au>
To: Neil Brown <neilb@cse.unsw.edu.au>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Cc: Martin Diehl <lists@mdiehl.de>
Cc: Andrew Morton <akpm@digeo.com>
Subject: Re: [PATCH] Add module_kernel_thread for threads that live in modules.
Date: Tue, 17 Jun 2003 14:25:45 +1000 [thread overview]
Message-ID: <20030617043558.82FAD2C7B6@lists.samba.org> (raw)
In-Reply-To: Your message of "Tue, 17 Jun 2003 09:10:48 +1000." <16110.20088.351260.156860@gargle.gargle.HOWL>
In message <16110.20088.351260.156860@gargle.gargle.HOWL> you write:
> On Monday June 16, rusty@rustcorp.com.au wrote:
> > Hi Neil,
>
> Hi Rusty. Thanks for the comments... I probably should have Cc:ed you
> in the first place....
Yeah, that does tend to get faster response, but I know some hackers
consider it completely optional 8(
> > There are several problems with this patch. Ignoring the fact
> > that you use __module_get. Firstly, you bump the module count
> > permentantly while the thread is running: how does it ever get
> > unloaded? Secondly, modprobe becomes your parent.
>
> We seem to have very different views of the problem, as you seem to be
> calling into question aspects that I thought were obviously correct.
>
> __module_get:
> In all the cases I am interested in (nfsd, lockd,
> lockd-helper-thread), the thread is started by code running
> inside the module and so there will be a reference held on the
> module while the thread is being started, thus __module_get is the
> correct thing to do as "we know we already have a refcount"...
But do you wait for it? Theoretically the init code could have
finished, and someone done rmmod, before this thread gets as far as
__module_get, no?
> module count bumped permananelt while thread is running:
> well ofcourse, the thread runs code in the module which can only
> be done safely while we have a ref-count.
For future reference: this isn't quite true. If a function/thread is
synchronously stopped by the exit code/failed init code then they
don't need to hold a reference count: it still *can* hold a reference
count, which really depends on whether the module should be considered
"in use" by the thread... cf. timers.
> The threads I am thinking of aren't running "whenever the module is
> loaded". They are running "whenever their service is needed".
My bad: I wasn't sure given my (admittedly brief) glance at the code.
Thanks for clarifing!
> modprobe becomes your parent:
> No, modprobe has nothing to do with it in my case. rpc.nfsd, or
> mount_nfs or lockd might be the parent. I thought reparent_to_init
> handled all that. Apparently there are question marks over that
> which I wasn't aware of.
Andrew has been trying to kill it, and I think he's right. In
practical terms, it's much easier to start from a clean environment
than to clean up an unknown one, and keep that cleanup code uptodate.
> I don't want to have to call "cleanup_thread" or de-allocate the
> "struct kthread". I want to be able to SIGKILL a process and have it
> go away and release everything, including possibly the last refernce
> to the module.
>
> In short, it really feels like we are trying to solve different
> problems :-)
Agreed: threads under their own control are much simpler than ones
under external control.
> I will have a look at keventd and see if it's services can be of
> assistance to solve my problem.
I will think, which usually seems to help me when presented with new
information 8)
Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2003-06-17 4:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-16 6:50 [PATCH] Add module_kernel_thread for threads that live in modules Rusty Russell
2003-06-16 7:58 ` Martin Diehl
2003-06-16 8:09 ` Rusty Russell
2003-06-16 8:57 ` Martin Diehl
2003-06-16 9:22 ` Rusty Russell
2003-06-16 10:27 ` Martin Diehl
2003-06-17 1:11 ` Rusty Russell
2003-06-16 8:19 ` Andrew Morton
2003-06-16 23:10 ` Neil Brown
2003-06-17 4:25 ` Rusty Russell [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-06-05 2:30 NeilBrown
2003-06-05 14:50 ` Andrey Klochko
2003-06-07 5:33 ` Neil Brown
2003-06-09 16:20 ` Andrey Klochko
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=20030617043558.82FAD2C7B6@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@cse.unsw.edu.au \
--cc=torvalds@transmeta.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