From: Christoph Lameter 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 Signed-off-by: Pavel Machek Signed-off-by: Andrew Morton --- 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 -puN include/asm-alpha/thread_info.h~swsusp-process-freezing-remove-smp-races include/asm-alpha/thread_info.h --- devel/include/asm-alpha/thread_info.h~swsusp-process-freezing-remove-smp-races 2005-07-25 20:39:51.000000000 -0700 +++ devel-akpm/include/asm-alpha/thread_info.h 2005-07-25 20:39:51.000000000 -0700 @@ -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 (1<usa #define PF_MEMALLOC 0x00000800 /* Allocating memory */ #define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ #define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ -#define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */ #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ #define PF_FROZEN 0x00010000 /* frozen for system suspend */ #define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ @@ -1287,16 +1286,15 @@ static inline int frozen(struct task_str */ static inline int freezing(struct task_struct *p) { - return p->flags & 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); _