Module Ref Counting & ibmphp
Before (in 2.6.16-rc*):
$ egrep 'ibmphp' /proc/modules
ibmphp 67809 4294967295 - Live 0xf8910000
^^^^^^^^^^After [1]:
ibmphp 64224 0 - Live 0xf8965000
^
Of course, now I'm able to successfully unload ibmphp (& subsequently load it too :)) without any observeable problems.
It'd seem, thro struct hotplug_slot_ops, module ref count for ibmphp is taken care of. No?
Correct me, if I'm completely wrong here. Perhaps, there may be a better way to address this that I'm unaware of. If so, enlighten me.
I'm afraid I've no hardware to verify whether the patch introduces any regressions.
Thanks
[1]
--- 2.6.16-rc6/drivers/pci/hotplug/ibmphp_core.c.orig
2006-03-15 03:37:38.000000000 +1100 +++ 2.6.16-rc6/drivers/pci/hotplug/ibmphp_core.c 2006-03-14 16:57:26.000000000 +1100
@@ -1398,10 +1398,6 @@
goto error;
}
- /* lock ourselves into memory with a module
- * count of -1 so that no one can unload us. */
- module_put(THIS_MODULE);
-
exit:
return rc;
____________________________________________________
On Yahoo!7
Answers: Real people ask and answer questions on any topic.
http://www.yahoo7.com.au/answers.
Quoted 7 lines · Srihari Vijayaraghavan
Before (in 2.6.16-rc*):
$ egrep 'ibmphp' /proc/modules ibmphp 67809 4294967295 - Live 0xf8910000 ^^^^^^^^^^After [1]:
ibmphp 64224 0 - Live0xf8965000
Quoted 8 lines
^Of course, now I'm able to successfully unload ibmphp (& subsequently load it too :)) without any observeable problems.
It'd seem, thro struct
hotplug_slot_ops, module ref count for ibmphp is taken care of. No?
No. I don't think this driver likes to be unloaded due to the instability of the hardware if that happens. So let's just let it not be unloaded, and hope that the hardware can die in peace and never get put into any new machines...
thanks,
greg k-h
Quoted 17 lines · On Tue, 14 Mar 2006 16:02:12 -0800 Greg KH <[email protected]> wrote:
Quoted 7 lines · Srihari Vijayaraghavan
Before (in 2.6.16-rc*):
$ egrep 'ibmphp' /proc/modules ibmphp 67809 4294967295 - Live 0xf8910000 ^^^^^^^^^^After [1]:
ibmphp 64224 0 - Live0xf8965000Quoted 8 lines
^Of course, now I'm able to successfully unload ibmphp (& subsequently load it too :)) without any observeable problems.
It'd seem, thro struct
hotplug_slot_ops, module ref count for ibmphp is taken care of. No?
Quoted 8 lines
No. I don't think this driver likes to be unloaded due to the instability of the hardware if that happens. So let's just let it not be unloaded, and hope that the hardware can die in peace and never get put into any new machines...
thanks,
greg k-h
The proper way to prevent unloading is just not to have a module exit routine, rather than causing ref count to be off. The the module subsystem will mark it as unsafe to unload. Unless it wants to allow unsafe forced unload. But IMHO either it needs to be safe to unload or not allow it.
drivers/pci/hotplug/ibmphp_core.c renamed from drivers/pci/hotplug/ibmphp_core.c.orig +0 -14
@@ -1398,10 +1398,6 @@ static int __init ibmphp_init(void) goto error; } -/* lock ourselves into memory with a module -* count of -1 so that no one can unload us. */ -module_put (THIS_MODULE ); - exit:return rc;
@@ -1409,14 +1405,4 @@ error:ibmphp_unload (); goto exit; } - -static void __exit ibmphp_exit(void) -{ -ibmphp_hpc_stop_poll_thread (); -debug ("after polling\n" ); -ibmphp_unload (); -debug ("done\n" ); -} -module_init (ibmphp_init); -module_exit (ibmphp_exit);
Quoted 4 lines · Stephen Hemminger
The proper way to prevent unloading is just not to have a module exit routine, rather than causing ref count to be off. The the module subsystem will mark it as unsafe to unload. Unless it wants to allow unsafe forced unload. But IMHO either it needs to be safe to unload or not allow it.
Maybe add a comment where module_exit was, saying that the hardware can't be made to behave without the module, so people don't think that debugging the module could make it safely unloadable?
-Daniel
*This .sig left intentionally blank*
PATCH 1/1 disallow unloading of ibmphp
In reply to Stephen HemmingerQuoted 27 lines · Stephen Hemminger
Quoted 24 lines · On Tue, 14 Mar 2006 16:02:12 -0800 Greg KH <[email protected]> wrote:
Quoted 7 lines · Srihari Vijayaraghavan
Before (in 2.6.16-rc*):
$ egrep 'ibmphp' /proc/modules ibmphp 67809 4294967295 - Live 0xf8910000 ^^^^^^^^^^After [1]:
ibmphp 64224 0 - Live0xf8965000Quoted 8 lines
^Of course, now I'm able to successfully unload ibmphp (& subsequently load it too :)) without any observeable problems.
It'd seem, thro struct
hotplug_slot_ops, module ref count for ibmphp is taken care of. No?No. I don't think this driver likes to be unloaded due to the instability of the hardware if that happens. So let's just let it not be unloaded, and hope that the hardware can die in peace and never get put into any new machines...
thanks,
Quoted 7 lines
Quoted 1 line
greg k-h
The proper way to prevent unloading is just not to have a module exit routine, rather than causing ref count to be off. The the module subsystem will mark it as unsafe to unload. Unless it wants to allow unsafe forced unload. But IMHO either it needs to be safe to unload or not allow it.
...
What about the patch below that also adds a comment and removes some more code?
I'll send a "diff -uwp" for better readability of the ibmphp_hpc.c changes in a reply.
<-- snip -->
The ibmphp driver shouldn't be unloaded.
This patch replaces the module_exit() with a comment why it shouldn't happen and removes some now no longer needed code.
---
drivers/pci/hotplug/ibmphp.h | 1 drivers/pci/hotplug/ibmphp_core.c | 24 +--- drivers/pci/hotplug/ibmphp_hpc.c | 178 +++++++++++------------------- 3 files changed, 76 insertions(+), 127 deletions(-)
drivers/pci/hotplug/ibmphp_core.c renamed from drivers/pci/hotplug/ibmphp_core.c.old +9 -15
@@ -736,7 +736,7 @@ static struct pci_func *ibm_slot_find(u8* the pointers to pci_func, bus, hotplug_slot, controller, * and deregistering from the hotplug core *************************************************************/ -static void free_slots (void ) +static __init void free_slots (void ) {struct slot *slot_cur;struct list_head * tmp;
@@ -1328,7 +1328,7 @@ struct hotplug_slot_ops ibmphp_hotplug_s*/ }; -static void ibmphp_unload (void ) +static void __init ibmphp_unload (void ) {free_slots ();debug ("after slots\n" );
@@ -1398,10 +1398,6 @@ static int __init ibmphp_init(void) goto error; } -/* lock ourselves into memory with a module -* count of -1 so that no one can unload us. */ -module_put (THIS_MODULE ); - exit:return rc;
@@ -1410,13 +1406,11 @@ error: goto exit; } -static void __exit ibmphp_exit(void) -{ -ibmphp_hpc_stop_poll_thread (); -debug ("after polling\n" ); -ibmphp_unload (); -debug ("done\n" ); -} -module_init (ibmphp_init); -module_exit (ibmphp_exit); + +/* Greg KH <[email protected]>: +* I don't think this driver likes to be unloaded due to the +* instability of the hardware if that happens. So let's just let it not +* be unloaded, and hope that the hardware can die in peace and never get +* put into any new machines... +*/
drivers/pci/hotplug/ibmphp.h renamed from drivers/pci/hotplug/ibmphp.h.old +0 -1
@@ -398,7 +398,6 @@ extern int ibmphp_hpc_writeslot (structextern void ibmphp_lock_operations (void );extern void ibmphp_unlock_operations (void );extern int ibmphp_hpc_start_poll_thread (void ); -extern void ibmphp_hpc_stop_poll_thread (void );//----------------------------------------------------------------------------
drivers/pci/hotplug/ibmphp_hpc.c renamed from drivers/pci/hotplug/ibmphp_hpc.c.old +67 -111
212 lines not on this page · raw message
Re: [2.6 patch] disallow unloading of ibmphp
Quoted 37 lines · Adrian Bunk
Quoted 27 lines · Stephen Hemminger
Quoted 24 lines · On Tue, 14 Mar 2006 16:02:12 -0800 Greg KH <[email protected]> wrote:
Quoted 7 lines · Srihari Vijayaraghavan
Before (in 2.6.16-rc*):
$ egrep 'ibmphp' /proc/modules ibmphp 67809 4294967295 - Live 0xf8910000 ^^^^^^^^^^After [1]:
ibmphp 64224 0 - Live0xf8965000Quoted 8 lines
^Of course, now I'm able to successfully unload ibmphp (& subsequently load it too :)) without any observeable problems.
It'd seem, thro struct
hotplug_slot_ops, module ref count for ibmphp is taken care of. No?No. I don't think this driver likes to be unloaded due to the instability of the hardware if that happens. So let's just let it not be unloaded, and hope that the hardware can die in peace and never get put into any new machines...
thanks,
Quoted 7 lines
Quoted 1 line
greg k-h
The proper way to prevent unloading is just not to have a module exit routine, rather than causing ref count to be off. The the module subsystem will mark it as unsafe to unload. Unless it wants to allow unsafe forced unload. But IMHO either it needs to be safe to unload or not allow it.
...
Quoted 5 lines
What about the patch below that also adds a comment and removes some more code?
I'll send a "diff -uwp" for better readability of the
ibmphp_hpc.cchanges in a reply.
It's below.
cu
Adrian
drivers/pci/hotplug/ibmphp_core.c renamed from drivers/pci/hotplug/ibmphp_core.c.old +9 -15
@@ -736,7 +736,7 @@ static struct pci_func *ibm_slot_find(u8* the pointers to pci_func, bus, hotplug_slot, controller, * and deregistering from the hotplug core *************************************************************/ -static void free_slots (void ) +static __init void free_slots (void ) {struct slot *slot_cur;struct list_head * tmp;
@@ -1328,7 +1328,7 @@ struct hotplug_slot_ops ibmphp_hotplug_s*/ }; -static void ibmphp_unload (void ) +static void __init ibmphp_unload (void ) {free_slots ();debug ("after slots\n" );
@@ -1398,10 +1398,6 @@ static int __init ibmphp_init(void) goto error; } -/* lock ourselves into memory with a module -* count of -1 so that no one can unload us. */ -module_put (THIS_MODULE ); - exit:return rc;
@@ -1410,13 +1406,11 @@ error: goto exit; } -static void __exit ibmphp_exit(void) -{ -ibmphp_hpc_stop_poll_thread (); -debug ("after polling\n" ); -ibmphp_unload (); -debug ("done\n" ); -} -module_init (ibmphp_init); -module_exit (ibmphp_exit); + +/* Greg KH <[email protected]>: +* I don't think this driver likes to be unloaded due to the +* instability of the hardware if that happens. So let's just let it not +* be unloaded, and hope that the hardware can die in peace and never get +* put into any new machines... +*/
drivers/pci/hotplug/ibmphp.h renamed from drivers/pci/hotplug/ibmphp.h.old +0 -1
@@ -398,7 +398,6 @@ extern int ibmphp_hpc_writeslot (structextern void ibmphp_lock_operations (void );extern void ibmphp_unlock_operations (void );extern int ibmphp_hpc_start_poll_thread (void ); -extern void ibmphp_hpc_stop_poll_thread (void );//----------------------------------------------------------------------------
drivers/pci/hotplug/ibmphp_hpc.c renamed from drivers/pci/hotplug/ibmphp_hpc.c.old +0 -44
85 lines not on this page · raw message
Quoted 8 lines · --- Greg KH
[...]
No. I don't think this driver likes to be unloaded due to the
instability of the hardware if that happens. So let's just let it not
be unloaded, and hope that the hardware can die in peace and never get
put into any new machines...
Fair enough & thanks for the explanation.
I've quickly tested Stephen's patch, which does the trick (no more 4.3 billion usages :)).
Note to Stephen: Pls don't remove people in the cc list. I almost missed your patch & hence my testing of it.
Thanks
___________________________________________________
On Yahoo!7
Desperate Housewives: Sneak peeks, recaps and more.
http://www.yahoo7.com.au/desperate-housewives
Quoted 10 lines · On Wed, 15 Mar 2006 14:25:49 +1100 (EST) Srihari Vijayaraghavan wrote:
Quoted 8 lines · --- Greg KH
[...]
No. I don't think this driver likes to be unloaded due to the
instability of the hardware if that happens. So let's just let it not
be unloaded, and hope that the hardware can die in peace and never get
put into any new machines...
Quoted 4 lines
Fair enough & thanks for the explanation.
I've quickly tested Stephen's patch, which does the trick (no more 4.3 billion usages :)).
That was ~0 (0xffffffff, -1) for those who missed it.
Quoted 3 lines
Note to Stephen: Pls don't remove people in the cc list. I almost missed your patch & hence my testing of it.
---
~Randy