[swsusp] swsusp process freezing: remove smp races

2005-07-18 Thread Pavel Machek
From: Christoph Lameter <[EMAIL PROTECTED]>

The current suspend code modifies thread->flags from outside the
context of the thread. This creates a SMP race.

This patch fixes that by introducing a TIF_FREEZE flag in thread_info.

(This is not the end of the races in the suspend code since TIF_FREEZE
is cleared when setting PF_FROZEN creating a window for
freeze_processes(). OTOH, this patch actually works :-)

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>
Signed-off-by: Pavel Machek <[EMAIL PROTECTED]>

---
commit b3ace94a1a465a2084bed642021aa8c8ddd912d1
tree 479de81d32de97f456f5d2929597f4047e1aab6f
parent e83468048173e800bfc4dc09c2d609f9983cd29d
author <[EMAIL PROTECTED](none)> Mon, 18 Jul 2005 22:20:46 +0200
committer <[EMAIL PROTECTED](none)> Mon, 18 Jul 2005 22:20:46 +0200

 include/asm-alpha/thread_info.h |1 +
 include/asm-arm/thread_info.h   |1 +
 include/asm-arm26/thread_info.h |1 +
 include/asm-cris/thread_info.h  |1 +
 include/asm-frv/thread_info.h   |1 +
 include/asm-h8300/thread_info.h |1 +
 include/asm-i386/thread_info.h  |1 +
 include/asm-ia64/thread_info.h  |1 +
 include/asm-m32r/thread_info.h  |1 +
 include/asm-m68k/thread_info.h  |1 +
 include/asm-m68knommu/thread_info.h |1 +
 include/asm-mips/thread_info.h  |1 +
 include/asm-parisc/thread_info.h|1 +
 include/asm-ppc/thread_info.h   |1 +
 include/asm-ppc64/thread_info.h |1 +
 include/asm-s390/thread_info.h  |1 +
 include/asm-sh/thread_info.h|1 +
 include/asm-sh64/thread_info.h  |1 +
 include/asm-sparc/thread_info.h |1 +
 include/asm-sparc64/thread_info.h   |1 +
 include/asm-um/thread_info.h|1 +
 include/asm-v850/thread_info.h  |1 +
 include/asm-x86_64/thread_info.h|1 +
 include/asm-xtensa/thread_info.h|1 +
 include/linux/sched.h   |9 -
 25 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/include/asm-alpha/thread_info.h b/include/asm-alpha/thread_info.h
--- a/include/asm-alpha/thread_info.h
+++ b/include/asm-alpha/thread_info.h
@@ -78,6 +78,7 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOFIX  7
 #define TIF_UAC_SIGBUS 8
 #define TIF_MEMDIE 9
+#define TIF_FREEZE 10
 
 #define _TIF_SYSCALL_TRACE (1flags & PF_FREEZE;
+   return test_ti_thread_flag(p->thread_info, TIF_FREEZE);
 }
 
 /*
  * Request that a process be frozen
- * FIXME: SMP problem. We may not modify other process' flags!
  */
 static inline void freeze(struct task_struct *p)
 {
-   p->flags |= PF_FREEZE;
+   set_ti_thread_flag(p->thread_info, TIF_FREEZE);
 }
 
 /*
@@ -1317,7 +1315,8 @@ static inline int thaw_process(struct ta
  */
 static inline void frozen_process(struct task_struct *p)
 {
-   p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
+   p->flags |= PF_FROZEN;
+   clear_ti_thread_flag(p->thread_info, TIF_FREEZE);
 }
 
 extern void refrigerator(void);

-- 
teflon -- maybe it is a trademark, but it should not be.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[swsusp] swsusp process freezing: remove smp races

2005-07-18 Thread Pavel Machek
From: Christoph Lameter [EMAIL PROTECTED]

The current suspend code modifies thread-flags from outside the
context of the thread. This creates a SMP race.

This patch fixes that by introducing a TIF_FREEZE flag in thread_info.

(This is not the end of the races in the suspend code since TIF_FREEZE
is cleared when setting PF_FROZEN creating a window for
freeze_processes(). OTOH, this patch actually works :-)

Signed-off-by: Christoph Lameter [EMAIL PROTECTED]
Signed-off-by: Pavel Machek [EMAIL PROTECTED]

---
commit b3ace94a1a465a2084bed642021aa8c8ddd912d1
tree 479de81d32de97f456f5d2929597f4047e1aab6f
parent e83468048173e800bfc4dc09c2d609f9983cd29d
author [EMAIL PROTECTED](none) Mon, 18 Jul 2005 22:20:46 +0200
committer [EMAIL PROTECTED](none) Mon, 18 Jul 2005 22:20:46 +0200

 include/asm-alpha/thread_info.h |1 +
 include/asm-arm/thread_info.h   |1 +
 include/asm-arm26/thread_info.h |1 +
 include/asm-cris/thread_info.h  |1 +
 include/asm-frv/thread_info.h   |1 +
 include/asm-h8300/thread_info.h |1 +
 include/asm-i386/thread_info.h  |1 +
 include/asm-ia64/thread_info.h  |1 +
 include/asm-m32r/thread_info.h  |1 +
 include/asm-m68k/thread_info.h  |1 +
 include/asm-m68knommu/thread_info.h |1 +
 include/asm-mips/thread_info.h  |1 +
 include/asm-parisc/thread_info.h|1 +
 include/asm-ppc/thread_info.h   |1 +
 include/asm-ppc64/thread_info.h |1 +
 include/asm-s390/thread_info.h  |1 +
 include/asm-sh/thread_info.h|1 +
 include/asm-sh64/thread_info.h  |1 +
 include/asm-sparc/thread_info.h |1 +
 include/asm-sparc64/thread_info.h   |1 +
 include/asm-um/thread_info.h|1 +
 include/asm-v850/thread_info.h  |1 +
 include/asm-x86_64/thread_info.h|1 +
 include/asm-xtensa/thread_info.h|1 +
 include/linux/sched.h   |9 -
 25 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/include/asm-alpha/thread_info.h b/include/asm-alpha/thread_info.h
--- a/include/asm-alpha/thread_info.h
+++ b/include/asm-alpha/thread_info.h
@@ -78,6 +78,7 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOFIX  7
 #define TIF_UAC_SIGBUS 8
 #define TIF_MEMDIE 9
+#define TIF_FREEZE 10
 
 #define _TIF_SYSCALL_TRACE (1TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME (1TIF_NOTIFY_RESUME)
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -132,6 +132,7 @@ extern void iwmmxt_task_release(struct t
 #define TIF_POLLING_NRFLAG 16
 #define TIF_USING_IWMMXT   17
 #define TIF_MEMDIE 18
+#define TIF_FREEZE 19
 
 #define _TIF_NOTIFY_RESUME (1  TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING(1  TIF_SIGPENDING)
diff --git a/include/asm-arm26/thread_info.h b/include/asm-arm26/thread_info.h
--- a/include/asm-arm26/thread_info.h
+++ b/include/asm-arm26/thread_info.h
@@ -127,6 +127,7 @@ extern void free_thread_info(struct thre
 #define TIF_USED_FPU   16
 #define TIF_POLLING_NRFLAG 17
 #define TIF_MEMDIE 18
+#define TIF_FREEZE 19
 
 #define _TIF_NOTIFY_RESUME (1  TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING(1  TIF_SIGPENDING)
diff --git a/include/asm-cris/thread_info.h b/include/asm-cris/thread_info.h
--- a/include/asm-cris/thread_info.h
+++ b/include/asm-cris/thread_info.h
@@ -86,6 +86,7 @@ struct thread_info {
 #define TIF_NEED_RESCHED   3   /* rescheduling necessary */
 #define TIF_POLLING_NRFLAG 16  /* true if poll_idle() is polling 
TIF_NEED_RESCHED */
 #define TIF_MEMDIE 17
+#define TIF_FREEZE 18
 
 #define _TIF_SYSCALL_TRACE (1TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME (1TIF_NOTIFY_RESUME)
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
--- a/include/asm-frv/thread_info.h
+++ b/include/asm-frv/thread_info.h
@@ -133,6 +133,7 @@ register struct thread_info *__current_t
 #define TIF_IRET   5   /* return with iret */
 #define TIF_POLLING_NRFLAG 16  /* true if poll_idle() is polling 
TIF_NEED_RESCHED */
 #define TIF_MEMDIE 17  /* OOM killer killed process */
+#define TIF_FREEZE 18
 
 #define _TIF_SYSCALL_TRACE (1  TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME (1  TIF_NOTIFY_RESUME)
diff --git a/include/asm-h8300/thread_info.h b/include/asm-h8300/thread_info.h
--- a/include/asm-h8300/thread_info.h
+++ b/include/asm-h8300/thread_info.h
@@ -94,6 +94,7 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG 4   /* true if poll_idle() is polling
   TIF_NEED_RESCHED */
 #define TIF_MEMDIE 5
+#define TIF_FREEZE 6
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE