diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-12-13 03:34:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-13 12:05:49 -0500 |
commit | 8a102eed9c4e1d21bad07a8fd97bd4fbf125d966 (patch) | |
tree | 9ec99f046b94971db46b08a87d7eab3e84c4acd4 /include/asm-frv/thread_info.h | |
parent | 3df494a32b936aef76d893f5065f962ebd9b9437 (diff) |
[PATCH] PM: Fix SMP races in the freezer
Currently, to tell a task that it should go to the refrigerator, we set the
PF_FREEZE flag for it and send a fake signal to it. Unfortunately there
are two SMP-related problems with this approach. First, a task running on
another CPU may be updating its flags while the freezer attempts to set
PF_FREEZE for it and this may leave the task's flags in an inconsistent
state. Second, there is a potential race between freeze_process() and
refrigerator() in which freeze_process() running on one CPU is reading a
task's PF_FREEZE flag while refrigerator() running on another CPU has just
set PF_FROZEN for the same task and attempts to reset PF_FREEZE for it. If
the refrigerator wins the race, freeze_process() will state that PF_FREEZE
hasn't been set for the task and will set it unnecessarily, so the task
will go to the refrigerator once again after it's been thawed.
To solve first of these problems we need to stop using PF_FREEZE to tell
tasks that they should go to the refrigerator. Instead, we can introduce a
special TIF_*** flag and use it for this purpose, since it is allowed to
change the other tasks' TIF_*** flags and there are special calls for it.
To avoid the freeze_process()-refrigerator() race we can make
freeze_process() to always check the task's PF_FROZEN flag after it's read
its "freeze" flag. We should also make sure that refrigerator() will
always reset the task's "freeze" flag after it's set PF_FROZEN for it.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>
Cc: Andi Kleen <ak@muc.de>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-frv/thread_info.h')
-rw-r--r-- | include/asm-frv/thread_info.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h index d66c48e6ef14..d881f518e6a9 100644 --- a/include/asm-frv/thread_info.h +++ b/include/asm-frv/thread_info.h | |||
@@ -116,6 +116,7 @@ register struct thread_info *__current_thread_info asm("gr15"); | |||
116 | #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ | 116 | #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ |
117 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ | 117 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
118 | #define TIF_MEMDIE 17 /* OOM killer killed process */ | 118 | #define TIF_MEMDIE 17 /* OOM killer killed process */ |
119 | #define TIF_FREEZE 18 /* freezing for suspend */ | ||
119 | 120 | ||
120 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) | 121 | #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) |
121 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) | 122 | #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) |
@@ -125,6 +126,7 @@ register struct thread_info *__current_thread_info asm("gr15"); | |||
125 | #define _TIF_IRET (1 << TIF_IRET) | 126 | #define _TIF_IRET (1 << TIF_IRET) |
126 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) | 127 | #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) |
127 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) | 128 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) |
129 | #define _TIF_FREEZE (1 << TIF_FREEZE) | ||
128 | 130 | ||
129 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ | 131 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
130 | #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ | 132 | #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ |