aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ia64/thread_info.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2006-12-13 03:34:30 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-13 12:05:49 -0500
commit8a102eed9c4e1d21bad07a8fd97bd4fbf125d966 (patch)
tree9ec99f046b94971db46b08a87d7eab3e84c4acd4 /include/asm-ia64/thread_info.h
parent3df494a32b936aef76d893f5065f962ebd9b9437 (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-ia64/thread_info.h')
-rw-r--r--include/asm-ia64/thread_info.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 8adcde0934ca..9b505b25544f 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -88,6 +88,7 @@ struct thread_info {
88#define TIF_MEMDIE 17 88#define TIF_MEMDIE 17
89#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */ 89#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */
90#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ 90#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
91#define TIF_FREEZE 20 /* is freezing for suspend */
91 92
92#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 93#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
93#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 94#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
@@ -98,6 +99,7 @@ struct thread_info {
98#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 99#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
99#define _TIF_MCA_INIT (1 << TIF_MCA_INIT) 100#define _TIF_MCA_INIT (1 << TIF_MCA_INIT)
100#define _TIF_DB_DISABLED (1 << TIF_DB_DISABLED) 101#define _TIF_DB_DISABLED (1 << TIF_DB_DISABLED)
102#define _TIF_FREEZE (1 << TIF_FREEZE)
101 103
102/* "work to do on user-return" bits */ 104/* "work to do on user-return" bits */
103#define TIF_ALLWORK_MASK (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) 105#define TIF_ALLWORK_MASK (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)