From: Corey Minyard <minyard@acm.org>
To: Keith Owens <kaos@ocs.com.au>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: Registering for notifier chains in modules (was Linux 2.4.21-rc3 - ipmi unresolved)
Date: Mon, 26 May 2003 23:45:39 -0500 [thread overview]
Message-ID: <3ED2ED73.7090300@acm.org> (raw)
In-Reply-To: <18292.1054004949@kao2.melbourne.sgi.com>
Keith Owens wrote:
>On Mon, 26 May 2003 19:30:04 -0500,
>Corey Minyard <minyard@acm.org> wrote:
>
>
>>Keith Owens wrote:
>>
>>
>>>I considered making notifier_chain_register() a macro which called
>>>notifier_chain_register_module() with __THIS_MODULE, but that assumes
>>>that all calls to notifier_chain_register() are local, i.e. from the
>>>top level functions. Alas there are any service routines that call
>>>notifier_chain_register() on behalf of their caller, so the macro
>>>approach will result in the wrong value for __THIS_MODULE.
>>>
>>>
>>>
>>Why can't you have a module id in the notifier chain, and use a boolean
>>to tell if it is set, or something similar to that? That way you could
>>mix them, if the bool is set then do the try_in_module_count thing, if
>>not then just call the function. It does add some components to the
>>register structure, but that shouldn't hurt anything besides taking a
>>little more memory.
>>
>>
>
>It is a change of API in a 2.4 kernel. Not a good idea.
>
Does adding a field to a structure (where the user does not have to do
anything with the
field) change the API? That would be the only API change here.
>
>
>
>>>notifier_chain_unregister() is not a problem, that is a downcall from
>>>the module into the kernel when the module is going away, downcalls are
>>>"always" safe. The race is a module that has started to unload, and
>>>another cpu (or even the same cpu under some circumstances) runs the
>>>notifier chain, doing an upcall from the kernel into a module without
>>>locking or refcounts. Given the right timing, the notifier code could
>>>even branch to a module that has been completely removed. Note that
>>>notifier_call_chain() has no locking, so it is also racy against
>>>notifier_chain_unregister().
>>>
>>>
>>>
>>>
>>You don't understand how the RCU code works.
>>
>>
>
>(a) I understand how RCU works, I was working on lock free code for
> years before RCU appeared in the kernel.
>
Then maybe I don't understand it. The writers of the RCU code pointed
it out to me
for a very similar situation. Why doesn't calling synchronize_kernel() in
notifier_chain_unregister() fix the module unload and unregister races?
Or perhaps not all notifier chains get called when the kernel is
unpreemptable?
You could turn preempt off in notifier_call_chain(), though that might have
some bad effects. In the preemptable kernel case, I'm not sure if the RCU
code waits until all threads of execution leave the kernel. If it does,
then
preemption shouldn't even matter.
>
>(b) This is 2.4, not 2.5, there is no RCU.
>
>
Understood (I already said this). But I was thinking it might be a good
addition to 2.5,
if it solved the problem.
-Corey
next prev parent reply other threads:[~2003-05-27 4:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-22 22:19 Linux 2.4.21-rc3 Marcelo Tosatti
2003-05-22 23:46 ` J.A. Magallon
2003-05-26 17:04 ` Alan Cox
2003-05-23 0:51 ` Barry K. Nathan
2003-05-23 5:32 ` Marc-Christian Petersen
2003-05-23 7:04 ` [BUG] 2.[45] ioperm fix seems broken (was Re: Linux 2.4.21-rc3) Barry K. Nathan
2003-05-23 9:00 ` Barry K. Nathan
2003-05-23 8:27 ` Linux 2.4.21-rc3 Benjamin Herrenschmidt
2003-05-23 13:38 ` Linux 2.4.21-rc3 - ipmi unresolved Eyal Lebedinsky
2003-05-23 13:41 ` Marc-Christian Petersen
2003-05-26 2:09 ` Corey Minyard
2003-05-25 7:57 ` Keith Owens
2003-05-26 3:37 ` Corey Minyard
2003-05-26 3:54 ` Keith Owens
2003-05-27 0:30 ` Corey Minyard
2003-05-27 3:09 ` Keith Owens
2003-05-27 4:45 ` Corey Minyard [this message]
2003-05-27 5:30 ` Registering for notifier chains in modules (was Linux 2.4.21-rc3 - ipmi unresolved) Keith Owens
2003-05-27 14:48 ` Corey Minyard
2003-05-27 16:02 ` viro
2003-05-27 17:09 ` Corey Minyard
2003-05-28 0:15 ` Keith Owens
2003-05-26 17:08 ` Linux 2.4.21-rc3 - ipmi unresolved Alan Cox
2003-05-23 21:10 ` Linux 2.4.21-rc3 [net-pf-4, devfs audio, drm radeon] Gabor Z. Papp
2003-05-25 17:36 ` Linux 2.4.21-rc3 : IDE pb on Alpha Willy Tarreau
2003-05-25 17:00 ` Willy Tarreau
2003-05-25 20:37 ` Mike Fedyk
2003-05-25 20:45 ` Bartlomiej Zolnierkiewicz
2003-05-25 20:55 ` Mike Fedyk
2003-05-25 21:23 ` Bartlomiej Zolnierkiewicz
2003-05-26 7:28 ` Linux 2.4.21-rc3: doesn't build with CONFIG_BLK_DEV_HD_ONLY=y Jerome Chantelauze
2003-05-26 13:16 ` Linux 2.4.21-rc3 Santiago Garcia Mantinan
2003-05-27 1:14 ` Jeff Chua
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=3ED2ED73.7090300@acm.org \
--to=minyard@acm.org \
--cc=kaos@ocs.com.au \
--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