From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261896AbVGRUlk (ORCPT ); Mon, 18 Jul 2005 16:41:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261872AbVGRUlj (ORCPT ); Mon, 18 Jul 2005 16:41:39 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.31.123]:51606 "EHLO atrey.karlin.mff.cuni.cz") by vger.kernel.org with ESMTP id S261899AbVGRUkq (ORCPT ); Mon, 18 Jul 2005 16:40:46 -0400 Date: Mon, 18 Jul 2005 22:40:27 +0200 From: Pavel Machek To: christoph@lameter.com, kernel list , Andrew Morton Subject: [swsusp] swsusp process freezing: remove smp races Message-ID: <20050718204027.GA2112@elf.ucw.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Warning: Reading this can be dangerous to your mental health. User-Agent: Mutt/1.5.9i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org 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 --- commit b3ace94a1a465a2084bed642021aa8c8ddd912d1 tree 479de81d32de97f456f5d2929597f4047e1aab6f parent e83468048173e800bfc4dc09c2d609f9983cd29d author Mon, 18 Jul 2005 22:20:46 +0200 committer 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 (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); -- teflon -- maybe it is a trademark, but it should not be.