fix refrigerator() vs thaw_process() race
Subsystems (2)
PATCH 1/1 fix refrigerator() vs thaw_process() race
refrigerator() can miss a wakeup, "wait event" loop needs a proper memory ordering.
kernel/power/process.c renamed from kernel/power/process.c~WAKE +4 -2
@@ -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);
Quoted 4 lines · Oleg Nesterov
refrigerator()can miss a wakeup, "wait event" loop needs a proper memory ordering.Signed-off-by Oleg Nesterov <[email protected]>
ACK
Quoted 18 lines
kernel/power/process.c renamed from kernel/power/process.c~WAKE +4
-2@@ -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);
Signature · 3 lines
If you don't have the time to read, you don't have the time or the tools to write. - Stephen King
Hi!
kernel/power/process.c void refrigerator(void) · line 49
Quoted 13 lines
refrigerator()can miss a wakeup, "wait event" loop needs a proper memory ordering.Signed-off-by Oleg Nesterov <[email protected]>kernel/power/process.c renamed from kernel/power/process.c~WAKE +1
-1@@ -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
Quoted 3 lines
kernel/power/process.c renamed from kernel/power/process.c~WAKE +0
-0schedule (); }pr_debug ("%s left refrigerator\n" , current->comm);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 12 lines · Pavel Machek
Quoted 12 lines
refrigerator()can miss a wakeup, "wait event" loop needs a proper memory ordering.Signed-off-by Oleg Nesterov <[email protected]>kernel/power/process.c renamed from kernel/power/process.c~WAKE +0
-0@@ -46,8 +46,10 @@ void refrigerator(void)recalc_sigpending ();/* We sent fake signal, clean it up */ spin_unlock_irq (¤t->sighand->siglock);
Quoted 6 lines
kernel/power/process.c void refrigerator(void) · line 50
Quoted 2 lines
kernel/power/process.c renamed from kernel/power/process.c~WAKE +1
-1- 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.
Hi!
Quoted 26 lines
Quoted 11 lines
Quoted 11 lines
refrigerator()can miss a wakeup, "wait event" loop needs a proper memory ordering.Signed-off-by Oleg Nesterov <[email protected]>kernel/power/process.c renamed from kernel/power/process.c~WAKE +0
-0@@ -46,8 +46,10 @@ void refrigerator(void)recalc_sigpending ();/* We sent fake signal, clean it up */ spin_unlock_irq (¤t->sighand->siglock);Quoted 6 lines
kernel/power/process.c void refrigerator(void) · line 50
Quoted 2 lines
kernel/power/process.c renamed from kernel/power/process.c~WAKE +1
-1- 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(); }
Quoted 4 lines
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
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html