Skip to contentSkip to conversation

Container Freezer: Reuse Suspend Freezer

PATCH In review Matt Helsley 10 participants 79 messages Aug 1, 2008 – Aug 2, 2008 14 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover Container Freezer: Reuse Suspend Freezer

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

The freezer subsystem in the container filesystem defines a cgroup file named freezer.state. Reading freezer.state will return the current state of the cgroup. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Cheers,
-Matt Helsley

Changes since v4:
v5:
Split out write_string as a separate patch for easier merging
with trees lacking certain cgroup patches at the time.
Checked use of task alloc lock for races with swsusp freeze/thaw --
looks safe because there are explicit barriers to handle freeze/thaw races for individual tasks, we explicitly handle partial group freezing, and partial group thawing should be resolved without changing swsusp's loop.
Updated the patches to Linus' git tree as of approximately
7/31/2008.
Added Pavel and Serge's Acked-by lines to Acked patches

v4 (Almost all of these changes are confined to patch 3):
Reworked the series to use task_lock() instead of RCU. Reworked the series to use write_string() and read_seq_string()
cgroup methods.
Fixed the race Paul Menage identified.
Fixed up check_if_frozen() to do more than just test the FROZEN
flag. In some cases tasks could be stopped (T) and marked FREEZING. When that happens we can safely assume that it will be frozen immediately upon waking up in the kernel. Waiting for it to get marked with PF_FROZEN in order to transition to the FROZEN state would block unnecessarily.
Removed freezer_ prefix from static functions in cgroup_freezer.c. Simplified STATE_ switch.
Updated the locking comments.

v3:
Ported to 2.6.26-rc5-mm2 with Rafael's freezer patches Tested on 24 combinations of 3 architectures (x86, x86_64, ppc64)
with 8 different kernel configs varying power management and cgroup config variables. Each patch builds and boots in these 24 combinations.
Passes functional testing.

v2 (roughly patches 3 and 5):
Moved the "kill" file into a separate cgroup subsystem (signal) and
it's own patch.
Changed the name of the file from freezer.freeze to freezer.state. Switched from taking 1 and 0 as input to the strings "FROZEN" and
"RUNNING", respectively. This helps keep the interface human-usable if/when we need to more states.
Checked that stopped or interrupted is "frozen enough"
Since try_to_freeze() is called upon wakeup of these tasks this should be fine. This idea comes from recent changes to the freezer.
Checked that if (task == current) whilst freezing cgroup we're ok Fixed bug where -EBUSY would always be returned when freezing Added code to handle userspace retries for any remaining -EBUSY

#1 lore raw

PATCH 1/6 Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#2 lore raw

PATCH 1/6 Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#3 lore raw

PATCH 2/6 Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

---
 include/linux/freezer.h |   24 +++++----
 kernel/Makefile         |    2 +-
 kernel/freezer.c        |  122 +++++++++++++++++++++++++++++++++++++++++++++++
 kernel/power/process.c  |  116 --------------------------------------------
 4 files changed, 136 insertions(+), 128 deletions(-)
 create mode 100644 kernel/freezer.c
include/linux/freezer.h +13 -11
index deddeed..4081768 100644
@@ -6,7 +6,6 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#ifdef CONFIG_PM_SLEEP
 /*
  * Check if a process has been frozen
  */
@@ -39,6 +38,11 @@ static inline void clear_freeze_flag(struct task_struct *p)
 	clear_tsk_thread_flag(p, TIF_FREEZE);
 }
 
+static inline bool should_send_signal(struct task_struct *p)
+{
+	return !(p->flags & PF_FREEZER_NOSIG);
+}
+
 /*
  * Wake up a frozen process
  *
@@ -63,8 +67,6 @@ static inline int thaw_process(struct task_struct *p)
 }
 
 extern void refrigerator(void);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
 
 static inline int try_to_freeze(void)
 {
@@ -75,6 +77,14 @@ static inline int try_to_freeze(void)
 		return 0;
 }
 
+extern bool freeze_task(struct task_struct *p, bool sig_only);
+extern void cancel_freezing(struct task_struct *p);
+
+#ifdef CONFIG_PM_SLEEP
+
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
 /*
  * The PF_FREEZER_SKIP flag should be set by a vfork parent right before it
  * calls wait_for_completion(&vfork) and reset right after it returns from this
@@ -167,18 +177,10 @@ static inline void set_freezable_with_signal(void)
 	__retval;							\
 })
 #else /* !CONFIG_PM_SLEEP */
-static inline int frozen(struct task_struct *p) { return 0; }
-static inline int freezing(struct task_struct *p) { return 0; }
-static inline void set_freeze_flag(struct task_struct *p) {}
-static inline void clear_freeze_flag(struct task_struct *p) {}
-static inline int thaw_process(struct task_struct *p) { return 1; }
 
-static inline void refrigerator(void) {}
 static inline int freeze_processes(void) { BUG(); return 0; }
 static inline void thaw_processes(void) {}
 
-static inline int try_to_freeze(void) { return 0; }
-
 static inline void freezer_do_not_count(void) {}
 static inline void freezer_count(void) {}
 static inline int freezer_should_skip(struct task_struct *p) { return 0; }
kernel/Makefile +1 -1
index 4e1d7df..9844f47 100644
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \
 	    rcupdate.o extable.o params.o posix-timers.o \
 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
kernel/freezer.c new file +122 -0

122 lines not on this page · raw message

kernel/power/process.c +0 -116

125 lines not on this page · raw message

Signature · 3 lines
1.5.3.7

-- 
#24 lore raw

PATCH 2/6 Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

---
 include/linux/freezer.h |   24 +++++----
 kernel/Makefile         |    2 +-
 kernel/freezer.c        |  122 +++++++++++++++++++++++++++++++++++++++++++++++
 kernel/power/process.c  |  116 --------------------------------------------
 4 files changed, 136 insertions(+), 128 deletions(-)
 create mode 100644 kernel/freezer.c
include/linux/freezer.h +13 -11
index deddeed..4081768 100644
@@ -6,7 +6,6 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#ifdef CONFIG_PM_SLEEP
 /*
  * Check if a process has been frozen
  */
@@ -39,6 +38,11 @@ static inline void clear_freeze_flag(struct task_struct *p)
 	clear_tsk_thread_flag(p, TIF_FREEZE);
 }
 
+static inline bool should_send_signal(struct task_struct *p)
+{
+	return !(p->flags & PF_FREEZER_NOSIG);
+}
+
 /*
  * Wake up a frozen process
  *
@@ -63,8 +67,6 @@ static inline int thaw_process(struct task_struct *p)
 }
 
 extern void refrigerator(void);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
 
 static inline int try_to_freeze(void)
 {
@@ -75,6 +77,14 @@ static inline int try_to_freeze(void)
 		return 0;
 }
 
+extern bool freeze_task(struct task_struct *p, bool sig_only);
+extern void cancel_freezing(struct task_struct *p);
+
+#ifdef CONFIG_PM_SLEEP
+
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
 /*
  * The PF_FREEZER_SKIP flag should be set by a vfork parent right before it
  * calls wait_for_completion(&vfork) and reset right after it returns from this
@@ -167,18 +177,10 @@ static inline void set_freezable_with_signal(void)
 	__retval;							\
 })
 #else /* !CONFIG_PM_SLEEP */
-static inline int frozen(struct task_struct *p) { return 0; }
-static inline int freezing(struct task_struct *p) { return 0; }
-static inline void set_freeze_flag(struct task_struct *p) {}
-static inline void clear_freeze_flag(struct task_struct *p) {}
-static inline int thaw_process(struct task_struct *p) { return 1; }
 
-static inline void refrigerator(void) {}
 static inline int freeze_processes(void) { BUG(); return 0; }
 static inline void thaw_processes(void) {}
 
-static inline int try_to_freeze(void) { return 0; }
-
 static inline void freezer_do_not_count(void) {}
 static inline void freezer_count(void) {}
 static inline int freezer_should_skip(struct task_struct *p) { return 0; }
kernel/Makefile +1 -1
index 4e1d7df..9844f47 100644
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \
 	    rcupdate.o extable.o params.o posix-timers.o \
 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
kernel/freezer.c new file +122 -0

122 lines not on this page · raw message

kernel/power/process.c +0 -116

125 lines not on this page · raw message

Signature · 3 lines
1.5.3.7

-- 
#23 lore raw

PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c
include/linux/cgroup_freezer.h new file +71 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <clg-NmTC/[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */
include/linux/cgroup_subsys.h +6 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_subsys.h
===================================================================
@@ -50,5 +50,11 @@ SUBSYS(devices)
 #ifdef CONFIG_CGROUP_MEMRLIMIT_CTLR
 SUBSYS(memrlimit_cgroup)
 #endif
 
 /* */
+
+#ifdef CONFIG_CGROUP_FREEZER
+SUBSYS(freezer)
+#endif
+
+/* */
include/linux/freezer.h +12 -4
Index: linux-2.6.27-rc1-mm1/include/linux/freezer.h
===================================================================
@@ -44,26 +44,34 @@ static inline bool should_send_signal(st
 }
 
 /*
  * Wake up a frozen process
  *
- * task_lock() is taken to prevent the race with refrigerator() which may
+ * task_lock() is needed to prevent the race with refrigerator() which may
  * occur if the freezing of tasks fails.  Namely, without the lock, if the
  * freezing of tasks failed, thaw_tasks() might have run before a task in
  * refrigerator() could call frozen_process(), in which case the task would be
  * frozen and no one would thaw it.
  */
-static inline int thaw_process(struct task_struct *p)
+static inline int __thaw_process(struct task_struct *p)
 {
-	task_lock(p);
 	if (frozen(p)) {
 		p->flags &= ~PF_FROZEN;
+		return 1;
+	}
+	clear_freeze_flag(p);
+	return 0;
+}
+
+static inline int thaw_process(struct task_struct *p)
+{
+	task_lock(p);
+	if (__thaw_process(p) == 1) {
 		task_unlock(p);
 		wake_up_process(p);
 		return 1;
 	}
-	clear_freeze_flag(p);
 	task_unlock(p);
 	return 0;
 }
 
 extern void refrigerator(void);
init/Kconfig +7 -0
Index: linux-2.6.27-rc1-mm1/init/Kconfig
===================================================================
@@ -329,10 +329,17 @@ config GROUP_SCHED
 	default n
 	help
 	  This feature lets CPU scheduler recognize task groups and control CPU
 	  bandwidth allocation to such task groups.
 
+config CGROUP_FREEZER
+        bool "control group freezer subsystem"
+        depends on CGROUPS
+        help
+          Provides a way to freeze and unfreeze all tasks in a
+	  cgroup
+
 config FAIR_GROUP_SCHED
 	bool "Group scheduling for SCHED_OTHER"
 	depends on GROUP_SCHED
 	default GROUP_SCHED
 
kernel/Makefile +1 -0
Index: linux-2.6.27-rc1-mm1/kernel/Makefile
===================================================================
@@ -51,10 +51,11 @@ obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup.o
 obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o
+obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
 obj-$(CONFIG_CPUSETS) += cpuset.o
 obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o
 obj-$(CONFIG_UTS_NS) += utsname.o
 obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
kernel/cgroup_freezer.c new file +328 -0

328 lines not on this page · raw message

#56 lore raw

PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c
include/linux/cgroup_freezer.h new file +71 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */
include/linux/cgroup_subsys.h +6 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_subsys.h
===================================================================
@@ -50,5 +50,11 @@ SUBSYS(devices)
 #ifdef CONFIG_CGROUP_MEMRLIMIT_CTLR
 SUBSYS(memrlimit_cgroup)
 #endif
 
 /* */
+
+#ifdef CONFIG_CGROUP_FREEZER
+SUBSYS(freezer)
+#endif
+
+/* */
include/linux/freezer.h +12 -4
Index: linux-2.6.27-rc1-mm1/include/linux/freezer.h
===================================================================
@@ -44,26 +44,34 @@ static inline bool should_send_signal(st
 }
 
 /*
  * Wake up a frozen process
  *
- * task_lock() is taken to prevent the race with refrigerator() which may
+ * task_lock() is needed to prevent the race with refrigerator() which may
  * occur if the freezing of tasks fails.  Namely, without the lock, if the
  * freezing of tasks failed, thaw_tasks() might have run before a task in
  * refrigerator() could call frozen_process(), in which case the task would be
  * frozen and no one would thaw it.
  */
-static inline int thaw_process(struct task_struct *p)
+static inline int __thaw_process(struct task_struct *p)
 {
-	task_lock(p);
 	if (frozen(p)) {
 		p->flags &= ~PF_FROZEN;
+		return 1;
+	}
+	clear_freeze_flag(p);
+	return 0;
+}
+
+static inline int thaw_process(struct task_struct *p)
+{
+	task_lock(p);
+	if (__thaw_process(p) == 1) {
 		task_unlock(p);
 		wake_up_process(p);
 		return 1;
 	}
-	clear_freeze_flag(p);
 	task_unlock(p);
 	return 0;
 }
 
 extern void refrigerator(void);
init/Kconfig +7 -0
Index: linux-2.6.27-rc1-mm1/init/Kconfig
===================================================================
@@ -329,10 +329,17 @@ config GROUP_SCHED
 	default n
 	help
 	  This feature lets CPU scheduler recognize task groups and control CPU
 	  bandwidth allocation to such task groups.
 
+config CGROUP_FREEZER
+        bool "control group freezer subsystem"
+        depends on CGROUPS
+        help
+          Provides a way to freeze and unfreeze all tasks in a
+	  cgroup
+
 config FAIR_GROUP_SCHED
 	bool "Group scheduling for SCHED_OTHER"
 	depends on GROUP_SCHED
 	default GROUP_SCHED
 
kernel/Makefile +1 -0
Index: linux-2.6.27-rc1-mm1/kernel/Makefile
===================================================================
@@ -51,10 +51,11 @@ obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup.o
 obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o
+obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
 obj-$(CONFIG_CPUSETS) += cpuset.o
 obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o
 obj-$(CONFIG_UTS_NS) += utsname.o
 obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
kernel/cgroup_freezer.c new file +328 -0

328 lines not on this page · raw message

#25 lore raw

PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume

In reply to Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 3 lines
1.5.3.7

-- 
#75 lore raw

PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume

In reply to Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 3 lines
1.5.3.7

-- 
#55 lore raw

PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing

In reply to Matt Helsley

Don't let frozen tasks or cgroups change. This means frozen tasks can't leave their current cgroup for another cgroup. It also means that tasks cannot be added to or removed from a cgroup in the FROZEN state. We enforce these rules by checking for frozen tasks and cgroups in the can_attach() function.

---
Changes since v4:
v5:
Checked use of task alloc lock for races with swsusp freeze/thaw --
looks safe because there are explicit barriers to handle freeze/thaw races for individual tasks, we explicitly handle partial group freezing, and partial group thawing should be resolved without changing swsusp's loop. This should answer Li Zefan's last comment re: races between freeze and thaw.

 kernel/cgroup_freezer.c |   43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)
kernel/cgroup_freezer.c +26 -17
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -90,26 +90,44 @@ static void freezer_destroy(struct cgrou
 			    struct cgroup *cgroup)
 {
 	kfree(cgroup_freezer(cgroup));
 }
 
+/* Task is frozen or will freeze immediately when next it gets woken */
+static bool is_task_frozen_enough(struct task_struct *task)
+{
+	return frozen(task) ||
+		(task_is_stopped_or_traced(task) && freezing(task));
+}
 
+/*
+ * The call to cgroup_lock() in the freezer.state write method prevents
+ * a write to that file racing against an attach, and hence the
+ * can_attach() result will remain valid until the attach completes.
+ */
 static int freezer_can_attach(struct cgroup_subsys *ss,
 			      struct cgroup *new_cgroup,
 			      struct task_struct *task)
 {
 	struct freezer *freezer;
-	int retval = 0;
+	int retval;
+
+	/* Anything frozen can't move or be moved to/from */
+
+	if (is_task_frozen_enough(task))
+		return -EBUSY;
 
-	/*
-	 * The call to cgroup_lock() in the freezer.state write method prevents
-	 * a write to that file racing against an attach, and hence the
-	 * can_attach() result will remain valid until the attach completes.
-	 */
 	freezer = cgroup_freezer(new_cgroup);
 	if (freezer->state == STATE_FROZEN)
+		return -EBUSY;
+
+	retval = 0;
+	task_lock(task);
+	freezer = task_freezer(task);
+	if (freezer->state == STATE_FROZEN)
 		retval = -EBUSY;
+	task_unlock(task);
 	return retval;
 }
 
 static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task)
 {
@@ -140,16 +158,11 @@ static void check_if_frozen(struct cgrou
 	unsigned int nfrozen = 0, ntotal = 0;
 
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		ntotal++;
-		/*
-		 * Task is frozen or will freeze immediately when next it gets
-		 * woken
-		 */
-		if (frozen(task) ||
-		    (task_is_stopped_or_traced(task) && freezing(task)))
+		if (is_task_frozen_enough(task))
 			nfrozen++;
 	}
 
 	/*
 	 * Transition to FROZEN when no new tasks can be added ensures
@@ -196,15 +209,11 @@ static int try_to_freeze_cgroup(struct c
 	freezer->state = STATE_FREEZING;
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		if (!freeze_task(task, true))
 			continue;
-		if (task_is_stopped_or_traced(task) && freezing(task))
-			/*
-			 * The freeze flag is set so these tasks will
-			 * immediately go into the fridge upon waking.
-			 */
+		if (is_task_frozen_enough(task))
 			continue;
 		if (!freezing(task) && !freezer_should_skip(task))
 			num_cant_freeze_now++;
 	}
 	cgroup_iter_end(cgroup, &it);
#81 lore raw

PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing

In reply to Matt Helsley

Don't let frozen tasks or cgroups change. This means frozen tasks can't leave their current cgroup for another cgroup. It also means that tasks cannot be added to or removed from a cgroup in the FROZEN state. We enforce these rules by checking for frozen tasks and cgroups in the can_attach() function.

---
Changes since v4:
v5:
Checked use of task alloc lock for races with swsusp freeze/thaw --
looks safe because there are explicit barriers to handle freeze/thaw races for individual tasks, we explicitly handle partial group freezing, and partial group thawing should be resolved without changing swsusp's loop. This should answer Li Zefan's last comment re: races between freeze and thaw.

 kernel/cgroup_freezer.c |   43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)
kernel/cgroup_freezer.c +26 -17
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -90,26 +90,44 @@ static void freezer_destroy(struct cgrou
 			    struct cgroup *cgroup)
 {
 	kfree(cgroup_freezer(cgroup));
 }
 
+/* Task is frozen or will freeze immediately when next it gets woken */
+static bool is_task_frozen_enough(struct task_struct *task)
+{
+	return frozen(task) ||
+		(task_is_stopped_or_traced(task) && freezing(task));
+}
 
+/*
+ * The call to cgroup_lock() in the freezer.state write method prevents
+ * a write to that file racing against an attach, and hence the
+ * can_attach() result will remain valid until the attach completes.
+ */
 static int freezer_can_attach(struct cgroup_subsys *ss,
 			      struct cgroup *new_cgroup,
 			      struct task_struct *task)
 {
 	struct freezer *freezer;
-	int retval = 0;
+	int retval;
+
+	/* Anything frozen can't move or be moved to/from */
+
+	if (is_task_frozen_enough(task))
+		return -EBUSY;
 
-	/*
-	 * The call to cgroup_lock() in the freezer.state write method prevents
-	 * a write to that file racing against an attach, and hence the
-	 * can_attach() result will remain valid until the attach completes.
-	 */
 	freezer = cgroup_freezer(new_cgroup);
 	if (freezer->state == STATE_FROZEN)
+		return -EBUSY;
+
+	retval = 0;
+	task_lock(task);
+	freezer = task_freezer(task);
+	if (freezer->state == STATE_FROZEN)
 		retval = -EBUSY;
+	task_unlock(task);
 	return retval;
 }
 
 static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task)
 {
@@ -140,16 +158,11 @@ static void check_if_frozen(struct cgrou
 	unsigned int nfrozen = 0, ntotal = 0;
 
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		ntotal++;
-		/*
-		 * Task is frozen or will freeze immediately when next it gets
-		 * woken
-		 */
-		if (frozen(task) ||
-		    (task_is_stopped_or_traced(task) && freezing(task)))
+		if (is_task_frozen_enough(task))
 			nfrozen++;
 	}
 
 	/*
 	 * Transition to FROZEN when no new tasks can be added ensures
@@ -196,15 +209,11 @@ static int try_to_freeze_cgroup(struct c
 	freezer->state = STATE_FREEZING;
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		if (!freeze_task(task, true))
 			continue;
-		if (task_is_stopped_or_traced(task) && freezing(task))
-			/*
-			 * The freeze flag is set so these tasks will
-			 * immediately go into the fridge upon waking.
-			 */
+		if (is_task_frozen_enough(task))
 			continue;
 		if (!freezing(task) && !freezer_should_skip(task))
 			num_cant_freeze_now++;
 	}
 	cgroup_iter_end(cgroup, &it);
#57 lore raw

PATCH 6/6 Container Freezer: Use cgroup write_string method

In reply to Matt Helsley

Use the new cgroup write_string method rather than the raw write method because it better matches the needs of the freezer cgroup subsystem.

---
 kernel/cgroup_freezer.c |   21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
kernel/cgroup_freezer.c +5 -16
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -29,11 +29,10 @@
 static const char *freezer_state_strs[] = {
 	"RUNNING",
 	"FREEZING",
 	"FROZEN",
 };
-#define STATE_MAX_STRLEN 8
 
 /*
  * State diagram (transition labels in parenthesis):
  *
  *  RUNNING -(FROZEN)-> FREEZING -(FROZEN)-> FROZEN
@@ -278,27 +277,17 @@ out:
 	spin_unlock_irq(&freezer->lock);
 
 	return retval;
 }
 
-static ssize_t freezer_write(struct cgroup *cgroup,
-			     struct cftype *cft,
-			     struct file *file,
-			     const char __user *userbuf,
-			     size_t nbytes, loff_t *unused_ppos)
+static int freezer_write(struct cgroup *cgroup,
+			 struct cftype *cft,
+			 const char *buffer)
 {
-	char buffer[STATE_MAX_STRLEN + 1];
-	int retval = 0;
+	int retval;
 	enum freezer_state goal_state;
 
-	if (nbytes >= PATH_MAX)
-		return -E2BIG;
-	nbytes = min(sizeof(buffer) - 1, nbytes);
-	if (copy_from_user(buffer, userbuf, nbytes))
-		return -EFAULT;
-	buffer[nbytes + 1] = 0; /* nul-terminate */
-	strstrip(buffer); /* remove any trailing whitespace */
 	if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0)
 		goal_state = STATE_RUNNING;
 	else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0)
 		goal_state = STATE_FROZEN;
 	else
@@ -313,11 +302,11 @@ static ssize_t freezer_write(struct cgro
 
 static struct cftype files[] = {
 	{
 		.name = "state",
 		.read_seq_string = freezer_read,
-		.write = freezer_write,
+		.write_string = freezer_write,
 	},
 };
 
 static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
 {
#83 lore raw

PATCH 6/6 Container Freezer: Use cgroup write_string method

In reply to Matt Helsley

Use the new cgroup write_string method rather than the raw write method because it better matches the needs of the freezer cgroup subsystem.

---
 kernel/cgroup_freezer.c |   21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
kernel/cgroup_freezer.c +5 -16
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -29,11 +29,10 @@
 static const char *freezer_state_strs[] = {
 	"RUNNING",
 	"FREEZING",
 	"FROZEN",
 };
-#define STATE_MAX_STRLEN 8
 
 /*
  * State diagram (transition labels in parenthesis):
  *
  *  RUNNING -(FROZEN)-> FREEZING -(FROZEN)-> FROZEN
@@ -278,27 +277,17 @@ out:
 	spin_unlock_irq(&freezer->lock);
 
 	return retval;
 }
 
-static ssize_t freezer_write(struct cgroup *cgroup,
-			     struct cftype *cft,
-			     struct file *file,
-			     const char __user *userbuf,
-			     size_t nbytes, loff_t *unused_ppos)
+static int freezer_write(struct cgroup *cgroup,
+			 struct cftype *cft,
+			 const char *buffer)
 {
-	char buffer[STATE_MAX_STRLEN + 1];
-	int retval = 0;
+	int retval;
 	enum freezer_state goal_state;
 
-	if (nbytes >= PATH_MAX)
-		return -E2BIG;
-	nbytes = min(sizeof(buffer) - 1, nbytes);
-	if (copy_from_user(buffer, userbuf, nbytes))
-		return -EFAULT;
-	buffer[nbytes + 1] = 0; /* nul-terminate */
-	strstrip(buffer); /* remove any trailing whitespace */
 	if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0)
 		goal_state = STATE_RUNNING;
 	else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0)
 		goal_state = STATE_FROZEN;
 	else
@@ -313,11 +302,11 @@ static ssize_t freezer_write(struct cgro
 
 static struct cftype files[] = {
 	{
 		.name = "state",
 		.read_seq_string = freezer_read,
-		.write = freezer_write,
+		.write_string = freezer_write,
 	},
 };
 
 static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
 {
#76 lore raw

PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume

In reply to Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 3 lines
1.5.3.7

-- 
#58 lore raw

PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c
include/linux/cgroup_freezer.h new file +71 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */
include/linux/cgroup_subsys.h +6 -0
Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_subsys.h
===================================================================
@@ -50,5 +50,11 @@ SUBSYS(devices)
 #ifdef CONFIG_CGROUP_MEMRLIMIT_CTLR
 SUBSYS(memrlimit_cgroup)
 #endif
 
 /* */
+
+#ifdef CONFIG_CGROUP_FREEZER
+SUBSYS(freezer)
+#endif
+
+/* */
include/linux/freezer.h +12 -4
Index: linux-2.6.27-rc1-mm1/include/linux/freezer.h
===================================================================
@@ -44,26 +44,34 @@ static inline bool should_send_signal(st
 }
 
 /*
  * Wake up a frozen process
  *
- * task_lock() is taken to prevent the race with refrigerator() which may
+ * task_lock() is needed to prevent the race with refrigerator() which may
  * occur if the freezing of tasks fails.  Namely, without the lock, if the
  * freezing of tasks failed, thaw_tasks() might have run before a task in
  * refrigerator() could call frozen_process(), in which case the task would be
  * frozen and no one would thaw it.
  */
-static inline int thaw_process(struct task_struct *p)
+static inline int __thaw_process(struct task_struct *p)
 {
-	task_lock(p);
 	if (frozen(p)) {
 		p->flags &= ~PF_FROZEN;
+		return 1;
+	}
+	clear_freeze_flag(p);
+	return 0;
+}
+
+static inline int thaw_process(struct task_struct *p)
+{
+	task_lock(p);
+	if (__thaw_process(p) == 1) {
 		task_unlock(p);
 		wake_up_process(p);
 		return 1;
 	}
-	clear_freeze_flag(p);
 	task_unlock(p);
 	return 0;
 }
 
 extern void refrigerator(void);
init/Kconfig +7 -0
Index: linux-2.6.27-rc1-mm1/init/Kconfig
===================================================================
@@ -329,10 +329,17 @@ config GROUP_SCHED
 	default n
 	help
 	  This feature lets CPU scheduler recognize task groups and control CPU
 	  bandwidth allocation to such task groups.
 
+config CGROUP_FREEZER
+        bool "control group freezer subsystem"
+        depends on CGROUPS
+        help
+          Provides a way to freeze and unfreeze all tasks in a
+	  cgroup
+
 config FAIR_GROUP_SCHED
 	bool "Group scheduling for SCHED_OTHER"
 	depends on GROUP_SCHED
 	default GROUP_SCHED
 
kernel/Makefile +1 -0
Index: linux-2.6.27-rc1-mm1/kernel/Makefile
===================================================================
@@ -51,10 +51,11 @@ obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup.o
 obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o
+obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
 obj-$(CONFIG_CPUSETS) += cpuset.o
 obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o
 obj-$(CONFIG_UTS_NS) += utsname.o
 obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
kernel/cgroup_freezer.c new file +328 -0

328 lines not on this page · raw message

#84 lore raw

PATCH 6/6 Container Freezer: Use cgroup write_string method

In reply to Matt Helsley

Use the new cgroup write_string method rather than the raw write method because it better matches the needs of the freezer cgroup subsystem.

---
 kernel/cgroup_freezer.c |   21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
kernel/cgroup_freezer.c +5 -16
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -29,11 +29,10 @@
 static const char *freezer_state_strs[] = {
 	"RUNNING",
 	"FREEZING",
 	"FROZEN",
 };
-#define STATE_MAX_STRLEN 8
 
 /*
  * State diagram (transition labels in parenthesis):
  *
  *  RUNNING -(FROZEN)-> FREEZING -(FROZEN)-> FROZEN
@@ -278,27 +277,17 @@ out:
 	spin_unlock_irq(&freezer->lock);
 
 	return retval;
 }
 
-static ssize_t freezer_write(struct cgroup *cgroup,
-			     struct cftype *cft,
-			     struct file *file,
-			     const char __user *userbuf,
-			     size_t nbytes, loff_t *unused_ppos)
+static int freezer_write(struct cgroup *cgroup,
+			 struct cftype *cft,
+			 const char *buffer)
 {
-	char buffer[STATE_MAX_STRLEN + 1];
-	int retval = 0;
+	int retval;
 	enum freezer_state goal_state;
 
-	if (nbytes >= PATH_MAX)
-		return -E2BIG;
-	nbytes = min(sizeof(buffer) - 1, nbytes);
-	if (copy_from_user(buffer, userbuf, nbytes))
-		return -EFAULT;
-	buffer[nbytes + 1] = 0; /* nul-terminate */
-	strstrip(buffer); /* remove any trailing whitespace */
 	if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0)
 		goal_state = STATE_RUNNING;
 	else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0)
 		goal_state = STATE_FROZEN;
 	else
@@ -313,11 +302,11 @@ static ssize_t freezer_write(struct cgro
 
 static struct cftype files[] = {
 	{
 		.name = "state",
 		.read_seq_string = freezer_read,
-		.write = freezer_write,
+		.write_string = freezer_write,
 	},
 };
 
 static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
 {
#4 lore raw

PATCH 1/6 Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#26 lore raw

PATCH 2/6 Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

---
 include/linux/freezer.h |   24 +++++----
 kernel/Makefile         |    2 +-
 kernel/freezer.c        |  122 +++++++++++++++++++++++++++++++++++++++++++++++
 kernel/power/process.c  |  116 --------------------------------------------
 4 files changed, 136 insertions(+), 128 deletions(-)
 create mode 100644 kernel/freezer.c
include/linux/freezer.h +13 -11
index deddeed..4081768 100644
@@ -6,7 +6,6 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#ifdef CONFIG_PM_SLEEP
 /*
  * Check if a process has been frozen
  */
@@ -39,6 +38,11 @@ static inline void clear_freeze_flag(struct task_struct *p)
 	clear_tsk_thread_flag(p, TIF_FREEZE);
 }
 
+static inline bool should_send_signal(struct task_struct *p)
+{
+	return !(p->flags & PF_FREEZER_NOSIG);
+}
+
 /*
  * Wake up a frozen process
  *
@@ -63,8 +67,6 @@ static inline int thaw_process(struct task_struct *p)
 }
 
 extern void refrigerator(void);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
 
 static inline int try_to_freeze(void)
 {
@@ -75,6 +77,14 @@ static inline int try_to_freeze(void)
 		return 0;
 }
 
+extern bool freeze_task(struct task_struct *p, bool sig_only);
+extern void cancel_freezing(struct task_struct *p);
+
+#ifdef CONFIG_PM_SLEEP
+
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
 /*
  * The PF_FREEZER_SKIP flag should be set by a vfork parent right before it
  * calls wait_for_completion(&vfork) and reset right after it returns from this
@@ -167,18 +177,10 @@ static inline void set_freezable_with_signal(void)
 	__retval;							\
 })
 #else /* !CONFIG_PM_SLEEP */
-static inline int frozen(struct task_struct *p) { return 0; }
-static inline int freezing(struct task_struct *p) { return 0; }
-static inline void set_freeze_flag(struct task_struct *p) {}
-static inline void clear_freeze_flag(struct task_struct *p) {}
-static inline int thaw_process(struct task_struct *p) { return 1; }
 
-static inline void refrigerator(void) {}
 static inline int freeze_processes(void) { BUG(); return 0; }
 static inline void thaw_processes(void) {}
 
-static inline int try_to_freeze(void) { return 0; }
-
 static inline void freezer_do_not_count(void) {}
 static inline void freezer_count(void) {}
 static inline int freezer_should_skip(struct task_struct *p) { return 0; }
kernel/Makefile +1 -1
index 4e1d7df..9844f47 100644
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \
 	    rcupdate.o extable.o params.o posix-timers.o \
 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
kernel/freezer.c new file +122 -0

122 lines not on this page · raw message

kernel/power/process.c +0 -116

125 lines not on this page · raw message

Signature · 3 lines
1.5.3.7

-- 
#82 lore raw

PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing

In reply to Matt Helsley

Don't let frozen tasks or cgroups change. This means frozen tasks can't leave their current cgroup for another cgroup. It also means that tasks cannot be added to or removed from a cgroup in the FROZEN state. We enforce these rules by checking for frozen tasks and cgroups in the can_attach() function.

---
Changes since v4:
v5:
Checked use of task alloc lock for races with swsusp freeze/thaw --
looks safe because there are explicit barriers to handle freeze/thaw races for individual tasks, we explicitly handle partial group freezing, and partial group thawing should be resolved without changing swsusp's loop. This should answer Li Zefan's last comment re: races between freeze and thaw.

 kernel/cgroup_freezer.c |   43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)
kernel/cgroup_freezer.c +26 -17
Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
@@ -90,26 +90,44 @@ static void freezer_destroy(struct cgrou
 			    struct cgroup *cgroup)
 {
 	kfree(cgroup_freezer(cgroup));
 }
 
+/* Task is frozen or will freeze immediately when next it gets woken */
+static bool is_task_frozen_enough(struct task_struct *task)
+{
+	return frozen(task) ||
+		(task_is_stopped_or_traced(task) && freezing(task));
+}
 
+/*
+ * The call to cgroup_lock() in the freezer.state write method prevents
+ * a write to that file racing against an attach, and hence the
+ * can_attach() result will remain valid until the attach completes.
+ */
 static int freezer_can_attach(struct cgroup_subsys *ss,
 			      struct cgroup *new_cgroup,
 			      struct task_struct *task)
 {
 	struct freezer *freezer;
-	int retval = 0;
+	int retval;
+
+	/* Anything frozen can't move or be moved to/from */
+
+	if (is_task_frozen_enough(task))
+		return -EBUSY;
 
-	/*
-	 * The call to cgroup_lock() in the freezer.state write method prevents
-	 * a write to that file racing against an attach, and hence the
-	 * can_attach() result will remain valid until the attach completes.
-	 */
 	freezer = cgroup_freezer(new_cgroup);
 	if (freezer->state == STATE_FROZEN)
+		return -EBUSY;
+
+	retval = 0;
+	task_lock(task);
+	freezer = task_freezer(task);
+	if (freezer->state == STATE_FROZEN)
 		retval = -EBUSY;
+	task_unlock(task);
 	return retval;
 }
 
 static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task)
 {
@@ -140,16 +158,11 @@ static void check_if_frozen(struct cgrou
 	unsigned int nfrozen = 0, ntotal = 0;
 
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		ntotal++;
-		/*
-		 * Task is frozen or will freeze immediately when next it gets
-		 * woken
-		 */
-		if (frozen(task) ||
-		    (task_is_stopped_or_traced(task) && freezing(task)))
+		if (is_task_frozen_enough(task))
 			nfrozen++;
 	}
 
 	/*
 	 * Transition to FROZEN when no new tasks can be added ensures
@@ -196,15 +209,11 @@ static int try_to_freeze_cgroup(struct c
 	freezer->state = STATE_FREEZING;
 	cgroup_iter_start(cgroup, &it);
 	while ((task = cgroup_iter_next(cgroup, &it))) {
 		if (!freeze_task(task, true))
 			continue;
-		if (task_is_stopped_or_traced(task) && freezing(task))
-			/*
-			 * The freeze flag is set so these tasks will
-			 * immediately go into the fridge upon waking.
-			 */
+		if (is_task_frozen_enough(task))
 			continue;
 		if (!freezing(task) && !freezer_should_skip(task))
 			num_cant_freeze_now++;
 	}
 	cgroup_iter_end(cgroup, &it);
#86 lore raw
In reply to a message not in the archive
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

Cheers,
-Matt Helsley

#87 lore raw
In reply to Matt Helsley
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

Cheers,
-Matt Helsley

#88 lore raw
In reply to Matt Helsley
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

Cheers,
-Matt Helsley

#78 lore raw

Re: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume

In reply to a message not in the archive

Hi.

Quoted 10 lines · Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

I understand the freezer pretty well, so maybe I can help a little.

Quoted 29 lines
---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 1 line
1.5.3.7
Acked-by on v1 4/6
#79 lore raw

Re: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume

In reply to Matt Helsley

Hi.

Quoted 10 lines · Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

I understand the freezer pretty well, so maybe I can help a little.

Quoted 29 lines
---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 1 line
1.5.3.7
#6 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to a message not in the archive

Hi.

Quoted 6 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#7 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley

Hi.

Quoted 6 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#28 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive

Hi.

Quoted 11 lines · Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

Acked-by on v1 2/6
#30 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Hi.

Quoted 11 lines · Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

Acked-by on v1 4/6
#80 lore raw

Re: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume

In reply to Matt Helsley

Hi.

Quoted 10 lines · Matt Helsley

When a system is resumed after a suspend, it will also unfreeze frozen cgroups.

This patchs modifies the resume sequence to skip the tasks which are part of a frozen control group.

I understand the freezer pretty well, so maybe I can help a little.

Quoted 29 lines
---
 kernel/power/process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/power/process.c +4 -0
index 444cea8..ce9e280 100644
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/freezer.h>
+#include <linux/cgroup_freezer.h>
 
 /* 
  * Timeout for stopping processes
@@ -135,6 +136,9 @@ static void thaw_tasks(bool nosig_only)
 		if (nosig_only && should_send_signal(p))
 			continue;
 
+		if (cgroup_frozen(p))
+			continue;
+
 		thaw_process(p);
 	} while_each_thread(g, p);
 	read_unlock(&tasklist_lock);
Signature · 1 line
1.5.3.7
#8 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley

Hi.

Quoted 6 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
Acked-by on v1 2/6
#31 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Hi.

Quoted 11 lines · Matt Helsley

Now that the TIF_FREEZE flag is available in all architectures, extract the refrigerator() and freeze_task() from kernel/power/process.c and make it available to all.

The refrigerator() can now be used in a control group subsystem implementing a control group freezer.

#9 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Nigel Cunningham
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

Quoted 303 lines

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#10 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Nigel Cunningham
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

Quoted 303 lines

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#11 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Nigel Cunningham
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

Quoted 303 lines

Regards,

Nigel

Quoted 298 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -137,10 +137,11 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_USEDFPU		8	/* FPU was used by this task
 					 * this quantum (SMP) */
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -150,9 +151,10 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -235,10 +235,11 @@ register struct thread_info *current_thr
  *       an immediate value in instructions such as andcc.
  */
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -247,10 +248,11 @@ register struct thread_info *current_thr
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
 				 _TIF_NEED_RESCHED | _TIF_PERFCTR)
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -72,16 +72,18 @@ register struct thread_info *__current_t
 #define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
 #define TIF_UAC_NOFIX		6
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
 
 /* Work to do on any return to userspace.  */

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -94,10 +94,11 @@ static inline struct thread_info *curren
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_SINGLE_STEP	(1 << TIF_SINGLE_STEP)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK				\

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -86,17 +86,19 @@ struct thread_info {
 #define TIF_SIGPENDING		2	/* signal pending */
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 #endif /* __KERNEL__ */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -87,17 +87,19 @@ static inline struct thread_info *curren
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -50,7 +50,8 @@ struct thread_info {
 #define TIF_SIGPENDING		6	/* signal pending */
 #define TIF_NEED_RESCHED	7	/* rescheduling necessary */
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		19	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -82,16 +82,18 @@ static inline struct thread_info *curren
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -96,10 +96,11 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	17	/* true if poll_idle() is polling 
 					   TIF_NEED_RESCHED */
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -108,10 +109,11 @@ static inline struct thread_info *curren
 #define _TIF_SINGLE_STEP	(1<<TIF_SINGLE_STEP)
 #define _TIF_MCCK_PENDING	(1<<TIF_MCCK_PENDING)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
 #define PREEMPT_ACTIVE		0x4000000
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -67,15 +67,17 @@ static inline struct thread_info *curren
 					 */
 #define TIF_RESTART_BLOCK 	4
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -132,18 +132,20 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
 #define TIF_IRET		4	/* return with iret */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
 
 /*

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -56,17 +56,19 @@ struct thread_info {
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		19	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
 
 #endif /* __KERNEL__ */
#89 lore raw
In reply to Matt Helsley
Quoted 9 lines · Matt Helsley
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 8 lines
Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

No problem.

If there are not too many new regressions reported today, I'll have a look at the patches in the evening.

Thanks,
Rafael

#91 lore raw
In reply to a message not in the archive
Quoted 9 lines · Matt Helsley
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 8 lines
Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

No problem.

If there are not too many new regressions reported today, I'll have a look at the patches in the evening.

Thanks,
Rafael

#92 lore raw
In reply to Matt Helsley
Quoted 9 lines · Matt Helsley
Quoted 4 lines · Matt Helsley

This patch series introduces a cgroup subsystem that utilizes the swsusp freezer to freeze a group of tasks. It's immediately useful for batch job management scripts. It should also be useful in the future for implementing container checkpoint/restart.

<snip>

Quoted 8 lines
Quoted 2 lines

Andrew, since I hear Rafael doesn't have time to review these (again) at this time, please consider these patches for -mm.

Argh -- that "(again)" is ripe for misinterpretation! Rafael has
reviewed and commented on these patches often in the past but, from what I hear, lacks the time to do so now. Hence I'm sending these to -mm.

Sorry about the wording Rafael.

No problem.

If there are not too many new regressions reported today, I'll have a look at the patches in the evening.

Thanks,
Rafael

#29 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive

Hi,

kernel/Makefile line 8

Quoted 8 lines · Matt Helsley
kernel/Makefile +1 -1
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

Thanks,

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
#32 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Hi,

Le Thu, 31 Jul 2008 22:07:01 -0700,
Matt Helsley <[email protected]> a écrit :

kernel/Makefile line 8

Quoted 8 lines
kernel/Makefile +1 -1
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#54 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Hi,

kernel/Makefile line 8

Quoted 8 lines · Matt Helsley
kernel/Makefile +1 -1
@@ -5,7 +5,7 @@
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
-	    signal.o sys.o kmod.o workqueue.o pid.o \
+	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

Thanks,

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#33 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Thomas Petazzoni

On Fri, 2008-08-01 at 16:27 +-0200, Thomas Petazzoni wrote:
+AD4 Hi,
+AD4
+AD4 Le Thu, 31 Jul 2008 22:07:01 -0700,
+AD4 Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4 a +AOk-crit :
+AD4
+AD4 +AD4 --- a/kernel/Makefile
+AD4 +AD4 +-+-+- b/kernel/Makefile
+AD4 +AD4 +AEAAQA -5,7 +-5,7 +AEAAQA

+AD4 +AD4  obj-y     +AD0 sched.o fork.o exec+AF8-domain.o panic.o printk.o +AFw
+AD4 +AD4  	    cpu.o exit.o itimer.o time.o softirq.o resource.o +AFw
+AD4 +AD4  	    sysctl.o capability.o ptrace.o timer.o user.o +AFw

+AD4 +AD4 - signal.o sys.o kmod.o workqueue.o pid.o +AFw
+AD4 +AD4 +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o +AFw
+AD4
+AD4 I have the impression that the code in kernel/power/process.c was +AD4 compiled only if CONFIG+AF8-PM+AF8-SLEEP was set. Now that the code has been +AD4 moved to kernel/freezer.c, it is unconditionnaly compiled in every +AD4 kernel. Is that correct ?
+AD4
+AD4 If so, is it possible to put this new feature under some
+AD4 CONFIG+AF8-SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Signed-off-by Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4

---
kernel/Makefile +AHw 3 +-+--
kernel/power/Kconfig +AHw 3 +-+-+-

 2 files changed, 5 insertions(+-), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/kernel/Makefile +AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0 --- linux-2.6.27-rc1-mm1.orig/kernel/Makefile
+-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile
+AEAAQA -5,7 +-5,7 +AEAAQA
obj-y +AD0 sched.o fork.o exec+AF8-domain.o panic.o printk.o +AFw
cpu.o exit.o itimer.o time.o softirq.o resource.o +AFw
sysctl.o capability.o ptrace.o timer.o user.o +AFw
- signal.o sys.o kmod.o workqueue.o pid.o freezer.o +AFw
+- signal.o sys.o kmod.o workqueue.o pid.o +AFw
rcupdate.o extable.o params.o posix-timers.o +AFw
kthread.o wait.o kfifo.o sys+AF8-ni.o posix-cpu-timers.o mutex.o +AFw
hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o +AFw
+AEAAQA -24,6 +-24,7 +AEAAQA CFLAGS+AF8-REMOVE+AF8-sched+AF8-clock.o +AD0 -pg
CFLAGS+AF8-REMOVE+AF8-sched.o +AD0 -mno-spe -pg
endif

+-obj-+ACQ(CONFIG+AF8-FREEZER) +-+AD0 freezer.o
obj-+ACQ(CONFIG+AF8-PROFILING) +-+AD0 profile.o
obj-+ACQ(CONFIG+AF8-SYSCTL+AF8-SYSCALL+AF8-CHECK) +-+AD0 sysctl+AF8-check.o
obj-+ACQ(CONFIG+AF8-STACKTRACE) +-+AD0 stacktrace.o
Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig +AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0 --- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig
+-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig
+AEAAQA -85,6 +-85,9 +AEAAQA config PM+AF8-SLEEP
depends on SUSPEND +AHwAfA HIBERNATION +AHwAfA XEN+AF8-SAVE+AF8-RESTORE
default y

+-config FREEZER
+-	def+AF8-bool PM+AF8-SLEEP +AHwAfA CGROUP+AF8-FREEZER
+-

config SUSPEND
bool +ACI-Suspend to RAM and standby+ACI depends on PM +ACYAJg ARCH+AF8-SUSPEND+AF8-POSSIBLE

#52 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Thomas Petazzoni
Quoted 12 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 2 lines
Quoted 1 line

If so, is it possible to put this new feature under some

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

 kernel/Makefile      |   3 +-+--
 kernel/power/Kconfig |   3 +-+-+-
 2 files changed, 5 insertions(+-), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/kernel/Makefile ===================================================================--- linux-2.6.27-rc1-mm1.orig/kernel/Makefile

+-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile
@@-5,7 +-5,7 @@ obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \ 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \ 	    sysctl.o capability.o ptrace.o timer.o user.o \-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \+-	    signal.o sys.o kmod.o workqueue.o pid.o \ 	    rcupdate.o extable.o params.o posix-timers.o \ 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \@@-24,6 +-24,7 @@CFLAGS_REMOVE_sched_clock.o =-pg

CFLAGS_REMOVE_sched.o =-mno-spe -pg
endif

+-obj-$CONFIG_FREEZER) +-=freezer.o
obj-$CONFIG_PROFILING) +-=profile.o
obj-$CONFIG_SYSCTL_SYSCALL_CHECK) +-=sysctl_check.o
obj-$CONFIG_STACKTRACE) +-=stacktrace.o
Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig ===================================================================--- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig +-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig
@@-85,6 +-85,9 @@config PM_SLEEP
depends on SUSPEND ||HIBERNATION ||XEN_SAVE_RESTORE
default y

+-config FREEZER
+-	def_bool PM_SLEEP ||CGROUP_FREEZER
+-

config SUSPEND
bool "Suspend to RAM and standby" depends on PM &&ARCH_SUSPEND_POSSIBLE

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#53 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Thomas Petazzoni
Quoted 12 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 2 lines
Quoted 1 line

If so, is it possible to put this new feature under some

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

 kernel/Makefile      |   3 +-+--
 kernel/power/Kconfig |   3 +-+-+-
 2 files changed, 5 insertions(+-), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/kernel/Makefile ===================================================================--- linux-2.6.27-rc1-mm1.orig/kernel/Makefile

+-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile
@@-5,7 +-5,7 @@ obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \ 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \ 	    sysctl.o capability.o ptrace.o timer.o user.o \-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \+-	    signal.o sys.o kmod.o workqueue.o pid.o \ 	    rcupdate.o extable.o params.o posix-timers.o \ 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \@@-24,6 +-24,7 @@CFLAGS_REMOVE_sched_clock.o =-pg

CFLAGS_REMOVE_sched.o =-mno-spe -pg
endif

+-obj-$CONFIG_FREEZER) +-=freezer.o
obj-$CONFIG_PROFILING) +-=profile.o
obj-$CONFIG_SYSCTL_SYSCALL_CHECK) +-=sysctl_check.o
obj-$CONFIG_STACKTRACE) +-=stacktrace.o
Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig ===================================================================--- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig +-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig
@@-85,6 +-85,9 @@config PM_SLEEP
depends on SUSPEND ||HIBERNATION ||XEN_SAVE_RESTORE
default y

+-config FREEZER
+-	def_bool PM_SLEEP ||CGROUP_FREEZER
+-

config SUSPEND
bool "Suspend to RAM and standby" depends on PM &&ARCH_SUSPEND_POSSIBLE

Acked-by Pavel Machek Acked-by Serge E. Hallyn Tested-by
#13 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to a message not in the archive
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <clg-NmTC/[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
author Acked-by Pavel Machek Acked-by Serge E. Hallyn Tested-by
#14 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Cedric Le Goater
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
author Acked-by Pavel Machek Acked-by Serge E. Hallyn Tested-by
#15 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Cedric Le Goater
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)
arch/sparc/include/asm/thread_info_32.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
arch/sparc/include/asm/thread_info_64.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \
include/asm-alpha/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)
include/asm-avr32/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 
include/asm-cris/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
include/asm-h8300/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-m68k/thread_info.h +1 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */
include/asm-m68knommu/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 
include/asm-s390/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 
include/asm-um/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif
include/asm-xtensa/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */
arch/parisc/include/asm/thread_info.h +2 -0
Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
#34 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

On Friday, 1 of August 2008, Matt Helsley wrote:> > On Fri, 2008-08-01 at 16:27 +-0200, Thomas Petazzoni wrote:> > Hi,> > > > Le Thu, 31 Jul 2008 22:07:01 -0700,> > Matt Helsley <[email protected]> a écrit :> > > > > --- a/kernel/Makefile> > > +-+-+- b/kernel/Makefile> > > @@ -5,7 +-5,7 @@> > > obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ > > cpu.o exit.o itimer.o time.o softirq.o resource.o \ > > sysctl.o capability.o ptrace.o timer.o user.o \ > > - signal.o sys.o kmod.o workqueue.o pid.o \ > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \ > > > I have the impression that the code in kernel/power/process.c was> > compiled only if CONFIG_PM_SLEEP was set. Now that the code has been> > moved to kernel/freezer.c, it is unconditionnaly compiled in every> > kernel. Is that correct ?> >> > If so, is it possible to put this new feature under some> > CONFIG_SOMETHING option, for people who care about the kernel size ?> > How about making it depend on a combination of CONFIG variables?> Here's an RFC PATCH. Completely untested.> > Signed-off-by: Matt Helsley <[email protected]>
Can you please also make the contents of include/linux/freezer.h depend onCONFIG_FREEZER instead of CONFIG_PM_SLEEP? Also, I'm not really sure if kernel/power/Kconfig is the right place to defineCONFIG_FREEZER.
Perhaps we should even move freezer.c from kernel/power to kerneland define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

Quoted 1 line

---> kernel/Makefile | 3 +-+--> kernel/power/Kconfig | 3 +-+-+-> 2 files changed, 5 insertions(+-), 1 deletion(-)> > Index: linux-2.6.27-rc1-mm1/kernel/Makefile> ===================================================================> --- linux-2.6.27-rc1-mm1.orig/kernel/Makefile> +-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile> @@ -5,7 +-5,7 @@> obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ cpu.o exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ - signal.o sys.o kmod.o workqueue.o pid.o freezer.o \ +- signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ @@ -24,6 +-24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg> CFLAGS_REMOVE_sched.o = -mno-spe -pg> endif> > +-obj-$(CONFIG_FREEZER) +-= freezer.o> obj-$(CONFIG_PROFILING) +-= profile.o> obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) +-= sysctl_check.o> obj-$(CONFIG_STACKTRACE) +-= stacktrace.o> Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig> ===================================================================> --- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig> +-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig> @@ -85,6 +-85,9 @@ config PM_SLEEP> depends on SUSPEND || HIBERNATION || XEN_SAVE_RESTORE> default y> > +-config FREEZER> +- def_bool PM_SLEEP || CGROUP_FREEZER> +-> config SUSPEND> bool "Suspend to RAM and standby"> depends on PM && ARCH_SUSPEND_POSSIBLE> > > > >

¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #: #' # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýýûXÓÌÎÿýýüÿýýüÿÍÆÉÿýýûÿýýüÿýýûÿÑÊÍÿòîïÿýýüÿýýüÿþþýÿÔÍÐÿÕÏÒÿðèéÿöïïÿöïðÿöïïÿöïïÿͼ¿ÿn}‘ÿFƒÿ0ˆµÿ8¡Õÿ@³îÿE¿úÿ•ìþÿ@Íþÿ1Åþÿºþÿ°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #A #/ # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþýýýûâÔÍÏÿüüúÿÎÇÊÿüûúÿüûúÿüûúÿüûúÿÒËÎÿóîîÿýýüÿÔÍÐÿÕÎÑÿõññÿùôôÿôìíÿõîïÿõíîÿôììÿíãäÿ©˜Ÿÿ%r™ÿ-oÿKÿ7§Þÿ=·ôÿD¿üÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #D #2 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüúvÓÌÎÿñììÿüûúÿÏÇÊÿüûúÿüûúÿüûúÿüûúÿÓÌÏÿóîîÿÔÍÐÿôïðÿüûúÿöððÿòéêÿôìíÿôììÿòèèÿôììÿ¾«­ÿp}‘ÿ!q›ÿ6sÿ9~ÿ\³ÿ:ºùÿ?¿þÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿüüúÓÌÎùÖÏÑÿûúøÿÏÇÊÿûúøÿûúùÿûúøÿûúùÿûûùÿÓÌÏÿòíîÿýýûÿú÷öÿôìíÿñçèÿóêëÿòèéÿðååÿñèçÿáÔÕÿ’vxÿm•ÿsŸÿ7vÿFvÿGœÿgÉÿ;»þÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿûúøœÔÍÏÿðêêÿúù÷ÿÏÇÊÿúø÷ÿúø÷ÿûúøÿûúøÿûúøÿÕÍÐÿòííÿöñðÿñçèÿñæçÿñçèÿñææÿîââÿðååÿñèçÿ­•—ÿorÿmšÿu¤ÿa§ÿDxÿZœÿP®ÿkÎÿsÛþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿûûø.ÔÍÏýÖÏÑÿúøöÿúøöÿúøöÿúøöÿúøöÿúø÷ÿúù÷ÿúù÷ÿÓÉÌÿéÝßÿïãäÿðåæÿðåæÿîââÿíààÿïããÿðæåÿàÓÓÿ‘vxÿi•ÿožÿwªÿƒ¿ÿr¦ÄÿUœÿf³ÿT¶ÿtâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿ?Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿúùö½×ÐÒÿïêéÿúøöÿù÷õÿúøöÿúøöÿúøöÿúøöÿ÷òñÿòééÿÒÂÆÿå×ÙÿïãäÿîáâÿëÜÜÿìÞÞÿíßßÿîââÿïäãÿ¯–˜ÿmo€ÿjšÿp£ÿz±ÿ‡Åÿ–Ýÿ¼âÿa³ÿmÂÿÚÿ‚Ýÿ‰éÿ’òÿ˜úÿœþÿŸþÿmÚÿLz•w #J #H #> #. # #ÿÿÿÿÿÿù÷õS×ÐÒÿúùöÿøöóÿù÷ôÿù÷ôÿù÷ôÿù÷õÿöðïÿñççÿíàáÿíàáÿνÁÿàÐÒÿêÚÚÿêÚÚÿêÜÛÿëÝÜÿíàßÿíáàÿÝÏÏÿ’uxÿh—ÿjžÿr©ÿ¹ÿŒËÿ›àÿ §ôÿƒÉóÿkÅÿ~Úÿâÿ…ìÿòÿ•üÿ˜þÿœþÿiÚÿmÛÿOz™t #? #3 #$ # #ÿÿÿ÷õñ÷õò׺°´ÿîçæÿøöóÿøõóÿöðïÿòêéÿïããÿëÜÝÿéÙÚÿèØÙÿè××ÿº¥©ÿÕÂÄÿéÙÙÿêÛÛÿêÜÛÿëÝÜÿìßÞÿíâàÿ®•–ÿjn€ÿfœÿk£ÿ u°ÿ ¿ÿŒÏÿšáÿ ©ôÿ+²ýÿ‡ÎüÿxÚÿzßÿ‚éÿŒõÿ‘üÿ•þÿ˜þÿ›þÿzìÿjÜÿWŒ®l #& # # #ÿÿÿöôð¶©«üÁ·¹ÿ¾°³ÿ»ª®ÿº¦ªÿ²šžÿ²™ÿ®•™ÿ«’–ÿ«’–ÿ¤ŠŽÿ®—šÿ¹¥©ÿÖÄÆÿéÚÙÿêÛÚÿëÝÜÿëÞÝÿìàÞÿÛÌÌÿ’txÿhŸÿhŸÿn©ÿx¸ÿ „ÅÿŽÒÿ™âÿ!«ôÿ/·ýÿ8¹þÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #' # # #ÿÿÿ˜†*˜†Ñµœ›ÿ¤„†ÿ ÿ¥†ˆÿ¦‡‰ÿ§‰‹ÿº ¢ÿº ¢ÿÁ©«ÿì®ÿË·¸ÿÖÅÆÿ×ÇÇÿéÚÙÿêÛÚÿéÛÚÿêÞÜÿêÞÜÿ­•–ÿg]|ÿi¥ÿh£ÿq°ÿ{¾ÿƒÉÿŠÒÿ™âÿ$©ôÿ4·ýÿ@¾þÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿ #q\S؝‰…üÔÀÂÿÜÉÊÿÜÉÊÿÛÈÉÿÛÉÉÿÜÊÊÿÜÊÊÿ¸¤¨ÿÖÅÅÿÞÍÍÿÝÍÍÿÞÏÎÿèÚØÿèÚØÿéÜÚÿêÝÛÿ×ÉÈÿ–uvù1ÿi©ÿjªÿr·ÿ}ÄÿƒÌÿQ¬ÿ™âÿ$«ôÿ2·ýÿFÀþÿ•ìþÿ@Íþÿ1Åþÿºþÿ°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #* # #ÿÿÿ #Q;0dq\SæÓ¼¼ÿàÎÎÿßÍÍÿßÍÍÿßÍÍÿÞÍÌÿßÎÎÿ¶¤§ÿÕÄÄÿÞÎÍÿßÏÎÿçØ×ÿèÚØÿèÚØÿèÚØÿéÜÙÿ©‘‘ÿ‡imÏ0–ÿk¯ÿm²ÿt¾ÿ}Èÿ„Ìÿ4ÿQ¯ÿ!©ôÿ4¸ýÿGÀþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #C #1 # #ÿÿÿ V@5È£ŠˆýÖÄÄÿàÏÎÿáÐÏÿáÑÐÿãÒÑÿãÒÑÿ´¢¥ÿÓÃÃÿåÖÔÿçÙ×ÿæØÕÿæØÖÿæØÖÿæÙÖÿÔÅÄÿ•tuú+$&V2˜ÿm·ÿp»ÿxÄÿ|ËÿƒÍÿ;”ÿ5–ÿZÄÿ8¸ýÿPÂþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿw_YêÔ¿¾ÿàÏÎÿàÑÏÿáÑÐÿàÑÏÿáÒÐÿµ£¥ÿÓÄÃÿäÕÓÿäÖÓÿäÖÓÿãÖÓÿãÖÓÿãÖÓÿ¦ŽÿŠloÒ"J3žÿp¿ÿqÂÿwÈÿ}Ëÿ€Íÿ;–ÿ=˜ÿ=«ÿeÐÿTÇþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿ T?5¿ ˆ†ýåÖÔÿßÐÎÿßÐÎÿßÐÎÿßÐÎÿ²¡£ÿÑÂÁÿãÕÒÿãÕÒÿãÕÒÿáÔÐÿàÓÏÿÑÂÀÿ“rrù,%'V"E5¤ÿqÈÿrÉÿwËÿzÌÿ~ÍÿQ™Ãÿ=ÿL¸ÿVËÿlÖÿxâÿsâÿoâÿkâÿfâÿbâÿ[ÖÿZâÿVâÿRâÿ@Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿ  s[UéÒ¿½ÿÝÎÌÿÜÍÊÿÝÎÌÿÛÍÊÿ± ¡ÿ;½ÿàÒÎÿáÔÐÿÜÎËÿÞÐÍÿßÒÎÿ¥ŒŒÿ‰kmÖOB3¥ÿtÏÿuÍÿwËÿzÌÿ~Íÿ„Óÿf¬ÚÿL¼ÿYÔÿaßÿzñÿrñÿtöÿ}ýÿ„þÿ„þÿpëÿ'çù #K #I #G #> #. # #ÿÿÿÿÿÿÿÿÿ R=4¦œ†‚ýãÕÑÿÛÍÊÿÚËÉÿÚÌÉÿ®Ÿÿ˼ºÿÞÑÍÿÜÍÊÿÜÎÊÿÛÍÉÿÊ»¹ÿpoû!kW1;Sa 4’þ cÒþuÐÿuÌÿuÌÿ|ÍÿˆÓÿ”âÿr½óÿ[Öÿbàÿiëÿpõÿvøÿ}þÿ‚þÿ„þÿoëÿlÙþ #I #C #; #0 #" # #ÿÿÿÿÿÿÿÿÿÿÿÿ  pZRåκ¸ÿÙËÈÿ×ÈÅÿÖÇÄÿ¬›œÿȹ·ÿÙËÇÿÚËÇÿØÉÅÿØÉÅÿ¡‰ˆÿ„hiÝj]K-9S[6’ý ^ÌþsÌÿwÌÿ|Íÿ‡Óÿ™âÿ-«ôÿ~Ìýÿbæÿlïÿröÿxüÿ{þÿþÿ‚þÿ„þÿ‰þÿqÙüQˆÏÏ #- # # # #ÿÿÿÿÿÿÿÿÿÿÿÿ  M:1†˜‚~ýÊ»¹ÿÔÅÂÿÔÅÂÿ©˜™ÿŶ´ÿØÉÅÿÔÅÁÿÓÅÀÿÄ´±ÿŽnmüvi[ I?%/CV7’ýZÇþwÌÿ}ÍÿˆÓÿ™âÿ6±ôÿM¿ýÿ…Óþÿmôÿr÷ÿwþÿ~þÿþÿ„þÿ‡þÿ‹þÿŒþÿqÙü #* # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  jLDåɶ³ÿÒÿÿÐÁ¾ÿ¦•–ÿÁ²¯ÿÒÄ¿ÿѾÿÏÁ¼ÿœ„ƒÿƒefßmc T C:<"1U9‘ýWÅÿ}Íÿ‡Óÿ™âÿ:³ôÿ[ÇýÿvÑþÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #! # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ P71gb]þó±ÿ̼¸ÿ¢’’ÿ¼®«ÿÏÀ»ÿ̽¸ÿ¼¬¨ÿŒljývi\
J<56=!O<‘üVÃÿ‡Óÿœãÿ@µôÿbÊýÿ…ÚþÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ fHAÌ®«ÿȸ´ÿ ÿºª§ÿȸ³ÿȹ³ÿ—€~ÿceßmd T C8336="N@”úYÌÿœæÿH¹öÿlÌýÿŽÝþÿ•ìþÿ@Íþÿ1Åþÿºþÿ°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #) # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 8-':pQJþºª§ÿ›‹Šÿ´¤¡ÿô®ÿ´£Ÿÿ{WSþwi\
J<421125 ;#H£ù^ÞÿC¶ùÿlÍýÿ’ßþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #B #0 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ _D=¤¸¤ ÿ—†…ÿ°Ÿœÿ¿®©ÿ‘ywÿ{XUømd U C82/+&! %*R´öcçÿaÇþÿ”àþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lNFô•ƒ‚ÿ«š–ÿ«™•ÿyUQþ!{i] J;/(#  ".X·óbéÿÕþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  W>7~Švuÿ¥”ÿwXUÿ{XUømcR <+   # # # #1]¸ñaæÿpÙþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  hJCݤ’ŽÿwTOþ#xeU> '  # # # # # # #<j¶ätâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿHàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ I4/W~]XÿŒllð]T>% # # # # # # # # # # # #) #7 #@ #D #D #D #D #D #D #D #D #= #. # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lUOµ7-.PE;%ÿÿÿ # # # # # # # # # # # # # #$ #. #2 #3 #3 #3 #3 #3 #3 #3 #. #" # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ#"#$ +!&! # #ÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ #! # # # #ÿÿÿÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayºʇڙë,j­¢f£¢·hšïêÿ‘êçz_è®(­éšŽŠÝ¢j"ú¶m§ÿÿ¾«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^¶m§ÿÿà ÿ¶ìÿ¢¸?–I¥

#16 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley
Quoted 81 lines · Matt Helsley
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Quoted 5 lines
Quoted 239 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
#47 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive
Quoted 16 lines · Matt Helsley
Quoted 14 lines · Thomas Petazzoni

Hi,

Quoted 4 lines · Matt Helsley

--- a/kernel/Makefile
+-+-+- b/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> > > cpu.o exit.o itimer.o time.o softirq.o resource.o \> > > sysctl.o capability.o ptrace.o timer.o user.o \> > > - signal.o sys.o kmod.o workqueue.o pid.o \> > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> >

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 7 lines
Quoted 2 lines

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Perhaps we should even move freezer.c from kernel/power to kernel and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

Quoted 28 lines
---
 kernel/Makefile      |    3 +-+--
 kernel/power/Kconfig |    3 +-+-+-
 2 files changed, 5 insertions(+-), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/kernel/Makefile
===================================================================
--- linux-2.6.27-rc1-mm1.orig/kernel/Makefile
+-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> cpu.o exit.o itimer.o time.o softirq.o resource.o \> sysctl.o capability.o ptrace.o timer.o user.o \> - signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> +- signal.o sys.o kmod.o workqueue.o pid.o \> rcupdate.o extable.o params.o posix-timers.o \> kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \> hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \> @@ -24,6 +-24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
CFLAGS_REMOVE_sched.o = -mno-spe -pg
endif

+-obj-$(CONFIG_FREEZER) +-= freezer.o
obj-$(CONFIG_PROFILING) +-= profile.o obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) +-= sysctl_check.o obj-$(CONFIG_STACKTRACE) +-= stacktrace.o
Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig
===================================================================
--- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig +-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig @@ -85,6 +-85,9 @@ config PM_SLEEP

Review

Quoted 9 lines
(quoted diff) +3 -0
 	depends on SUSPEND || HIBERNATION || XEN_SAVE_RESTORE
 	default y
 
+-config FREEZER
+-	def_bool PM_SLEEP || CGROUP_FREEZER
+-
 config SUSPEND
 	bool "Suspend to RAM and standby"
 	depends on PM && ARCH_SUSPEND_POSSIBLE

¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #: #' # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýýûXÓÌÎÿýýüÿýýüÿÍÆÉÿýýûÿýýüÿýýûÿÑÊÍÿòîïÿýýüÿýýüÿþþýÿÔÍÐÿÕÏÒÿðèéÿöïïÿöïðÿöïïÿöïïÿͼ¿ÿn}‘ÿFƒÿ0ˆµÿ8¡Õÿ@³îÿE¿úÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #A #/ # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþýýýûâÔÍÏÿüüúÿÎÇÊÿüûúÿüûúÿüûúÿüûúÿÒËÎÿóîîÿýýüÿÔÍÐÿÕÎÑÿõññÿùôôÿôìíÿõîïÿõíîÿôììÿíãäÿ©˜Ÿÿ%r™ÿ-oÿKÿ7§Þÿ=·ôÿD¿üÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #D #2 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüúvÓÌÎÿñììÿüûúÿÏÇÊÿüûúÿüûúÿüûúÿüûúÿÓÌÏÿóîîÿÔÍÐÿôïðÿüûúÿöððÿòéêÿôìíÿôììÿòèèÿôììÿ¾«­ÿp}‘ÿ!q›ÿ6sÿ9~ÿ\³ÿ:ºùÿ?¿þÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿüüúÓÌÎùÖÏÑÿûúøÿÏÇÊÿûúøÿûúùÿûúøÿûúùÿûûùÿÓÌÏÿòíîÿýýûÿú÷öÿôìíÿñçèÿóêëÿòèéÿðååÿñèçÿáÔÕÿ’vxÿm•ÿsŸÿ7vÿFvÿGœÿgÉÿ;»þÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿûúøœÔÍÏÿðêêÿúù÷ÿÏÇÊÿúø÷ÿúø÷ÿûúøÿûúøÿûúøÿÕÍÐÿòííÿöñðÿñçèÿñæçÿñçèÿñææÿîââÿðååÿñèçÿ­•—ÿorÿmšÿu¤ÿa§ÿDxÿZœÿP®ÿkÎÿsÛþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿûûø.ÔÍÏýÖÏÑÿúøöÿúøöÿúøöÿúøöÿúøöÿúø÷ÿúù÷ÿúù÷ÿÓÉÌÿéÝßÿïãäÿðåæÿðåæÿîââÿíààÿïããÿðæåÿàÓÓÿ‘vxÿi•ÿožÿwªÿƒ¿ÿr¦ÄÿUœÿf³ÿT¶ÿtâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿ?Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿúùö½×ÐÒÿïêéÿúøöÿù÷õÿúøöÿúøöÿúøöÿúøöÿ÷òñÿòééÿÒÂÆÿå×ÙÿïãäÿîáâÿëÜÜÿìÞÞÿíßßÿîââÿïäãÿ¯–˜ÿmo€ÿjšÿp£ÿz±ÿ‡Åÿ–Ýÿ¼âÿa³ÿmÂÿÚÿ‚Ýÿ‰éÿ’òÿ˜úÿœþÿŸþÿmÚÿLz•w #J #H #> #. # #ÿÿÿÿÿÿù÷õS×ÐÒÿúùöÿøöóÿù÷ôÿù÷ôÿù÷ôÿù÷õÿöðïÿñççÿíàáÿíàáÿνÁÿàÐÒÿêÚÚÿêÚÚÿêÜÛÿëÝÜÿíàßÿíáàÿÝÏÏÿ’uxÿh—ÿjžÿr©ÿ¹ÿŒËÿ›àÿ §ôÿƒÉóÿkÅÿ~Úÿâÿ…ìÿòÿ•üÿ˜þÿœþÿiÚÿmÛÿOz™t #? #3 #$ # #ÿÿÿ÷õñ÷õò׺°´ÿîçæÿøöóÿøõóÿöðïÿòêéÿïããÿëÜÝÿéÙÚÿèØÙÿè××ÿº¥©ÿÕÂÄÿéÙÙÿêÛÛÿêÜÛÿëÝÜÿìßÞÿíâàÿ®•–ÿjn€ÿfœÿk£ÿ u°ÿ ¿ÿŒÏÿšáÿ ©ôÿ+²ýÿ‡ÎüÿxÚÿzßÿ‚éÿŒõÿ‘üÿ•þÿ˜þÿ›þÿzìÿjÜÿWŒ®l #& # #
#ÿÿÿöôð¶©«üÁ·¹ÿ¾°³ÿ»ª®ÿº¦ªÿ²šžÿ²™ÿ®•™ÿ«’–ÿ«’–ÿ¤ŠŽÿ®—šÿ¹¥©ÿÖÄÆÿéÚÙÿêÛÚÿëÝÜÿëÞÝÿìàÞÿÛÌÌÿ’txÿhŸÿhŸÿn©ÿx¸ÿ „ÅÿŽÒÿ™âÿ!«ôÿ/·ýÿ8¹þÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #' # # #ÿÿÿ˜†*˜†Ñµœ›ÿ¤„†ÿ ÿ¥†ˆÿ¦‡‰ÿ§‰‹ÿº ¢ÿº ¢ÿÁ©«ÿì®ÿË·¸ÿÖÅÆÿ×ÇÇÿéÚÙÿêÛÚÿéÛÚÿêÞÜÿêÞÜÿ­•–ÿg]|ÿi¥ÿh£ÿq°ÿ{¾ÿƒÉÿŠÒÿ™âÿ$©ôÿ4·ýÿ@¾þÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿ #q\S؝‰…üÔÀÂÿÜÉÊÿÜÉÊÿÛÈÉÿÛÉÉÿÜÊÊÿÜÊÊÿ¸¤¨ÿÖÅÅÿÞÍÍÿÝÍÍÿÞÏÎÿèÚØÿèÚØÿéÜÚÿêÝÛÿ×ÉÈÿ–uvù1ÿi©ÿjªÿr·ÿ}ÄÿƒÌÿQ¬ÿ™âÿ$«ôÿ2·ýÿFÀþÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #* # #ÿÿÿ #Q;0dq\SæÓ¼¼ÿàÎÎÿßÍÍÿßÍÍÿßÍÍÿÞÍÌÿßÎÎÿ¶¤§ÿÕÄÄÿÞÎÍÿßÏÎÿçØ×ÿèÚØÿèÚØÿèÚØÿéÜÙÿ©‘‘ÿ‡imÏ0–ÿk¯ÿm²ÿt¾ÿ}Èÿ„Ìÿ4ÿQ¯ÿ!©ôÿ4¸ýÿGÀþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #C #1 # #ÿÿÿ V@5È£ŠˆýÖÄÄÿàÏÎÿáÐÏÿáÑÐÿãÒÑÿãÒÑÿ´¢¥ÿÓÃÃÿåÖÔÿçÙ×ÿæØÕÿæØÖÿæØÖÿæÙÖÿÔÅÄÿ•tuú+$&V2˜ÿm·ÿp»ÿxÄÿ|ËÿƒÍÿ;”ÿ5–ÿZÄÿ8¸ýÿPÂþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿw_YêÔ¿¾ÿàÏÎÿàÑÏÿáÑÐÿàÑÏÿáÒÐÿµ£¥ÿÓÄÃÿäÕÓÿäÖÓÿäÖÓÿãÖÓÿãÖÓÿãÖÓÿ¦ŽÿŠloÒ"J3žÿp¿ÿqÂÿwÈÿ}Ëÿ€Íÿ;–ÿ=˜ÿ=«ÿeÐÿTÇþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿ
T?5¿ ˆ†ýåÖÔÿßÐÎÿßÐÎÿßÐÎÿßÐÎÿ²¡£ÿÑÂÁÿãÕÒÿãÕÒÿãÕÒÿáÔÐÿàÓÏÿÑÂÀÿ“rrù,%'V"E5¤ÿqÈÿrÉÿwËÿzÌÿ~ÍÿQ™Ãÿ=ÿL¸ÿVËÿlÖÿxâÿsâÿoâÿkâÿfâÿbâÿ[ÖÿZâÿVâÿRâÿ@Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿ  s[UéÒ¿½ÿÝÎÌÿÜÍÊÿÝÎÌÿÛÍÊÿ± ¡ÿ;½ÿàÒÎÿáÔÐÿÜÎËÿÞÐÍÿßÒÎÿ¥ŒŒÿ‰kmÖOB3¥ÿtÏÿuÍÿwËÿzÌÿ~Íÿ„Óÿf¬ÚÿL¼ÿYÔÿaßÿzñÿrñÿtöÿ}ýÿ„þÿ„þÿpëÿ'çù #K #I #G #> #. # #ÿÿÿÿÿÿÿÿÿ R=4¦œ†‚ýãÕÑÿÛÍÊÿÚËÉÿÚÌÉÿ®Ÿÿ˼ºÿÞÑÍÿÜÍÊÿÜÎÊÿÛÍÉÿÊ»¹ÿpoû!kW1;Sa 4’þ cÒþuÐÿuÌÿuÌÿ|ÍÿˆÓÿ”âÿr½óÿ[Öÿbàÿiëÿpõÿvøÿ}þÿ‚þÿ„þÿoëÿlÙþ #I #C #; #0 #" # #ÿÿÿÿÿÿÿÿÿÿÿÿ  pZRåκ¸ÿÙËÈÿ×ÈÅÿÖÇÄÿ¬›œÿȹ·ÿÙËÇÿÚËÇÿØÉÅÿØÉÅÿ¡‰ˆÿ„hiÝj]K-9S[6’ý ^ÌþsÌÿwÌÿ|Íÿ‡Óÿ™âÿ-«ôÿ~Ìýÿbæÿlïÿröÿxüÿ{þÿþÿ‚þÿ„þÿ‰þÿqÙüQˆÏÏ #- # # # #ÿÿÿÿÿÿÿÿÿÿÿÿ  M:1†˜‚~ýÊ»¹ÿÔÅÂÿÔÅÂÿ©˜™ÿŶ´ÿØÉÅÿÔÅÁÿÓÅÀÿÄ´±ÿŽnmüvi[
I?%/CV7’ý
ZÇþwÌÿ}ÍÿˆÓÿ™âÿ6±ôÿM¿ýÿ…Óþÿmôÿr÷ÿwþÿ~þÿþÿ„þÿ‡þÿ‹þÿŒþÿqÙü #* # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  jLDåɶ³ÿÒÿÿÐÁ¾ÿ¦•–ÿÁ²¯ÿÒÄ¿ÿѾÿÏÁ¼ÿœ„ƒÿƒefßmc T C:<"1U9‘ýWÅÿ}Íÿ‡Óÿ™âÿ:³ôÿ[ÇýÿvÑþÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #! # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ P71gb]þó±ÿ̼¸ÿ¢’’ÿ¼®«ÿÏÀ»ÿ̽¸ÿ¼¬¨ÿŒljývi\

J<56=!O<‘üVÃÿ‡Óÿœãÿ@µôÿbÊýÿ…ÚþÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ fHAÌ®«ÿȸ´ÿ ÿºª§ÿȸ³ÿȹ³ÿ—€~ÿceßmd T C8336="N@”úYÌÿœæÿH¹öÿlÌýÿŽÝþÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #) # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 8-':pQJþºª§ÿ›‹Šÿ´¤¡ÿô®ÿ´£Ÿÿ{WSþwi\

J<421125 ;#H£ù^ÞÿC¶ùÿlÍýÿ’ßþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #B #0 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
_D=¤¸¤ ÿ—†…ÿ°Ÿœÿ¿®©ÿ‘ywÿ{XUømd U C82/+&! %*R´öcçÿaÇþÿ”àþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lNFô•ƒ‚ÿ«š–ÿ«™•ÿyUQþ!{i]
J;/(#
  ".X·óbéÿÕþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
 W>7~Švuÿ¥”ÿwXUÿ{XUømcR

	<+  # # # #1]¸ñaæÿpÙþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

 hJCݤ’ŽÿwTOþ#xeU>
'  # # # # # # #<j¶ätâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿHàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ I4/W~]XÿŒllð]T>% # # # # # # # # # # # #) #7 #@ #D #D #D #D #D #D #D #D #= #. # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lUOµ7-.PE;%ÿÿÿ # # # # # # # # # # # # # #$ #. #2 #3 #3 #3 #3 #3 #3 #3 #. #" # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ#"#$ +!&! # #ÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ #! # # # #ÿÿÿÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#49 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley
Quoted 16 lines · Matt Helsley
Quoted 14 lines · Thomas Petazzoni

Hi,

Quoted 4 lines · Matt Helsley

--- a/kernel/Makefile
+-+-+- b/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> > > cpu.o exit.o itimer.o time.o softirq.o resource.o \> > > sysctl.o capability.o ptrace.o timer.o user.o \> > > - signal.o sys.o kmod.o workqueue.o pid.o \> > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> >

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 7 lines
Quoted 2 lines

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Perhaps we should even move freezer.c from kernel/power to kernel and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

Quoted 28 lines
---
 kernel/Makefile      |    3 +-+--
 kernel/power/Kconfig |    3 +-+-+-
 2 files changed, 5 insertions(+-), 1 deletion(-)

Index: linux-2.6.27-rc1-mm1/kernel/Makefile
===================================================================
--- linux-2.6.27-rc1-mm1.orig/kernel/Makefile
+-+-+- linux-2.6.27-rc1-mm1/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> cpu.o exit.o itimer.o time.o softirq.o resource.o \> sysctl.o capability.o ptrace.o timer.o user.o \> - signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> +- signal.o sys.o kmod.o workqueue.o pid.o \> rcupdate.o extable.o params.o posix-timers.o \> kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \> hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \> @@ -24,6 +-24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
CFLAGS_REMOVE_sched.o = -mno-spe -pg
endif

+-obj-$(CONFIG_FREEZER) +-= freezer.o
obj-$(CONFIG_PROFILING) +-= profile.o obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) +-= sysctl_check.o obj-$(CONFIG_STACKTRACE) +-= stacktrace.o
Index: linux-2.6.27-rc1-mm1/kernel/power/Kconfig
===================================================================
--- linux-2.6.27-rc1-mm1.orig/kernel/power/Kconfig +-+-+- linux-2.6.27-rc1-mm1/kernel/power/Kconfig @@ -85,6 +-85,9 @@ config PM_SLEEP

Review

Quoted 9 lines
(quoted diff) +3 -0
 	depends on SUSPEND || HIBERNATION || XEN_SAVE_RESTORE
 	default y
 
+-config FREEZER
+-	def_bool PM_SLEEP || CGROUP_FREEZER
+-
 config SUSPEND
 	bool "Suspend to RAM and standby"
 	depends on PM && ARCH_SUSPEND_POSSIBLE

¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #: #' # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýýûXÓÌÎÿýýüÿýýüÿÍÆÉÿýýûÿýýüÿýýûÿÑÊÍÿòîïÿýýüÿýýüÿþþýÿÔÍÐÿÕÏÒÿðèéÿöïïÿöïðÿöïïÿöïïÿͼ¿ÿn}‘ÿFƒÿ0ˆµÿ8¡Õÿ@³îÿE¿úÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #A #/ # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþýýýûâÔÍÏÿüüúÿÎÇÊÿüûúÿüûúÿüûúÿüûúÿÒËÎÿóîîÿýýüÿÔÍÐÿÕÎÑÿõññÿùôôÿôìíÿõîïÿõíîÿôììÿíãäÿ©˜Ÿÿ%r™ÿ-oÿKÿ7§Þÿ=·ôÿD¿üÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #D #2 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüúvÓÌÎÿñììÿüûúÿÏÇÊÿüûúÿüûúÿüûúÿüûúÿÓÌÏÿóîîÿÔÍÐÿôïðÿüûúÿöððÿòéêÿôìíÿôììÿòèèÿôììÿ¾«­ÿp}‘ÿ!q›ÿ6sÿ9~ÿ\³ÿ:ºùÿ?¿þÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿüüúÓÌÎùÖÏÑÿûúøÿÏÇÊÿûúøÿûúùÿûúøÿûúùÿûûùÿÓÌÏÿòíîÿýýûÿú÷öÿôìíÿñçèÿóêëÿòèéÿðååÿñèçÿáÔÕÿ’vxÿm•ÿsŸÿ7vÿFvÿGœÿgÉÿ;»þÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿûúøœÔÍÏÿðêêÿúù÷ÿÏÇÊÿúø÷ÿúø÷ÿûúøÿûúøÿûúøÿÕÍÐÿòííÿöñðÿñçèÿñæçÿñçèÿñææÿîââÿðååÿñèçÿ­•—ÿorÿmšÿu¤ÿa§ÿDxÿZœÿP®ÿkÎÿsÛþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿûûø.ÔÍÏýÖÏÑÿúøöÿúøöÿúøöÿúøöÿúøöÿúø÷ÿúù÷ÿúù÷ÿÓÉÌÿéÝßÿïãäÿðåæÿðåæÿîââÿíààÿïããÿðæåÿàÓÓÿ‘vxÿi•ÿožÿwªÿƒ¿ÿr¦ÄÿUœÿf³ÿT¶ÿtâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿ?Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿúùö½×ÐÒÿïêéÿúøöÿù÷õÿúøöÿúøöÿúøöÿúøöÿ÷òñÿòééÿÒÂÆÿå×ÙÿïãäÿîáâÿëÜÜÿìÞÞÿíßßÿîââÿïäãÿ¯–˜ÿmo€ÿjšÿp£ÿz±ÿ‡Åÿ–Ýÿ¼âÿa³ÿmÂÿÚÿ‚Ýÿ‰éÿ’òÿ˜úÿœþÿŸþÿmÚÿLz•w #J #H #> #. # #ÿÿÿÿÿÿù÷õS×ÐÒÿúùöÿøöóÿù÷ôÿù÷ôÿù÷ôÿù÷õÿöðïÿñççÿíàáÿíàáÿνÁÿàÐÒÿêÚÚÿêÚÚÿêÜÛÿëÝÜÿíàßÿíáàÿÝÏÏÿ’uxÿh—ÿjžÿr©ÿ¹ÿŒËÿ›àÿ §ôÿƒÉóÿkÅÿ~Úÿâÿ…ìÿòÿ•üÿ˜þÿœþÿiÚÿmÛÿOz™t #? #3 #$ # #ÿÿÿ÷õñ÷õò׺°´ÿîçæÿøöóÿøõóÿöðïÿòêéÿïããÿëÜÝÿéÙÚÿèØÙÿè××ÿº¥©ÿÕÂÄÿéÙÙÿêÛÛÿêÜÛÿëÝÜÿìßÞÿíâàÿ®•–ÿjn€ÿfœÿk£ÿ u°ÿ ¿ÿŒÏÿšáÿ ©ôÿ+²ýÿ‡ÎüÿxÚÿzßÿ‚éÿŒõÿ‘üÿ•þÿ˜þÿ›þÿzìÿjÜÿWŒ®l #& # #
#ÿÿÿöôð¶©«üÁ·¹ÿ¾°³ÿ»ª®ÿº¦ªÿ²šžÿ²™ÿ®•™ÿ«’–ÿ«’–ÿ¤ŠŽÿ®—šÿ¹¥©ÿÖÄÆÿéÚÙÿêÛÚÿëÝÜÿëÞÝÿìàÞÿÛÌÌÿ’txÿhŸÿhŸÿn©ÿx¸ÿ „ÅÿŽÒÿ™âÿ!«ôÿ/·ýÿ8¹þÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #' # # #ÿÿÿ˜†*˜†Ñµœ›ÿ¤„†ÿ ÿ¥†ˆÿ¦‡‰ÿ§‰‹ÿº ¢ÿº ¢ÿÁ©«ÿì®ÿË·¸ÿÖÅÆÿ×ÇÇÿéÚÙÿêÛÚÿéÛÚÿêÞÜÿêÞÜÿ­•–ÿg]|ÿi¥ÿh£ÿq°ÿ{¾ÿƒÉÿŠÒÿ™âÿ$©ôÿ4·ýÿ@¾þÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿ #q\S؝‰…üÔÀÂÿÜÉÊÿÜÉÊÿÛÈÉÿÛÉÉÿÜÊÊÿÜÊÊÿ¸¤¨ÿÖÅÅÿÞÍÍÿÝÍÍÿÞÏÎÿèÚØÿèÚØÿéÜÚÿêÝÛÿ×ÉÈÿ–uvù1ÿi©ÿjªÿr·ÿ}ÄÿƒÌÿQ¬ÿ™âÿ$«ôÿ2·ýÿFÀþÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #* # #ÿÿÿ #Q;0dq\SæÓ¼¼ÿàÎÎÿßÍÍÿßÍÍÿßÍÍÿÞÍÌÿßÎÎÿ¶¤§ÿÕÄÄÿÞÎÍÿßÏÎÿçØ×ÿèÚØÿèÚØÿèÚØÿéÜÙÿ©‘‘ÿ‡imÏ0–ÿk¯ÿm²ÿt¾ÿ}Èÿ„Ìÿ4ÿQ¯ÿ!©ôÿ4¸ýÿGÀþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #C #1 # #ÿÿÿ V@5È£ŠˆýÖÄÄÿàÏÎÿáÐÏÿáÑÐÿãÒÑÿãÒÑÿ´¢¥ÿÓÃÃÿåÖÔÿçÙ×ÿæØÕÿæØÖÿæØÖÿæÙÖÿÔÅÄÿ•tuú+$&V2˜ÿm·ÿp»ÿxÄÿ|ËÿƒÍÿ;”ÿ5–ÿZÄÿ8¸ýÿPÂþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿw_YêÔ¿¾ÿàÏÎÿàÑÏÿáÑÐÿàÑÏÿáÒÐÿµ£¥ÿÓÄÃÿäÕÓÿäÖÓÿäÖÓÿãÖÓÿãÖÓÿãÖÓÿ¦ŽÿŠloÒ"J3žÿp¿ÿqÂÿwÈÿ}Ëÿ€Íÿ;–ÿ=˜ÿ=«ÿeÐÿTÇþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿ
T?5¿ ˆ†ýåÖÔÿßÐÎÿßÐÎÿßÐÎÿßÐÎÿ²¡£ÿÑÂÁÿãÕÒÿãÕÒÿãÕÒÿáÔÐÿàÓÏÿÑÂÀÿ“rrù,%'V"E5¤ÿqÈÿrÉÿwËÿzÌÿ~ÍÿQ™Ãÿ=ÿL¸ÿVËÿlÖÿxâÿsâÿoâÿkâÿfâÿbâÿ[ÖÿZâÿVâÿRâÿ@Åÿ #D #3 # #ÿÿÿÿÿÿÿÿÿ  s[UéÒ¿½ÿÝÎÌÿÜÍÊÿÝÎÌÿÛÍÊÿ± ¡ÿ;½ÿàÒÎÿáÔÐÿÜÎËÿÞÐÍÿßÒÎÿ¥ŒŒÿ‰kmÖOB3¥ÿtÏÿuÍÿwËÿzÌÿ~Íÿ„Óÿf¬ÚÿL¼ÿYÔÿaßÿzñÿrñÿtöÿ}ýÿ„þÿ„þÿpëÿ'çù #K #I #G #> #. # #ÿÿÿÿÿÿÿÿÿ R=4¦œ†‚ýãÕÑÿÛÍÊÿÚËÉÿÚÌÉÿ®Ÿÿ˼ºÿÞÑÍÿÜÍÊÿÜÎÊÿÛÍÉÿÊ»¹ÿpoû!kW1;Sa 4’þ cÒþuÐÿuÌÿuÌÿ|ÍÿˆÓÿ”âÿr½óÿ[Öÿbàÿiëÿpõÿvøÿ}þÿ‚þÿ„þÿoëÿlÙþ #I #C #; #0 #" # #ÿÿÿÿÿÿÿÿÿÿÿÿ  pZRåκ¸ÿÙËÈÿ×ÈÅÿÖÇÄÿ¬›œÿȹ·ÿÙËÇÿÚËÇÿØÉÅÿØÉÅÿ¡‰ˆÿ„hiÝj]K-9S[6’ý ^ÌþsÌÿwÌÿ|Íÿ‡Óÿ™âÿ-«ôÿ~Ìýÿbæÿlïÿröÿxüÿ{þÿþÿ‚þÿ„þÿ‰þÿqÙüQˆÏÏ #- # # # #ÿÿÿÿÿÿÿÿÿÿÿÿ  M:1†˜‚~ýÊ»¹ÿÔÅÂÿÔÅÂÿ©˜™ÿŶ´ÿØÉÅÿÔÅÁÿÓÅÀÿÄ´±ÿŽnmüvi[
I?%/CV7’ý
ZÇþwÌÿ}ÍÿˆÓÿ™âÿ6±ôÿM¿ýÿ…Óþÿmôÿr÷ÿwþÿ~þÿþÿ„þÿ‡þÿ‹þÿŒþÿqÙü #* # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  jLDåɶ³ÿÒÿÿÐÁ¾ÿ¦•–ÿÁ²¯ÿÒÄ¿ÿѾÿÏÁ¼ÿœ„ƒÿƒefßmc T C:<"1U9‘ýWÅÿ}Íÿ‡Óÿ™âÿ:³ôÿ[ÇýÿvÑþÿ¾ýþÿ¸øþÿ°õþÿ©òþÿ îþÿ–éþÿåþÿ‡âþÿÝþÿxÙþÿhÊþÿ #! # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ P71gb]þó±ÿ̼¸ÿ¢’’ÿ¼®«ÿÏÀ»ÿ̽¸ÿ¼¬¨ÿŒljývi\

J<56=!O<‘üVÃÿ‡Óÿœãÿ@µôÿbÊýÿ…ÚþÿœïþÿPÑþÿ?Ëþÿ-Áþÿ¹þÿ°þÿ¦þÿŸþÿ˜þÿþÿ`âÿ #0 # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ fHAÌ®«ÿȸ´ÿ ÿºª§ÿȸ³ÿȹ³ÿ—€~ÿceßmd T C8336="N@”úYÌÿœæÿH¹öÿlÌýÿŽÝþÿ•ìþÿ@Íþÿ1Åþÿºþÿ
°þÿ«þÿ¢þÿ™þÿþÿ‡þÿZàÿ #< #) # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 8-':pQJþºª§ÿ›‹Šÿ´¤¡ÿô®ÿ´£Ÿÿ{WSþwi\

J<421125 ;#H£ù^ÞÿC¶ùÿlÍýÿ’ßþÿŽéþÿ4Åþÿ!¼þÿ´þÿ¬þÿ£þÿ›þÿ’þÿ‹þÿþÿWâÿ #B #0 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
_D=¤¸¤ ÿ—†…ÿ°Ÿœÿ¿®©ÿ‘ywÿ{XUømd U C82/+&! %*R´öcçÿaÇþÿ”àþÿ…åþÿ%¿þÿ¶þÿ¬þÿ¤þÿœþÿ”þÿ‹þÿþÿzþÿSâÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lNFô•ƒ‚ÿ«š–ÿ«™•ÿyUQþ!{i]
J;/(#
  ".X·óbéÿÕþÿ{ßþÿ¸þÿ¬þÿ¥þÿžþÿ•þÿŽþÿ‚þÿ{þÿrþÿPàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
 W>7~Švuÿ¥”ÿwXUÿ{XUømcR

	<+  # # # #1]¸ñaæÿpÙþÿ®þÿ¦þÿžþÿ–þÿŽþÿ…þÿ}þÿtþÿlþÿMàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

 hJCݤ’ŽÿwTOþ#xeU>
'  # # # # # # #<j¶ätâÿpâÿlâÿhâÿdâÿ`àÿZâÿVâÿRàÿMàÿHàÿ #D #3 # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ I4/W~]XÿŒllð]T>% # # # # # # # # # # # #) #7 #@ #D #D #D #D #D #D #D #D #= #. # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ lUOµ7-.PE;%ÿÿÿ # # # # # # # # # # # # # #$ #. #2 #3 #3 #3 #3 #3 #3 #3 #. #" # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ#"#$ +!&! # #ÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ #! # # # #ÿÿÿÿÿÿÿÿÿ # # # # # # # # # # # # # # # # # # # # # # # # # # #ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

#18 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to a message not in the archive
Quoted 81 lines · Matt Helsley
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <clg-NmTC/[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Quoted 5 lines
Quoted 239 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
#20 lore raw

Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures

In reply to Matt Helsley
Quoted 81 lines · Matt Helsley
Quoted 14 lines · Cedric Le Goater
Quoted 6 lines · Nigel Cunningham

Hi.

Quoted 3 lines · Matt Helsley

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

Quoted 6 lines
Quoted 3 lines

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Is there a reason for always using 19, rather than just the next available bit?

Quoted 7 lines

At the time I did the patch, it was to be consistent with the other arches supporting suspend but this can not be true anymore. So we might as well just use the next available bit as you suggest.

Thanks,

C.

This is a good point.

I did a quick survey of the thread_info*.h headers. Most archs appear
to use the MSW/LSW to distinguish "pending work-to-be-done" (LSW) vs. other flags (MSW). This explains most of the gaps in thread flag assignment. In some other cases the bits are allocated based on whether the arch asm code uses asm immediate values to test the flag. sparc64 is by far the most elaborate and includes some excellent comments to explain the situation.

The gaps in allocated flag bit assignments not explained in thread_info*.h comments are:

mips doesn't use bit 0, there's a gap between 4 and 9, and another gap
between 24 and 31.

m32r has a gap between bit 4 and bit 8.

ia64 has a gap at bit 5.

blackfin doesn't explicitly mention the MSW/LSW distinction but appears
to follow it.

arm also doesn't mention MSW/LSW but appears consistent with that
explanation.

avr32 makes the MSW/LSW distinction but this doesn't fully explain
jumping from bit 8 to bit 30 unless they're allocating numbers in the opposite direction within the MSW (highest flag is bit 31).

m68k starts at 6 and the comments don't explain why. At first glance it
doesn't appear to be because of m68knommu. It also jumps from bit 7 to bit 14 without explanation and appears to not follow the MSW/LSW convention.

cris has an inexplicable gap between bit 3 and bit 9.

s390 has a gap at bit 1. It appears to follow the MSW/LSW distinction
but doesn't mention it in a comment.

x86 has a gap at bit 9.

"sparc32" has a gap between 4 and 8.

So I've modified the flag numbers to follow apparent conventions of each arch as best I can tell given the lack of explanation above.
------------
From: Cedric Le Goater <[email protected]>
Subject: Container Freezer: Add TIF_FREEZE flag to all architectures

This patch is the first step in making the refrigerator() available to all architectures, even for those without power management.

The purpose of such a change is to be able to use the refrigerator() in a new control group subsystem which will implement a control group freezer.

Quoted 5 lines
Quoted 239 lines
---
 arch/parisc/include/asm/thread_info.h   |    2 ++
 arch/sparc/include/asm/thread_info_32.h |    2 ++
 arch/sparc/include/asm/thread_info_64.h |    2 ++
 include/asm-alpha/thread_info.h         |    2 ++
 include/asm-avr32/thread_info.h         |    1 +
 include/asm-cris/thread_info.h          |    2 ++
 include/asm-h8300/thread_info.h         |    2 ++
 include/asm-m68k/thread_info.h          |    1 +
 include/asm-m68knommu/thread_info.h     |    2 ++
 include/asm-s390/thread_info.h          |    2 ++
 include/asm-um/thread_info.h            |    2 ++
 include/asm-xtensa/thread_info.h        |    2 ++
 12 files changed, 22 insertions(+)

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_32.h
===================================================================

arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -139,6 +139,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10
+#define TIF_FREEZE		11	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -152,6 +153,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | \
 					 _TIF_RESTORE_SIGMASK)
+#define TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/arch/sparc/include/asm/thread_info_64.h
===================================================================

arch/sparc/include/asm/thread_info_64.h +2 -0
@@ -237,6 +237,7 @@ register struct thread_info *current_thr
 #define TIF_ABI_PENDING		12
 #define TIF_MEMDIE		13
 #define TIF_POLLING_NRFLAG	14
+#define TIF_FREEZE		15	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -249,6 +250,7 @@ register struct thread_info *current_thr
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_ABI_PENDING	(1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK	((0xff << TI_FLAG_WSAVED_SHIFT) | \
 				 _TIF_DO_NOTIFY_RESUME_MASK | \

Index: linux-2.6.27-rc1-mm1/include/asm-alpha/thread_info.h
===================================================================

include/asm-alpha/thread_info.h +2 -0
@@ -74,12 +74,14 @@ register struct thread_info *__current_t
 #define TIF_UAC_SIGBUS		7
 #define TIF_MEMDIE		8
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 /* Work to do on interrupt/exception return.  */
 #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED)

Index: linux-2.6.27-rc1-mm1/include/asm-avr32/thread_info.h
===================================================================

include/asm-avr32/thread_info.h +1 -0
@@ -96,6 +96,7 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 /* Note: The masks below must never span more than 16 bits! */
 

Index: linux-2.6.27-rc1-mm1/include/asm-cris/thread_info.h
===================================================================

include/asm-cris/thread_info.h +2 -0
@@ -88,6 +88,7 @@ struct thread_info {
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
 #define TIF_MEMDIE		17
+#define TIF_FREEZE		18	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
@@ -95,6 +96,7 @@ struct thread_info {
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/include/asm-h8300/thread_info.h
===================================================================

include/asm-h8300/thread_info.h +2 -0
@@ -89,6 +89,7 @@ static inline struct thread_info *curren
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -96,6 +97,7 @@ static inline struct thread_info *curren
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-m68k/thread_info.h
===================================================================

include/asm-m68k/thread_info.h +1 -0
@@ -52,5 +52,6 @@ struct thread_info {
 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
 #define TIF_SYSCALL_TRACE	15	/* syscall trace active */
 #define TIF_MEMDIE		16
+#define TIF_FREEZE		17	/* thread is freezing for suspend */
 
 #endif	/* _ASM_M68K_THREAD_INFO_H */

Index: linux-2.6.27-rc1-mm1/include/asm-m68knommu/thread_info.h
===================================================================

include/asm-m68knommu/thread_info.h +2 -0
@@ -84,12 +84,14 @@ static inline struct thread_info *curren
 #define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
 					   TIF_NEED_RESCHED */
 #define TIF_MEMDIE		4
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 

Index: linux-2.6.27-rc1-mm1/include/asm-s390/thread_info.h
===================================================================

include/asm-s390/thread_info.h +2 -0
@@ -98,6 +98,7 @@ static inline struct thread_info *curren
 #define TIF_31BIT		18	/* 32bit process */ 
 #define TIF_MEMDIE		19
 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
+#define TIF_FREEZE		21	/* thread is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
@@ -110,6 +111,7 @@ static inline struct thread_info *curren
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_31BIT		(1<<TIF_31BIT)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #endif /* __KERNEL__ */
 

Index: linux-2.6.27-rc1-mm1/include/asm-um/thread_info.h
===================================================================

include/asm-um/thread_info.h +2 -0
@@ -69,6 +69,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE	 	5
 #define TIF_SYSCALL_AUDIT	6
 #define TIF_RESTORE_SIGMASK	7
+#define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -77,5 +78,6 @@ static inline struct thread_info *curren
 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #endif

Index: linux-2.6.27-rc1-mm1/include/asm-xtensa/thread_info.h
===================================================================

include/asm-xtensa/thread_info.h +2 -0
@@ -134,6 +134,7 @@ static inline struct thread_info *curren
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+#define TIF_FREEZE		17	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
@@ -142,6 +143,7 @@ static inline struct thread_info *curren
 #define _TIF_IRET		(1<<TIF_IRET)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 #define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x0000FFFF	/* work to do on any return to u-space */

Index: linux-2.6.27-rc1-mm1/arch/parisc/include/asm/thread_info.h
===================================================================

arch/parisc/include/asm/thread_info.h +2 -0
@@ -58,6 +58,7 @@ struct thread_info {
 #define TIF_32BIT               4       /* 32 bit binary */
 #define TIF_MEMDIE		5
 #define TIF_RESTORE_SIGMASK	6	/* restore saved signal mask */
+#define TIF_FREEZE		7	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
@@ -65,6 +66,7 @@ struct thread_info {
 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1 << TIF_32BIT)
 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+#define _TIF_FREEZE		(1 << TIF_FREEZE)
 
 #define _TIF_USER_WORK_MASK     (_TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
#59 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley
Quoted 134 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +61 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+

include/linux/cgroup_freezer.h line 71

Quoted 10 lines
include/linux/cgroup_freezer.h new file +10 -0
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Thanks,
Rafael

#73 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to a message not in the archive
Quoted 134 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +61 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <clg-NmTC/[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+

include/linux/cgroup_freezer.h line 71

Quoted 10 lines
include/linux/cgroup_freezer.h new file +10 -0
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Thanks,
Rafael

#74 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley
Quoted 134 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +61 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+

include/linux/cgroup_freezer.h line 71

Quoted 10 lines
include/linux/cgroup_freezer.h new file +10 -0
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Thanks,
Rafael

#35 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Rafael J. Wysocki

On Sat, 2008-08-02 at 00:53 +-0200, Rafael J. Wysocki wrote:
+AD4 On Friday, 1 of August 2008, Matt Helsley wrote:
+AD4 +AD4
+AD4 +AD4 On Fri, 2008-08-01 at 16:27 +-0200, Thomas Petazzoni wrote:
+AD4 +AD4 +AD4 Hi,
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 Le Thu, 31 Jul 2008 22:07:01 -0700,
+AD4 +AD4 +AD4 Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4 a +AOk-crit :
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 +AD4 --- a/kernel/Makefile
+AD4 +AD4 +AD4 +AD4 +-+-+- b/kernel/Makefile
+AD4 +AD4 +AD4 +AD4 +AEAAQA -5,7 +-5,7 +AEAAQA

+AD4 +AD4 +AD4 +AD4  obj-y     +AD0 sched.o fork.o exec+AF8-domain.o panic.o printk.o +AFw
+AD4 +AD4 +AD4 +AD4  	    cpu.o exit.o itimer.o time.o softirq.o resource.o +AFw
+AD4 +AD4 +AD4 +AD4  	    sysctl.o capability.o ptrace.o timer.o user.o +AFw

+AD4 +AD4 +AD4 +AD4 - signal.o sys.o kmod.o workqueue.o pid.o +AFw
+AD4 +AD4 +AD4 +AD4 +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o +AFw
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 I have the impression that the code in kernel/power/process.c was +AD4 +AD4 +AD4 compiled only if CONFIG+AF8-PM+AF8-SLEEP was set. Now that the code has been +AD4 +AD4 +AD4 moved to kernel/freezer.c, it is unconditionnaly compiled in every +AD4 +AD4 +AD4 kernel. Is that correct ?
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 If so, is it possible to put this new feature under some
+AD4 +AD4 +AD4 CONFIG+AF8-SOMETHING option, for people who care about the kernel size ? +AD4 +AD4
+AD4 +AD4 How about making it depend on a combination of CONFIG variables?
+AD4 +AD4 Here's an RFC PATCH. Completely untested.
+AD4 +AD4
+AD4 +AD4 Signed-off-by: Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4
+AD4
+AD4 Can you please also make the contents of include/linux/freezer.h depend on +AD4 CONFIG+AF8-FREEZER instead of CONFIG+AF8-PM+AF8-SLEEP?

Good point -- I'll add that to this patch and repost.

+AD4 Also, I'm not really sure if kernel/power/Kconfig is the right place to define +AD4 CONFIG+AF8-FREEZER.

There's no nice place to put it since we're dealing with CONFIG+AF8
variables in two different Kconfig files. I put it in kernel/power/Kconfig because I wasn't certain Kbuild would do the right thing if I referenced PM+AF8-SLEEP from init/Kconfig.

+AD4 Perhaps we should even move freezer.c from kernel/power to kernel

It's already there. Perhaps you meant something else (kernel/power/process.c?)?

+AD4 and define CONFIG+AF8-FREEZER in Kconfig in there. Andrew, what do you think?

The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which don't seem appropriate. I suppose we could add another (perhaps Kconfig.cgroup).

Thanks for the review+ACE

Cheers,
-Matt

#41 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Matt Helsley
Quoted 13 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>>>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>>>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>>>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>>>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 1 line
Quoted 1 line
Quoted 1 line

If so, is it possible to put this new feature under some

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Good point -- I'll add that to this patch and repost.

Quoted 2 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

There's no nice place to put it since we're dealing with CONFIG_variables in two different Kconfig files. I put it in
kernel/power/Kconfig because I wasn't certain Kbuild would do the right
thing if I referenced PM_SLEEP from init/Kconfig.

Quoted 1 line

Perhaps we should even move freezer.c from kernel/power to kernel

It's already there. Perhaps you meant something else (kernel/power/process.c?)?

Quoted 1 line

and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which don't seem appropriate. I suppose we could add another (perhaps Kconfig.cgroup).

Thanks for the review!
Cheers,
-Matt

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#43 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Rafael J. Wysocki
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Matt Helsley
Quoted 13 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>>>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>>>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>>>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>>>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 1 line
Quoted 1 line
Quoted 1 line

If so, is it possible to put this new feature under some

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Good point -- I'll add that to this patch and repost.

Quoted 2 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

There's no nice place to put it since we're dealing with CONFIG_variables in two different Kconfig files. I put it in
kernel/power/Kconfig because I wasn't certain Kbuild would do the right
thing if I referenced PM_SLEEP from init/Kconfig.

Quoted 1 line

Perhaps we should even move freezer.c from kernel/power to kernel

It's already there. Perhaps you meant something else (kernel/power/process.c?)?

Quoted 1 line

and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which don't seem appropriate. I suppose we could add another (perhaps Kconfig.cgroup).

Thanks for the review!
Cheers,
-Matt

#61 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to a message not in the archive
Quoted 140 lines · Rafael J. Wysocki
Quoted 139 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +66 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <clg-NmTC/[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 5 lines
include/linux/cgroup_freezer.h new file +5 -0
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

Cheers,
-Matt

#62 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Rafael J. Wysocki
Quoted 140 lines · Rafael J. Wysocki
Quoted 139 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +66 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 5 lines
include/linux/cgroup_freezer.h new file +5 -0
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

Cheers,
-Matt

#63 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Rafael J. Wysocki
Quoted 140 lines · Rafael J. Wysocki
Quoted 139 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +66 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	return 0;
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 5 lines
include/linux/cgroup_freezer.h new file +5 -0
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

Cheers,
-Matt

#42 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Matt Helsley
Quoted 13 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>>>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>>>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>>>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>>>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 1 line
Quoted 1 line
Quoted 1 line

If so, is it possible to put this new feature under some

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Done.

Quoted 5 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Perhaps we should even move freezer.c from kernel/power to kernel and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

I'll check this weekend for replies and repost the RFC PATCH on Monday
if I don't hear anything. In the meantime I'll be doing some config build testing with the above changes to make sure it's correct.

Cheers,
-Matt

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#44 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Rafael J. Wysocki

On Sat, 2008-08-02 at 00:53 +-0200, Rafael J. Wysocki wrote:
+AD4 On Friday, 1 of August 2008, Matt Helsley wrote:
+AD4 +AD4
+AD4 +AD4 On Fri, 2008-08-01 at 16:27 +-0200, Thomas Petazzoni wrote:
+AD4 +AD4 +AD4 Hi,
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 Le Thu, 31 Jul 2008 22:07:01 -0700,
+AD4 +AD4 +AD4 Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4 a +AOk-crit :
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 +AD4 --- a/kernel/Makefile
+AD4 +AD4 +AD4 +AD4 +-+-+- b/kernel/Makefile
+AD4 +AD4 +AD4 +AD4 +AEAAQA -5,7 +-5,7 +AEAAQA

+AD4 +AD4 +AD4 +AD4  obj-y     +AD0 sched.o fork.o exec+AF8-domain.o panic.o printk.o +AFw
+AD4 +AD4 +AD4 +AD4  	    cpu.o exit.o itimer.o time.o softirq.o resource.o +AFw
+AD4 +AD4 +AD4 +AD4  	    sysctl.o capability.o ptrace.o timer.o user.o +AFw

+AD4 +AD4 +AD4 +AD4 - signal.o sys.o kmod.o workqueue.o pid.o +AFw
+AD4 +AD4 +AD4 +AD4 +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o +AFw
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 I have the impression that the code in kernel/power/process.c was +AD4 +AD4 +AD4 compiled only if CONFIG+AF8-PM+AF8-SLEEP was set. Now that the code has been +AD4 +AD4 +AD4 moved to kernel/freezer.c, it is unconditionnaly compiled in every +AD4 +AD4 +AD4 kernel. Is that correct ?
+AD4 +AD4 +AD4
+AD4 +AD4 +AD4 If so, is it possible to put this new feature under some
+AD4 +AD4 +AD4 CONFIG+AF8-SOMETHING option, for people who care about the kernel size ? +AD4 +AD4
+AD4 +AD4 How about making it depend on a combination of CONFIG variables?
+AD4 +AD4 Here's an RFC PATCH. Completely untested.
+AD4 +AD4
+AD4 +AD4 Signed-off-by: Matt Helsley +ADw-matthltc+AEA-us.ibm.com+AD4
+AD4
+AD4 Can you please also make the contents of include/linux/freezer.h depend on +AD4 CONFIG+AF8-FREEZER instead of CONFIG+AF8-PM+AF8-SLEEP?

Done.

+AD4 Also, I'm not really sure if kernel/power/Kconfig is the right place to define +AD4 CONFIG+AF8-FREEZER.
+AD4
+AD4 Perhaps we should even move freezer.c from kernel/power to kernel +AD4 and define CONFIG+AF8-FREEZER in Kconfig in there. Andrew, what do you think?

I'll check this weekend for replies and repost the RFC PATCH on Monday
if I don't hear anything. In the meantime I'll be doing some config build testing with the above changes to make sure it's correct.

Cheers,
-Matt

#45 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Rafael J. Wysocki
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Matt Helsley
Quoted 13 lines · Thomas Petazzoni

Hi,

Quoted 3 lines · Matt Helsley

--- a/kernel/Makefile

+-+-+- b/kernel/Makefile
@@-5,7 +-5,7 @@>>>> obj-y     =sched.o fork.o exec_domain.o panic.o printk.o \>>>> 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \>>>> 	    sysctl.o capability.o ptrace.o timer.o user.o \>>>>-	    signal.o sys.o kmod.o workqueue.o pid.o \>>>>+-	    signal.o sys.o kmod.o workqueue.o pid.o freezer.o \>>>

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

Quoted 1 line
Quoted 1 line
Quoted 1 line

If so, is it possible to put this new feature under some

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

CONFIG_SOMETHING option, for people who care about the kernel size ?

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Done.

Quoted 5 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Perhaps we should even move freezer.c from kernel/power to kernel and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

I'll check this weekend for replies and repost the RFC PATCH on Monday
if I don't hear anything. In the meantime I'll be doing some config build testing with the above changes to make sure it's correct.

Cheers,
-Matt

#65 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to a message not in the archive
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <clg-NmTC/[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}

and kill include/linux/cgroup_freezer.h ?

Thanks Matt,

C.

#66 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}

and kill include/linux/cgroup_freezer.h ?

Thanks Matt,

C.

#67 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Matt Helsley
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}

and kill include/linux/cgroup_freezer.h ?

Thanks Matt,

C.

#48 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive
Quoted 2 lines · Matt Helsley

How about making it depend on a combination of CONFIG
variables? Here's an RFC PATCH. Completely untested.

It solves my kernel size increase problem, so it's perfectly fine for me.

Thanks!

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
#50 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

Le Fri, 01 Aug 2008 12:08:09 -0700,
Matt Helsley <[email protected]> a écrit :

Quoted 2 lines

How about making it depend on a combination of CONFIG
variables? Here's an RFC PATCH. Completely untested.

It solves my kernel size increase problem, so it's perfectly fine for me.

Thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#51 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley
Quoted 2 lines · Matt Helsley

How about making it depend on a combination of CONFIG
variables? Here's an RFC PATCH. Completely untested.

It solves my kernel size increase problem, so it's perfectly fine for me.

Thanks!

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#36 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley

On Saturday, 2 of August 2008, Matt Helsley wrote:> > On Sat, 2008-08-02 at 00:53 +-0200, Rafael J. Wysocki wrote:> > On Friday, 1 of August 2008, Matt Helsley wrote:> > > > > > On Fri, 2008-08-01 at 16:27 +-0200, Thomas Petazzoni wrote:> > > > Hi,> > > > > > > > Le Thu, 31 Jul 2008 22:07:01 -0700,> > > > Matt Helsley <[email protected]> a écrit :> > > > > > > > > --- a/kernel/Makefile> > > > > +-+-+- b/kernel/Makefile> > > > > @@ -5,7 +-5,7 @@> > > > > obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ > > > > cpu.o exit.o itimer.o time.o softirq.o resource.o \ > > > > sysctl.o capability.o ptrace.o timer.o user.o \ > > > > - signal.o sys.o kmod.o workqueue.o pid.o \ > > > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \ > > > > > > > I have the impression that the code in kernel/power/process.c was> > > > compiled only if CONFIG_PM_SLEEP was set. Now that the code has been> > > > moved to kernel/freezer.c, it is unconditionnaly compiled in every> > > > kernel. Is that correct ?> > > >> > > > If so, is it possible to put this new feature under some> > > > CONFIG_SOMETHING option, for people who care about the kernel size ?> > > > > > How about making it depend on a combination of CONFIG variables?> > > Here's an RFC PATCH. Completely untested.> > > > > > Signed-off-by: Matt Helsley <[email protected]>> > > > Can you please also make the contents of include/linux/freezer.h depend on> > CONFIG_FREEZER instead of CONFIG_PM_SLEEP?> > Good point -- I'll add that to this patch and repost.> > > Also, I'm not really sure if kernel/power/Kconfig is the right place to define> > CONFIG_FREEZER.> > There's no nice place to put it since we're dealing with CONFIG_> variables in two different Kconfig files. I put it in> kernel/power/Kconfig because I wasn't certain Kbuild would do the right> thing if I referenced PM_SLEEP from init/Kconfig.> > > Perhaps we should even move freezer.c from kernel/power to kernel> > It's already there.
Yes, sorry.

Quoted 1 line

Perhaps you meant something else (kernel/power/process.c?)?

Well, I'll have to actually apply the patches and look at the modified code.

Quoted 1 line
Quoted 1 line

and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?> > The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which> don't seem appropriate. I suppose we could add another (perhaps> Kconfig.cgroup).

Either that, or Kconfig.freezer maybe? After all, it will also be used forPM_SLEEP, at least for some time.

Quoted 1 line

Thanks for the review!

You're welcome.
Thanks,Rafael7mNóùnÐ7mNóp4o0¾gApàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNó`5o€5oÑpàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNóP6op6oapàÀ©šMóÐ7mNó6oÐ7mNóùnÐ7mNó@7o`7oñpàÀ©šMóÐ7mNó€7oÐ7mNóùnÐ7mNó08oP8opàÀ©šMóÐ7mNóp8oÐ7mNóùnÐ7mNó 9o@9opàÀ©šMóÐ7mNó`9oÐ7mNóùnÐ7mNó:o0:o¡pàÀ©šMóÐ7mNóP:oÐ7mNóùnÐ7mNó;o ;o1pàÀ©šMóÐ7mNó@;oÐ7mNóùnÐ7mNóð;o<oÁpàÀ©šMóÐ7mNó0<oÐ7mNóùnÐ7mNóà<o=oQpàÀ©šMóÐ7mNó =oÐ7mNóùnÐ7mNóÐ=oð=oápàÀ©šMóÐ7mNó>oÐ7mNóùnÐ7mNóÀ>oà>oqpàÀ©šMóÐ7mNó?oÐ7mNóùnÐ7mNó°?oÐ?opàÀ©šMóÐ7mNóð?oÐ7mNóùnÐ7mNó @oÀ@o‘pàÀ©šMóÐ7mNóà@oÐ7mNóùnÐ7mNóAo°Ao!pàÀ©šMóÐ7mNóÐAoÐ7mNóùnÐ7mNó€Bo Bo±pàÀ©šMóÐ7mNóÀBoÐ7mNóùnÐ7mNópCoCoApàÀ©šMóÐ7mNó°CoÐ7mNóùnÐ7mNó`Do€DoÑ pàÀ©šMóÐ7mNó DoÐ7mNóùnÐ7mNóPEopEoa pàÀ©šMóÐ7mNóEoÐ7mNóùnÐ7mNó@Fo`Foñ pàÀ©šMóÐ7mNó€FoÐ7mNóùnÐ7mNó0GoPGo pàÀ©šMóÐ7mNópGoÐ7mNóùnÐ7mNó Ho@Ho pàÀ©šMóÐ7mNó`HoÐ7mNóùnÐ7mNóIo0Io¡ pàÀ©šMóÐ7mNó4oÐ7mNóùnÐ7mNóàIo€¾g1 pàÀ©šMóÐ7mNó JoÐ7mNóùnÐ7mNóÐJoðJoÁpàÀ©šMóÐ7mNóÀoÐ7mNóùnÐ7mNóÀKoàKoQpàÀ©šMóÐ7mNóLoÐ7mNóùnÐ7mNó°LoÐLoá pàÀ©šMóÐ7mNóðLoÐ7mNóùnÐ7mNó MoÀMoq pàÀ©šMóÐ7mNópNoÐ7mNó@!oÐ7mNóàMo pàÀ©šMóÐ7mNó@OoÐ7mNó@!oÐ7mNó€Oo Oo‘pàÀ©šMóÐ7mNóÀOoÐ7mNó@!oÐ7mNópPoPo!pàÀ©šMóÐ7mNó°PoÐ7mNó@!oÐ7mNó`Qo€Qo±pàÀ©šMóÐ7mNó QoÐ7mNó@!oÐ7mNóPRopRoApàÀ©šMóÐ7mNóRoÐ7mNó@!oÐ7mNó@So`SoÑpàÀ©šMóÐ7mNó€SoÐ7mNó@!oÐ7mNó0ToPToapàÀ©šMóÐ7mNópToÐ7mNó@!oÐ7mNó Uo@UoñpàÀ©šMóÐ7mNó`UoÐ7mNó@!oÐ7mNóVo0VopàÀ©šMóÐ7mNóPVoÐ7mNó@!oÐ7mNóWo WopàÀ©šMóÐ7mNó@WoÐ7mNó@!oÐ7mNóðWoXo¡pàÀ©šMóÐ7mNó0XoÐ7mNó@!oÐ7mNóàXoYo1pàÀ©šMóÐ7mNó YoÐ7mNó@!oÐ7mNóÐYoðYoÁpàÀ©šMó€‚Ð7mNó°NoÐ7mNó@!oÐ7mNó Zo[oQpàÀ©šMó`‚Ð7mNóàZoÐ7mNó@!oÐ7mNóÀ[oà[oápàÀ©šMó€‚Ð7mNó\oÐ7mNó@!oÐ7mNó°\oÐ\oqpàÀ©šMó ‚Ð7mNóð\oÐ7mNó@!oÐ7mNó ]oÀ]opàÀ©šMó@‚Ð7mNóà]oÐ7mNó@!oÐ7mNó^o°^o‘pàÀ©šMó`‚Ð7mNóÐ^oÐ7mNó@!oÐ7mNó€_oÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayºʇڙë,j­¢f£¢·hšïêÿ‘êçz_è®(­éšŽŠÝ¢j"ú¶m§ÿÿ¾«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^¶m§ÿÿà ÿ¶ìÿ¢¸?–I¥

#68 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Cedric Le Goater
Quoted 191 lines · Cedric Le Goater
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}
Quoted 1 line

and kill include/linux/cgroup_freezer.h ?

I'd prefer this.

Thanks,
Rafael

#38 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to a message not in the archive
Quoted 35 lines · Matt Helsley
Quoted 20 lines · Rafael J. Wysocki
Quoted 19 lines · Matt Helsley
Quoted 16 lines · Thomas Petazzoni

Hi,

Quoted 4 lines · Matt Helsley

--- a/kernel/Makefile
+-+-+- b/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> > > > > cpu.o exit.o itimer.o time.o softirq.o resource.o \> > > > > sysctl.o capability.o ptrace.o timer.o user.o \> > > > > - signal.o sys.o kmod.o workqueue.o pid.o \> > > > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> > > >

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

Quoted 7 lines
Quoted 4 lines

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Good point -- I'll add that to this patch and repost.

Quoted 2 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Quoted 8 lines

There's no nice place to put it since we're dealing with CONFIG_
variables in two different Kconfig files. I put it in kernel/power/Kconfig because I wasn't certain Kbuild would do the right thing if I referenced PM_SLEEP from init/Kconfig.

Quoted 1 line

Perhaps we should even move freezer.c from kernel/power to kernel

It's already there.

Yes, sorry.

Quoted 1 line

Perhaps you meant something else (kernel/power/process.c?)?

Well, I'll have to actually apply the patches and look at the modified code.

Quoted 5 lines
Quoted 1 line

and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which don't seem appropriate. I suppose we could add another (perhaps Kconfig.cgroup).

Either that, or Kconfig.freezer maybe? After all, it will also be used for PM_SLEEP, at least for some time.

Quoted 1 line

Thanks for the review!

You're welcome.

Thanks,
Rafael
7mNóùnÐ7mNóp4o0¾gApàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNó`5o€5oÑpàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNóP6op6oapàÀ©šMóÐ7mNó6oÐ7mNóùnÐ7mNó@7o`7oñpàÀ©šMóÐ7mNó€7oÐ7mNóùnÐ7mNó08oP8opàÀ©šMóÐ7mNóp8oÐ7mNóùnÐ7mNó 9o@9opàÀ©šMóÐ7mNó`9oÐ7mNóùnÐ7mNó:o0:o¡pàÀ©šMóÐ7mNóP:oÐ7mNóùnÐ7mNó;o ;o1pàÀ©šMóÐ7mNó@;oÐ7mNóùnÐ7mNóð;o<oÁpàÀ©šMóÐ7mNó0<oÐ7mNóùnÐ7mNóà<o=oQpàÀ©šMóÐ7mNó =oÐ7mNóùnÐ7mNóÐ=oð=oápàÀ©šMóÐ7mNó>oÐ7mNóùnÐ7mNóÀ>oà>oqpàÀ©šMóÐ7mNó?oÐ7mNóùnÐ7mNó°?oÐ?opàÀ©šMóÐ7mNóð?oÐ7mNóùnÐ7mNó @oÀ@o‘pàÀ©šMóÐ7mNóà@oÐ7mNóùnÐ7mNóAo°Ao!pàÀ©šMóÐ7mNóÐAoÐ7mNóùnÐ7mNó€Bo Bo±pàÀ©šMóÐ7mNóÀBoÐ7mNóùnÐ7mNópCoCoApàÀ©šMóÐ7mNó°CoÐ7mNóùnÐ7mNó`Do€DoÑ pàÀ©šMóÐ7mNó DoÐ7mNóùnÐ7mNóPEopEoa pàÀ©šMóÐ7mNóEoÐ7mNóùnÐ7mNó@Fo`Foñ pàÀ©šMóÐ7mNó€FoÐ7mNóùnÐ7mNó0GoPGo pàÀ©šMóÐ7mNópGoÐ7mNóùnÐ7mNó Ho@Ho pàÀ©šMóÐ7mNó`HoÐ7mNóùnÐ7mNóIo0Io¡ pàÀ©šMóÐ7mNó4oÐ7mNóùnÐ7mNóàIo€¾g1 pàÀ©šMóÐ7mNó JoÐ7mNóùnÐ7mNóÐJoðJoÁ pàÀ©šMóÐ7mNóÀoÐ7mNóùnÐ7mNóÀKoàKoQ
pàÀ©šMóÐ7mNóLoÐ7mNóùnÐ7mNó°LoÐLoá pàÀ©šMóÐ7mNóðLoÐ7mNóùnÐ7mNó MoÀMoq pàÀ©šMóÐ7mNópNoÐ7mNó@!oÐ7mNóàMo pàÀ©šMóÐ7mNó@OoÐ7mNó@!oÐ7mNó€Oo Oo‘pàÀ©šMóÐ7mNóÀOoÐ7mNó@!oÐ7mNópPoPo!pàÀ©šMóÐ7mNó°PoÐ7mNó@!oÐ7mNó`Qo€Qo±pàÀ©šMóÐ7mNó QoÐ7mNó@!oÐ7mNóPRopRoApàÀ©šMóÐ7mNóRoÐ7mNó@!oÐ7mNó@So`SoÑpàÀ©šMóÐ7mNó€SoÐ7mNó@!oÐ7mNó0ToPToapàÀ©šMóÐ7mNópToÐ7mNó@!oÐ7mNó Uo@UoñpàÀ©šMóÐ7mNó`UoÐ7mNó@!oÐ7mNóVo0VopàÀ©šMóÐ7mNóPVoÐ7mNó@!oÐ7mNóWo WopàÀ©šMóÐ7mNó@WoÐ7mNó@!oÐ7mNóðWoXo¡pàÀ©šMóÐ7mNó0XoÐ7mNó@!oÐ7mNóàXoYo1pàÀ©šMóÐ7mNó YoÐ7mNó@!oÐ7mNóÐYoðYoÁpàÀ©šMó€‚Ð7mNó°NoÐ7mNó@!oÐ7mNó Zo[oQpàÀ©šMó`‚Ð7mNóàZoÐ7mNó@!oÐ7mNóÀ[oà[oápàÀ©šMó€‚Ð7mNó\oÐ7mNó@!oÐ7mNó°\oÐ\oqpàÀ©šMó ‚Ð7mNóð\oÐ7mNó@!oÐ7mNó ]oÀ]opàÀ©šMó@‚Ð7mNóà]oÐ7mNó@!oÐ7mNó^o°^o‘pàÀ©šMó`‚Ð7mNóÐ^oÐ7mNó@!oÐ7mNó€_o

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#39 lore raw

Re: [PATCH 2/6] Container Freezer: Make refrigerator always available

In reply to Matt Helsley
Quoted 35 lines · Matt Helsley
Quoted 20 lines · Rafael J. Wysocki
Quoted 19 lines · Matt Helsley
Quoted 16 lines · Thomas Petazzoni

Hi,

Quoted 4 lines · Matt Helsley

--- a/kernel/Makefile
+-+-+- b/kernel/Makefile
@@ -5,7 +-5,7 @@
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \> > > > > cpu.o exit.o itimer.o time.o softirq.o resource.o \> > > > > sysctl.o capability.o ptrace.o timer.o user.o \> > > > > - signal.o sys.o kmod.o workqueue.o pid.o \> > > > > +- signal.o sys.o kmod.o workqueue.o pid.o freezer.o \> > > >

I have the impression that the code in kernel/power/process.c was compiled only if CONFIG_PM_SLEEP was set. Now that the code has been moved to kernel/freezer.c, it is unconditionnaly compiled in every kernel. Is that correct ?

If so, is it possible to put this new feature under some CONFIG_SOMETHING option, for people who care about the kernel size ?

Quoted 7 lines
Quoted 4 lines

How about making it depend on a combination of CONFIG variables?
Here's an RFC PATCH. Completely untested.

Can you please also make the contents of include/linux/freezer.h depend on CONFIG_FREEZER instead of CONFIG_PM_SLEEP?

Good point -- I'll add that to this patch and repost.

Quoted 2 lines

Also, I'm not really sure if kernel/power/Kconfig is the right place to define CONFIG_FREEZER.

Quoted 8 lines

There's no nice place to put it since we're dealing with CONFIG_
variables in two different Kconfig files. I put it in kernel/power/Kconfig because I wasn't certain Kbuild would do the right thing if I referenced PM_SLEEP from init/Kconfig.

Quoted 1 line

Perhaps we should even move freezer.c from kernel/power to kernel

It's already there.

Yes, sorry.

Quoted 1 line

Perhaps you meant something else (kernel/power/process.c?)?

Well, I'll have to actually apply the patches and look at the modified code.

Quoted 5 lines
Quoted 1 line

and define CONFIG_FREEZER in Kconfig in there. Andrew, what do you think?

The Kconfig files in kernel/ are Kconfig.hz and Kconfig.preemt which don't seem appropriate. I suppose we could add another (perhaps Kconfig.cgroup).

Either that, or Kconfig.freezer maybe? After all, it will also be used for PM_SLEEP, at least for some time.

Quoted 1 line

Thanks for the review!

You're welcome.

Thanks,
Rafael
7mNóùnÐ7mNóp4o0¾gApàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNó`5o€5oÑpàÀ©šMóÐ7mNó 5oÐ7mNóùnÐ7mNóP6op6oapàÀ©šMóÐ7mNó6oÐ7mNóùnÐ7mNó@7o`7oñpàÀ©šMóÐ7mNó€7oÐ7mNóùnÐ7mNó08oP8opàÀ©šMóÐ7mNóp8oÐ7mNóùnÐ7mNó 9o@9opàÀ©šMóÐ7mNó`9oÐ7mNóùnÐ7mNó:o0:o¡pàÀ©šMóÐ7mNóP:oÐ7mNóùnÐ7mNó;o ;o1pàÀ©šMóÐ7mNó@;oÐ7mNóùnÐ7mNóð;o<oÁpàÀ©šMóÐ7mNó0<oÐ7mNóùnÐ7mNóà<o=oQpàÀ©šMóÐ7mNó =oÐ7mNóùnÐ7mNóÐ=oð=oápàÀ©šMóÐ7mNó>oÐ7mNóùnÐ7mNóÀ>oà>oqpàÀ©šMóÐ7mNó?oÐ7mNóùnÐ7mNó°?oÐ?opàÀ©šMóÐ7mNóð?oÐ7mNóùnÐ7mNó @oÀ@o‘pàÀ©šMóÐ7mNóà@oÐ7mNóùnÐ7mNóAo°Ao!pàÀ©šMóÐ7mNóÐAoÐ7mNóùnÐ7mNó€Bo Bo±pàÀ©šMóÐ7mNóÀBoÐ7mNóùnÐ7mNópCoCoApàÀ©šMóÐ7mNó°CoÐ7mNóùnÐ7mNó`Do€DoÑ pàÀ©šMóÐ7mNó DoÐ7mNóùnÐ7mNóPEopEoa pàÀ©šMóÐ7mNóEoÐ7mNóùnÐ7mNó@Fo`Foñ pàÀ©šMóÐ7mNó€FoÐ7mNóùnÐ7mNó0GoPGo pàÀ©šMóÐ7mNópGoÐ7mNóùnÐ7mNó Ho@Ho pàÀ©šMóÐ7mNó`HoÐ7mNóùnÐ7mNóIo0Io¡ pàÀ©šMóÐ7mNó4oÐ7mNóùnÐ7mNóàIo€¾g1 pàÀ©šMóÐ7mNó JoÐ7mNóùnÐ7mNóÐJoðJoÁ pàÀ©šMóÐ7mNóÀoÐ7mNóùnÐ7mNóÀKoàKoQ
pàÀ©šMóÐ7mNóLoÐ7mNóùnÐ7mNó°LoÐLoá pàÀ©šMóÐ7mNóðLoÐ7mNóùnÐ7mNó MoÀMoq pàÀ©šMóÐ7mNópNoÐ7mNó@!oÐ7mNóàMo pàÀ©šMóÐ7mNó@OoÐ7mNó@!oÐ7mNó€Oo Oo‘pàÀ©šMóÐ7mNóÀOoÐ7mNó@!oÐ7mNópPoPo!pàÀ©šMóÐ7mNó°PoÐ7mNó@!oÐ7mNó`Qo€Qo±pàÀ©šMóÐ7mNó QoÐ7mNó@!oÐ7mNóPRopRoApàÀ©šMóÐ7mNóRoÐ7mNó@!oÐ7mNó@So`SoÑpàÀ©šMóÐ7mNó€SoÐ7mNó@!oÐ7mNó0ToPToapàÀ©šMóÐ7mNópToÐ7mNó@!oÐ7mNó Uo@UoñpàÀ©šMóÐ7mNó`UoÐ7mNó@!oÐ7mNóVo0VopàÀ©šMóÐ7mNóPVoÐ7mNó@!oÐ7mNóWo WopàÀ©šMóÐ7mNó@WoÐ7mNó@!oÐ7mNóðWoXo¡pàÀ©šMóÐ7mNó0XoÐ7mNó@!oÐ7mNóàXoYo1pàÀ©šMóÐ7mNó YoÐ7mNó@!oÐ7mNóÐYoðYoÁpàÀ©šMó€‚Ð7mNó°NoÐ7mNó@!oÐ7mNó Zo[oQpàÀ©šMó`‚Ð7mNóàZoÐ7mNó@!oÐ7mNóÀ[oà[oápàÀ©šMó€‚Ð7mNó\oÐ7mNó@!oÐ7mNó°\oÐ\oqpàÀ©šMó ‚Ð7mNóð\oÐ7mNó@!oÐ7mNó ]oÀ]opàÀ©šMó@‚Ð7mNóà]oÐ7mNó@!oÐ7mNó^o°^o‘pàÀ©šMó`‚Ð7mNóÐ^oÐ7mNó@!oÐ7mNó€_o

#70 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to a message not in the archive
Quoted 191 lines · Cedric Le Goater
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <clg-NmTC/[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}
Quoted 1 line

and kill include/linux/cgroup_freezer.h ?

I'd prefer this.

Thanks,
Rafael

#71 lore raw

Re: [PATCH 3/6] Container Freezer: Implement freezer cgroup subsystem

In reply to Cedric Le Goater
Quoted 191 lines · Cedric Le Goater
Quoted 149 lines · Matt Helsley
Quoted 139 lines · Rafael J. Wysocki
Quoted 138 lines · Matt Helsley

This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem.

The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state.

* Examples of usage :

   # mkdir /containers/freezer
   # mount -t cgroup -ofreezer freezer  /containers
   # mkdir /containers/0
   # echo $some_pid > /containers/0/tasks

to get status of the freezer subsystem :

   # cat /containers/0/freezer.state
   RUNNING

to freeze all tasks in the container :

   # echo FROZEN > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   FREEZING
   # cat /containers/0/freezer.state
   FROZEN

to unfreeze all tasks in the container :

   # echo RUNNING > /containers/0/freezer.state
   # cat /containers/0/freezer.state
   RUNNING

This is the basic mechanism which should do the right thing for user space task in a simple scenario.

It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens:

1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file
2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO)
3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks.

---
 include/linux/cgroup_freezer.h |   71 ++++++++
 include/linux/cgroup_subsys.h  |    6 
 include/linux/freezer.h        |   16 +-
 init/Kconfig                   |    7 
 kernel/Makefile                |    1 
 kernel/cgroup_freezer.c        |  328 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 425 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/cgroup_freezer.h
 create mode 100644 kernel/cgroup_freezer.c

Index: linux-2.6.27-rc1-mm1/include/linux/cgroup_freezer.h
===================================================================

include/linux/cgroup_freezer.h new file +65 -0
@@ -0,0 +1,71 @@
+#ifndef _LINUX_CGROUP_FREEZER_H
+#define _LINUX_CGROUP_FREEZER_H
+/*
+ * cgroup_freezer.h -  control group freezer subsystem interface
+ *
+ * Copyright IBM Corporation, 2007
+ *
+ * Author : Cedric Le Goater <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <linux/cgroup.h>
+
+#ifdef CONFIG_CGROUP_FREEZER
+
+enum freezer_state {
+	STATE_RUNNING = 0,
+	STATE_FREEZING,
+	STATE_FROZEN,
+};
+
+struct freezer {
+	struct cgroup_subsys_state css;
+	enum freezer_state state;
+	spinlock_t lock; /* protects _writes_ to state */
+};
+
+static inline struct freezer *cgroup_freezer(
+		struct cgroup *cgroup)
+{
+	return container_of(
+		cgroup_subsys_state(cgroup, freezer_subsys_id),
+		struct freezer, css);
+}
+
+static inline struct freezer *task_freezer(struct task_struct *task)
+{
+	return container_of(task_subsys_state(task, freezer_subsys_id),
+			    struct freezer, css);
+}
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
+	struct freezer *freezer;
+	enum freezer_state state;
+
+	task_lock(task);
+	freezer = task_freezer(task);
+	state = freezer->state;
+	task_unlock(task);
+
+	return state == STATE_FROZEN;
+}
+
+#else /* !CONFIG_CGROUP_FREEZER */
+
+static inline int cgroup_frozen(struct task_struct *task)
+{
Quoted 8 lines

include/linux/cgroup_freezer.h line 71

Quoted 6 lines
include/linux/cgroup_freezer.h new file +6 -0
+	return 0;
+}
+
+#endif /* !CONFIG_CGROUP_FREEZER */
+
+#endif /* _LINUX_CGROUP_FREEZER_H */

Hmm. I wonder if we really need a separate file for this. I'd prefer it to be in freezer.h, unless there's a good reason not to place it in there.

Quoted 7 lines

Yeah, it's a pretty small header so combining it with another header
would be nice. However if we combine it with freezer.h we'd be including cgroup.h in unrelated filesystem code. An alternative might be to put it into a cgroup header for "small" subsystems (which might just be cgroup.h for now..).

Thanks for the review!

I'm not sure the inline is really useful. In that case, we could probably do something like the following :

include/linux/freezer.h :

	#ifdef CONFIG_CGROUP_FREEZER

	extern int cgroup_frozen(struct task_struct *task);

	#else /* !CONFIG_CGROUP_FREEZER */

	static inline int cgroup_frozen(struct task_struct *task)
	{
		return 0;
	}

	#endif /* !CONFIG_CGROUP_FREEZER */

and in kernel/cgroup_freezer.c:

	int cgroup_frozen(struct task_struct *task)
	{
		struct freezer *freezer;
		enum freezer_state state;

		task_lock(task);
		freezer = task_freezer(task);
		state = freezer->state;
		task_unlock(task);

		return state == STATE_FROZEN;
	}
Quoted 1 line

and kill include/linux/cgroup_freezer.h ?

I'd prefer this.

Thanks,
Rafael