Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Gautham R Shenoy
On Mon, Apr 23, 2007 at 10:39:56PM +0400, Oleg Nesterov wrote: > On 04/23, Gautham R Shenoy wrote: > > > > On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: > > > On 04/19, Gautham R Shenoy wrote: > > > > > > > > @@ -63,12 +74,16 @@ void refrigerator(void) > > > >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Oleg Nesterov
On 04/23, Gautham R Shenoy wrote: > > On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: > > On 04/19, Gautham R Shenoy wrote: > > > > > > @@ -63,12 +74,16 @@ void refrigerator(void) > > > recalc_sigpending(); /* We sent fake signal, clean it up */ > > >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Gautham R Shenoy
On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: > On 04/19, Gautham R Shenoy wrote: > > > > @@ -63,12 +74,16 @@ void refrigerator(void) > > recalc_sigpending(); /* We sent fake signal, clean it up */ > > spin_unlock_irq(>sighand->siglock); > > > > + task_lock(current); >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Gautham R Shenoy
On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: On 04/19, Gautham R Shenoy wrote: @@ -63,12 +74,16 @@ void refrigerator(void) recalc_sigpending(); /* We sent fake signal, clean it up */ spin_unlock_irq(current-sighand-siglock); + task_lock(current);

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Oleg Nesterov
On 04/23, Gautham R Shenoy wrote: On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: On 04/19, Gautham R Shenoy wrote: @@ -63,12 +74,16 @@ void refrigerator(void) recalc_sigpending(); /* We sent fake signal, clean it up */ spin_unlock_irq(current-sighand-siglock);

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-23 Thread Gautham R Shenoy
On Mon, Apr 23, 2007 at 10:39:56PM +0400, Oleg Nesterov wrote: On 04/23, Gautham R Shenoy wrote: On Sat, Apr 21, 2007 at 01:12:09AM +0400, Oleg Nesterov wrote: On 04/19, Gautham R Shenoy wrote: @@ -63,12 +74,16 @@ void refrigerator(void) recalc_sigpending(); /* We sent

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-21 Thread Pavel Machek
Hi! > > Of course, running try_to_freeze() in kthread_stop() would be very wrong, > > so we'd actually need to do it in callers, preferably via a new > > kthread_stop_freezeable() wrapper. > > > Well, even then we'll need to ensure that a thread would not call > kthread_stop_freezeable() with

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-21 Thread Pavel Machek
Hi! Of course, running try_to_freeze() in kthread_stop() would be very wrong, so we'd actually need to do it in callers, preferably via a new kthread_stop_freezeable() wrapper. Well, even then we'll need to ensure that a thread would not call kthread_stop_freezeable() with any locks

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 23:20, Oleg Nesterov wrote: > On 04/20, Gautham R Shenoy wrote: > > > > On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: > > > > > > Hmm, can't we do something like this instead: > > > > > > --- > > > kernel/kthread.c | 10 ++ > > > 1 file

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Oleg Nesterov
On 04/20, Gautham R Shenoy wrote: > > On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: > > > > Hmm, can't we do something like this instead: > > > > --- > > kernel/kthread.c | 10 ++ > > 1 file changed, 10 insertions(+) > > > > Index:

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Oleg Nesterov
On 04/19, Gautham R Shenoy wrote: > > @@ -63,12 +74,16 @@ void refrigerator(void) > recalc_sigpending(); /* We sent fake signal, clean it up */ > spin_unlock_irq(>sighand->siglock); > > + task_lock(current); > for (;;) { >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 20:31, Ingo Molnar wrote: > > * Andrew Morton <[EMAIL PROTECTED]> wrote: > > > > > I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, > > > > PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two > > > > more for the freezer-based CPU hotplug, so

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Ingo Molnar
* Andrew Morton <[EMAIL PROTECTED]> wrote: > > > I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, > > > PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two > > > more for the freezer-based CPU hotplug, so if yet another one is > > > needed, that will make up almost a

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Andrew Morton
On Fri, 20 Apr 2007 17:56:09 +0530 Gautham R Shenoy <[EMAIL PROTECTED]> wrote: > > I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, > > PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two more for > > the freezer-based CPU hotplug, so if yet another one is needed, that

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 14:26, Gautham R Shenoy wrote: > On Fri, Apr 20, 2007 at 01:59:29PM +0200, Rafael J. Wysocki wrote: > > > > Actually, I thought about it for a while. The thread that is going to stop > > another one may temporarily mark itself as freezable in all cases, which > > will

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Fri, Apr 20, 2007 at 01:59:29PM +0200, Rafael J. Wysocki wrote: > > Actually, I thought about it for a while. The thread that is going to stop > another one may temporarily mark itself as freezable in all cases, which > will have no effect on it, since it's not going to cally try_to_freeze(),

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 13:05, Gautham R Shenoy wrote: > On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: > > > > Hmm, can't we do something like this instead: > > > > --- > > kernel/kthread.c | 10 ++ > > 1 file changed, 10 insertions(+) > > > > Index:

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: > > Hmm, can't we do something like this instead: > > --- > kernel/kthread.c | 10 ++ > 1 file changed, 10 insertions(+) > > Index: linux-2.6.21-rc7/kernel/kthread.c >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Thu, Apr 19, 2007 at 02:31:33PM -0700, Andrew Morton wrote: > On Thu, 19 Apr 2007 17:34:19 +0530 > Gautham R Shenoy <[EMAIL PROTECTED]> wrote: > > > flush_workqueue() just needs to die. I think there are (almost) no > legitimate users of it once cancel_work_sync() is merged. > > > This

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Thursday, 19 April 2007 23:31, Andrew Morton wrote: > On Thu, 19 Apr 2007 17:34:19 +0530 > Gautham R Shenoy <[EMAIL PROTECTED]> wrote: > > > Threads which wait for completion on a frozen thread might result in > > causing the freezer to fail, if the waiting thread is freezeable. > > > >

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Thursday, 19 April 2007 23:31, Andrew Morton wrote: On Thu, 19 Apr 2007 17:34:19 +0530 Gautham R Shenoy [EMAIL PROTECTED] wrote: Threads which wait for completion on a frozen thread might result in causing the freezer to fail, if the waiting thread is freezeable. There are some

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Thu, Apr 19, 2007 at 02:31:33PM -0700, Andrew Morton wrote: On Thu, 19 Apr 2007 17:34:19 +0530 Gautham R Shenoy [EMAIL PROTECTED] wrote: flush_workqueue() just needs to die. I think there are (almost) no legitimate users of it once cancel_work_sync() is merged. This patch attempts

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: Hmm, can't we do something like this instead: --- kernel/kthread.c | 10 ++ 1 file changed, 10 insertions(+) Index: linux-2.6.21-rc7/kernel/kthread.c

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 13:05, Gautham R Shenoy wrote: On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: Hmm, can't we do something like this instead: --- kernel/kthread.c | 10 ++ 1 file changed, 10 insertions(+) Index:

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Gautham R Shenoy
On Fri, Apr 20, 2007 at 01:59:29PM +0200, Rafael J. Wysocki wrote: Actually, I thought about it for a while. The thread that is going to stop another one may temporarily mark itself as freezable in all cases, which will have no effect on it, since it's not going to cally try_to_freeze(), but

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 14:26, Gautham R Shenoy wrote: On Fri, Apr 20, 2007 at 01:59:29PM +0200, Rafael J. Wysocki wrote: Actually, I thought about it for a while. The thread that is going to stop another one may temporarily mark itself as freezable in all cases, which will have no

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Andrew Morton
On Fri, 20 Apr 2007 17:56:09 +0530 Gautham R Shenoy [EMAIL PROTECTED] wrote: I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two more for the freezer-based CPU hotplug, so if yet another one is needed, that will

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Ingo Molnar
* Andrew Morton [EMAIL PROTECTED] wrote: I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two more for the freezer-based CPU hotplug, so if yet another one is needed, that will make up almost a separate u8

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 20:31, Ingo Molnar wrote: * Andrew Morton [EMAIL PROTECTED] wrote: I mean, we already have four of them (PF_NOFREEZE, PF_FROZEN, PF_FREEZER_SKIP, TIF_FREEZE), and you will need to introduce two more for the freezer-based CPU hotplug, so if yet another

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Oleg Nesterov
On 04/19, Gautham R Shenoy wrote: @@ -63,12 +74,16 @@ void refrigerator(void) recalc_sigpending(); /* We sent fake signal, clean it up */ spin_unlock_irq(current-sighand-siglock); + task_lock(current); for (;;) {

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Oleg Nesterov
On 04/20, Gautham R Shenoy wrote: On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: Hmm, can't we do something like this instead: --- kernel/kthread.c | 10 ++ 1 file changed, 10 insertions(+) Index: linux-2.6.21-rc7/kernel/kthread.c

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-20 Thread Rafael J. Wysocki
On Friday, 20 April 2007 23:20, Oleg Nesterov wrote: On 04/20, Gautham R Shenoy wrote: On Fri, Apr 20, 2007 at 10:54:36AM +0200, Rafael J. Wysocki wrote: Hmm, can't we do something like this instead: --- kernel/kthread.c | 10 ++ 1 file changed, 10 insertions(+)

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-19 Thread Andrew Morton
On Thu, 19 Apr 2007 17:34:19 +0530 Gautham R Shenoy <[EMAIL PROTECTED]> wrote: > Threads which wait for completion on a frozen thread might result in > causing the freezer to fail, if the waiting thread is freezeable. > > There are some well known cases where it's preferable to temporarily thaw

[RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-19 Thread Gautham R Shenoy
Threads which wait for completion on a frozen thread might result in causing the freezer to fail, if the waiting thread is freezeable. There are some well known cases where it's preferable to temporarily thaw the frozen process, finish the wait for completion and allow both the processes to

[RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-19 Thread Gautham R Shenoy
Threads which wait for completion on a frozen thread might result in causing the freezer to fail, if the waiting thread is freezeable. There are some well known cases where it's preferable to temporarily thaw the frozen process, finish the wait for completion and allow both the processes to

Re: [RFC PATCH(experimental) 2/2] Fix freezer-kthread_stop race

2007-04-19 Thread Andrew Morton
On Thu, 19 Apr 2007 17:34:19 +0530 Gautham R Shenoy [EMAIL PROTECTED] wrote: Threads which wait for completion on a frozen thread might result in causing the freezer to fail, if the waiting thread is freezeable. There are some well known cases where it's preferable to temporarily thaw the