Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-26 Thread Alan Stern
On Wed, 26 Sep 2007, Tejun Heo wrote: > >> Hmmm... I might be missing something here. Who else can wake up a > >> thread in uninterruptible sleep? > > > > In principle, anything can. There has never been any guarantee in the > > kernel that a task sleeping on a waitqueue will remain asleep

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-26 Thread Alan Stern
On Wed, 26 Sep 2007, Tejun Heo wrote: Hmmm... I might be missing something here. Who else can wake up a thread in uninterruptible sleep? In principle, anything can. There has never been any guarantee in the kernel that a task sleeping on a waitqueue will remain asleep until the

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: > On Wed, 2007-09-26 at 08:15 +0900, Tejun Heo wrote: >> I have no problem with changing the condition check to loop but it would >> be great if someone can point me to a code where this unexpected wake up >> is used. > > This is one of those areas where we're conservative.

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Rusty Russell
On Wed, 2007-09-26 at 08:15 +0900, Tejun Heo wrote: > I have no problem with changing the condition check to loop but it would > be great if someone can point me to a code where this unexpected wake up > is used. This is one of those areas where we're conservative. Historically there have been

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Alan Stern wrote: > On Tue, 25 Sep 2007, Tejun Heo wrote: > >> Alan Stern wrote: The unloading can proceed once module_unload_inhibit_cnt reaches zero. An unloading thread only has to care about inhibition put in effect before unloading has started, so there's no need to check

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Alan Stern
On Tue, 25 Sep 2007, Tejun Heo wrote: > Alan Stern wrote: > >> The unloading can proceed once module_unload_inhibit_cnt reaches zero. > >> An unloading thread only has to care about inhibition put in effect > >> before unloading has started, so there's no need to check again. > > > > You haven't

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Alan Stern wrote: >> The unloading can proceed once module_unload_inhibit_cnt reaches zero. >> An unloading thread only has to care about inhibition put in effect >> before unloading has started, so there's no need to check again. > > You haven't fully answered Jon's question. Suppose >

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Alan Stern
On Tue, 25 Sep 2007, Tejun Heo wrote: > Jonathan Corbet wrote: > > Hi, Tejun, > > > > I was just looking over these changes... > > > >> + /* Don't proceed till inhibition is lifted. */ > >> + add_wait_queue(_unload_wait, ); > >> + set_current_state(TASK_UNINTERRUPTIBLE); > >> + if

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: > On Tue, 2007-09-25 at 17:36 +0900, Tejun Heo wrote: >> Hmmm There doesn't seem to any reason why the blocking should be >> after calling ->exit(). And, yeah, it would be more useful and >> intuitive if blocking happens before ->exit(). What do you think? > > *That* I

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Rusty Russell
On Tue, 2007-09-25 at 17:36 +0900, Tejun Heo wrote: > Hmmm There doesn't seem to any reason why the blocking should be > after calling ->exit(). And, yeah, it would be more useful and > intuitive if blocking happens before ->exit(). What do you think? *That* I have no problem with. I was

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Tejun Heo wrote: > Rusty Russell wrote: >> Now, are you sure that calling cleanup_ccwgroup just after >> device_unregister() works? >> >> static void __exit >> cleanup_ccwgroup (void) >> { >> bus_unregister (_bus_type); >> } > > It should. After ->exit() is called, there can't be any object

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: > On Tue, 2007-09-25 at 12:36 +0900, Tejun Heo wrote: >> Rusty Russell wrote: >>> As stated you cannot protect arbitrary code this way, as you are trying >>> to do. I do not think you've broken any of the current code, but I >>> cannot tell. You're certainly going to

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Cornelia Huck
On Tue, 25 Sep 2007 14:38:38 +1000, Rusty Russell <[EMAIL PROTECTED]> wrote: > Have you tested that *this* path works? Let's take your first change as > an example: > > + mutex_lock(>reg_mutex); > + __ccwgroup_remove_symlinks(gdev); > + device_unregister(dev); > +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Cornelia Huck
On Tue, 25 Sep 2007 14:38:38 +1000, Rusty Russell [EMAIL PROTECTED] wrote: Have you tested that *this* path works? Let's take your first change as an example: + mutex_lock(gdev-reg_mutex); + __ccwgroup_remove_symlinks(gdev); + device_unregister(dev); +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: On Tue, 2007-09-25 at 12:36 +0900, Tejun Heo wrote: Rusty Russell wrote: As stated you cannot protect arbitrary code this way, as you are trying to do. I do not think you've broken any of the current code, but I cannot tell. You're certainly going to surprise

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Tejun Heo wrote: Rusty Russell wrote: Now, are you sure that calling cleanup_ccwgroup just after device_unregister() works? static void __exit cleanup_ccwgroup (void) { bus_unregister (ccwgroup_bus_type); } It should. After -exit() is called, there can't be any object left

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Rusty Russell
On Tue, 2007-09-25 at 17:36 +0900, Tejun Heo wrote: Hmmm There doesn't seem to any reason why the blocking should be after calling -exit(). And, yeah, it would be more useful and intuitive if blocking happens before -exit(). What do you think? *That* I have no problem with. I was going

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: On Tue, 2007-09-25 at 17:36 +0900, Tejun Heo wrote: Hmmm There doesn't seem to any reason why the blocking should be after calling -exit(). And, yeah, it would be more useful and intuitive if blocking happens before -exit(). What do you think? *That* I have no

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Alan Stern
On Tue, 25 Sep 2007, Tejun Heo wrote: Jonathan Corbet wrote: Hi, Tejun, I was just looking over these changes... + /* Don't proceed till inhibition is lifted. */ + add_wait_queue(module_unload_wait, wait); + set_current_state(TASK_UNINTERRUPTIBLE); + if

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Alan Stern wrote: The unloading can proceed once module_unload_inhibit_cnt reaches zero. An unloading thread only has to care about inhibition put in effect before unloading has started, so there's no need to check again. You haven't fully answered Jon's question. Suppose

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Alan Stern
On Tue, 25 Sep 2007, Tejun Heo wrote: Alan Stern wrote: The unloading can proceed once module_unload_inhibit_cnt reaches zero. An unloading thread only has to care about inhibition put in effect before unloading has started, so there's no need to check again. You haven't fully

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Alan Stern wrote: On Tue, 25 Sep 2007, Tejun Heo wrote: Alan Stern wrote: The unloading can proceed once module_unload_inhibit_cnt reaches zero. An unloading thread only has to care about inhibition put in effect before unloading has started, so there's no need to check again. You haven't

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Rusty Russell
On Wed, 2007-09-26 at 08:15 +0900, Tejun Heo wrote: I have no problem with changing the condition check to loop but it would be great if someone can point me to a code where this unexpected wake up is used. This is one of those areas where we're conservative. Historically there have been

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-25 Thread Tejun Heo
Rusty Russell wrote: On Wed, 2007-09-26 at 08:15 +0900, Tejun Heo wrote: I have no problem with changing the condition check to loop but it would be great if someone can point me to a code where this unexpected wake up is used. This is one of those areas where we're conservative.

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 12:36 +0900, Tejun Heo wrote: > Rusty Russell wrote: > > As stated you cannot protect arbitrary code this way, as you are trying > > to do. I do not think you've broken any of the current code, but I > > cannot tell. You're certainly going to surprise unsuspecting future >

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: > As stated you cannot protect arbitrary code this way, as you are trying > to do. I do not think you've broken any of the current code, but I > cannot tell. You're certainly going to surprise unsuspecting future > authors. Can you elaborate a bit? Why can't it protect the

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 11:39 +0900, Tejun Heo wrote: > Rusty Russell wrote: > >>> I really wonder if an explicit "kill_this_attribute()" is a better way > >>> to go than this... > >> I think this sort of temporary unload blocking would be useful for other > >> cases like this. > > > > I hope not:

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: >>> I really wonder if an explicit "kill_this_attribute()" is a better way >>> to go than this... >> I think this sort of temporary unload blocking would be useful for other >> cases like this. > > I hope not: this doesn't work in general. Calling into a module after >

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 10:40 +0900, Tejun Heo wrote: > Rusty Russell wrote: > > My concern is that you're dropping the module mutex around ->exit now. > > I don't *think* this should matter, but it's worth considering. > > We always did that. Before the patch the code segment looked like the >

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: > On Tue, 2007-09-25 at 08:18 +0900, Tejun Heo wrote: >>> Given your description of this tool as a "sledgehammer," might it not be >>> easier to just take and hold module_mutex for the duration of the unload >>> block? >> That would be easier but... >> >> * It would serialize

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 08:18 +0900, Tejun Heo wrote: > > Given your description of this tool as a "sledgehammer," might it not be > > easier to just take and hold module_mutex for the duration of the unload > > block? > > That would be easier but... > > * It would serialize users of the

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Jonathan Corbet wrote: > Hi, Tejun, > > I was just looking over these changes... > >> +/* Don't proceed till inhibition is lifted. */ >> +add_wait_queue(_unload_wait, ); >> +set_current_state(TASK_UNINTERRUPTIBLE); >> +if (atomic_read(_unload_inhibit_cnt)) >> +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Jonathan Corbet
Hi, Tejun, I was just looking over these changes... > + /* Don't proceed till inhibition is lifted. */ > + add_wait_queue(_unload_wait, ); > + set_current_state(TASK_UNINTERRUPTIBLE); > + if (atomic_read(_unload_inhibit_cnt)) > + schedule(); > +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Jonathan Corbet
Hi, Tejun, I was just looking over these changes... + /* Don't proceed till inhibition is lifted. */ + add_wait_queue(module_unload_wait, wait); + set_current_state(TASK_UNINTERRUPTIBLE); + if (atomic_read(module_unload_inhibit_cnt)) + schedule(); +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Jonathan Corbet wrote: Hi, Tejun, I was just looking over these changes... +/* Don't proceed till inhibition is lifted. */ +add_wait_queue(module_unload_wait, wait); +set_current_state(TASK_UNINTERRUPTIBLE); +if (atomic_read(module_unload_inhibit_cnt)) +

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 08:18 +0900, Tejun Heo wrote: Given your description of this tool as a sledgehammer, might it not be easier to just take and hold module_mutex for the duration of the unload block? That would be easier but... * It would serialize users of the sledgehammer. * It

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: On Tue, 2007-09-25 at 08:18 +0900, Tejun Heo wrote: Given your description of this tool as a sledgehammer, might it not be easier to just take and hold module_mutex for the duration of the unload block? That would be easier but... * It would serialize users of the

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 10:40 +0900, Tejun Heo wrote: Rusty Russell wrote: My concern is that you're dropping the module mutex around -exit now. I don't *think* this should matter, but it's worth considering. We always did that. Before the patch the code segment looked like the following.

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: I really wonder if an explicit kill_this_attribute() is a better way to go than this... I think this sort of temporary unload blocking would be useful for other cases like this. I hope not: this doesn't work in general. Calling into a module after -exit has called

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 11:39 +0900, Tejun Heo wrote: Rusty Russell wrote: I really wonder if an explicit kill_this_attribute() is a better way to go than this... I think this sort of temporary unload blocking would be useful for other cases like this. I hope not: this doesn't work in

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Tejun Heo
Rusty Russell wrote: As stated you cannot protect arbitrary code this way, as you are trying to do. I do not think you've broken any of the current code, but I cannot tell. You're certainly going to surprise unsuspecting future authors. Can you elaborate a bit? Why can't it protect the

Re: [PATCH 1/4] module: implement module_inhibit_unload()

2007-09-24 Thread Rusty Russell
On Tue, 2007-09-25 at 12:36 +0900, Tejun Heo wrote: Rusty Russell wrote: As stated you cannot protect arbitrary code this way, as you are trying to do. I do not think you've broken any of the current code, but I cannot tell. You're certainly going to surprise unsuspecting future