* [PATCH] fix refrigerator() vs thaw_process() race
@ 2007-02-18 22:17 Oleg Nesterov
2007-02-18 23:28 ` Rafael J. Wysocki
2007-02-19 10:50 ` Pavel Machek
0 siblings, 2 replies; 5+ messages in thread
From: Oleg Nesterov @ 2007-02-18 22:17 UTC (permalink / raw)
To: Andrew Morton
Cc: Rafael J. Wysocki, Pavel Machek, Paul E. McKenney, linux-kernel
refrigerator() can miss a wakeup, "wait event" loop needs a proper memory
ordering.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- WQ/kernel/power/process.c~WAKE 2007-02-18 22:56:49.000000000 +0300
+++ WQ/kernel/power/process.c 2007-02-19 01:04:26.000000000 +0300
@@ -46,8 +46,10 @@ void refrigerator(void)
recalc_sigpending(); /* We sent fake signal, clean it up */
spin_unlock_irq(¤t->sighand->siglock);
- while (frozen(current)) {
- current->state = TASK_UNINTERRUPTIBLE;
+ for (;;) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ if (!frozen(current))
+ break;
schedule();
}
pr_debug("%s left refrigerator\n", current->comm);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix refrigerator() vs thaw_process() race
2007-02-18 22:17 [PATCH] fix refrigerator() vs thaw_process() race Oleg Nesterov
@ 2007-02-18 23:28 ` Rafael J. Wysocki
2007-02-19 10:50 ` Pavel Machek
1 sibling, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2007-02-18 23:28 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Andrew Morton, Pavel Machek, Paul E. McKenney, linux-kernel
On Sunday, 18 February 2007 23:17, Oleg Nesterov wrote:
> refrigerator() can miss a wakeup, "wait event" loop needs a proper memory
> ordering.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
ACK
> --- WQ/kernel/power/process.c~WAKE 2007-02-18 22:56:49.000000000 +0300
> +++ WQ/kernel/power/process.c 2007-02-19 01:04:26.000000000 +0300
> @@ -46,8 +46,10 @@ void refrigerator(void)
> recalc_sigpending(); /* We sent fake signal, clean it up */
> spin_unlock_irq(¤t->sighand->siglock);
>
> - while (frozen(current)) {
> - current->state = TASK_UNINTERRUPTIBLE;
> + for (;;) {
> + set_current_state(TASK_UNINTERRUPTIBLE);
> + if (!frozen(current))
> + break;
> schedule();
> }
> pr_debug("%s left refrigerator\n", current->comm);
>
>
>
--
If you don't have the time to read,
you don't have the time or the tools to write.
- Stephen King
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix refrigerator() vs thaw_process() race
2007-02-18 22:17 [PATCH] fix refrigerator() vs thaw_process() race Oleg Nesterov
2007-02-18 23:28 ` Rafael J. Wysocki
@ 2007-02-19 10:50 ` Pavel Machek
2007-02-19 12:12 ` Oleg Nesterov
1 sibling, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2007-02-19 10:50 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Andrew Morton, Rafael J. Wysocki, Paul E. McKenney, linux-kernel
Hi!
> refrigerator() can miss a wakeup, "wait event" loop needs a proper memory
> ordering.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>
> --- WQ/kernel/power/process.c~WAKE 2007-02-18 22:56:49.000000000 +0300
> +++ WQ/kernel/power/process.c 2007-02-19 01:04:26.000000000 +0300
> @@ -46,8 +46,10 @@ void refrigerator(void)
> recalc_sigpending(); /* We sent fake signal, clean it up */
> spin_unlock_irq(¤t->sighand->siglock);
>
> - current->state = TASK_UNINTERRUPTIBLE;
> + set_current_state(TASK_UNINTERRUPTIBLE);
Looks okay to me... but this one liner would be exactly as effective,
right?
Pavel
> schedule();
> }
> pr_debug("%s left refrigerator\n", current->comm);
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix refrigerator() vs thaw_process() race
2007-02-19 10:50 ` Pavel Machek
@ 2007-02-19 12:12 ` Oleg Nesterov
2007-02-19 22:47 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2007-02-19 12:12 UTC (permalink / raw)
To: Pavel Machek
Cc: Andrew Morton, Rafael J. Wysocki, Paul E. McKenney, linux-kernel
On 02/19, Pavel Machek wrote:
>
> > refrigerator() can miss a wakeup, "wait event" loop needs a proper memory
> > ordering.
> >
> > Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
> >
> > --- WQ/kernel/power/process.c~WAKE 2007-02-18 22:56:49.000000000 +0300
> > +++ WQ/kernel/power/process.c 2007-02-19 01:04:26.000000000 +0300
> > @@ -46,8 +46,10 @@ void refrigerator(void)
> > recalc_sigpending(); /* We sent fake signal, clean it up */
> > spin_unlock_irq(¤t->sighand->siglock);
> >
> > - current->state = TASK_UNINTERRUPTIBLE;
> > + set_current_state(TASK_UNINTERRUPTIBLE);
>
>
> Looks okay to me... but this one liner would be exactly as effective,
> right?
I think no, with this one liner we have
while (frozen(current)) {
// ------ WINDOW ------------
set_current_state(TASK_UNINTERRUPTIBLE);
schedule();
}
What if thaw_process() happens in the window above?
We need the barrier exactly because LOAD (check condition) should not
come before STORE (set task->state).
Oleg.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix refrigerator() vs thaw_process() race
2007-02-19 12:12 ` Oleg Nesterov
@ 2007-02-19 22:47 ` Pavel Machek
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2007-02-19 22:47 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Andrew Morton, Rafael J. Wysocki, Paul E. McKenney, linux-kernel
Hi!
> > > refrigerator() can miss a wakeup, "wait event" loop needs a proper memory
> > > ordering.
> > >
> > > Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
> > >
> > > --- WQ/kernel/power/process.c~WAKE 2007-02-18 22:56:49.000000000 +0300
> > > +++ WQ/kernel/power/process.c 2007-02-19 01:04:26.000000000 +0300
> > > @@ -46,8 +46,10 @@ void refrigerator(void)
> > > recalc_sigpending(); /* We sent fake signal, clean it up */
> > > spin_unlock_irq(¤t->sighand->siglock);
> > >
> > > - current->state = TASK_UNINTERRUPTIBLE;
> > > + set_current_state(TASK_UNINTERRUPTIBLE);
> >
> >
> > Looks okay to me... but this one liner would be exactly as effective,
> > right?
>
> I think no, with this one liner we have
>
> while (frozen(current)) {
> // ------ WINDOW ------------
> set_current_state(TASK_UNINTERRUPTIBLE);
> schedule();
> }
>
> What if thaw_process() happens in the window above?
>
> We need the barrier exactly because LOAD (check condition) should not
> come before STORE (set task->state).
Aha, ok :-). You already have my ACK ;-).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-02-20 23:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-18 22:17 [PATCH] fix refrigerator() vs thaw_process() race Oleg Nesterov
2007-02-18 23:28 ` Rafael J. Wysocki
2007-02-19 10:50 ` Pavel Machek
2007-02-19 12:12 ` Oleg Nesterov
2007-02-19 22:47 ` Pavel Machek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.