Container Freezer: Reuse Suspend Freezer
Subsystems (6)
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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__ */
PATCH 1/6 Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Matt HelsleyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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__ */
PATCH 2/6 Container Freezer: Make refrigerator always available
In reply to Matt HelsleyNow 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
@@ -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
@@ -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 --
PATCH 2/6 Container Freezer: Make refrigerator always available
In reply to Matt HelsleyNow 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
@@ -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
@@ -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 --
PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem
In reply to Matt HelsleyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem
In reply to Matt HelsleyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume
In reply to Matt HelsleyWhen 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
@@ -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 --
PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume
In reply to Matt HelsleyWhen 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
@@ -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 --
PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing
In reply to Matt HelsleyDon'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
@@ -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 cgrouunsigned 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);
PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing
In reply to Matt HelsleyDon'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
@@ -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 cgrouunsigned 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);
PATCH 6/6 Container Freezer: Use cgroup write_string method
In reply to Matt HelsleyUse 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
@@ -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 cgrostatic 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) {
PATCH 6/6 Container Freezer: Use cgroup write_string method
In reply to Matt HelsleyUse 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
@@ -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 cgrostatic 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) {
PATCH 4/6 Container Freezer: Skip frozen cgroups during power management resume
In reply to Matt HelsleyWhen 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
@@ -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 --
PATCH 3/6 Container Freezer: Implement freezer cgroup subsystem
In reply to Matt HelsleyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 6/6 Container Freezer: Use cgroup write_string method
In reply to Matt HelsleyUse 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
@@ -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 cgrostatic 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) {
PATCH 1/6 Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Matt HelsleyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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__ */
PATCH 2/6 Container Freezer: Make refrigerator always available
In reply to Matt HelsleyNow 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
@@ -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
@@ -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 --
PATCH 5/6 Container Freezer: Prevent frozen tasks or cgroups from changing
In reply to Matt HelsleyDon'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
@@ -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 cgrouunsigned 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);
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
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
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
Nigel Cunningham
Acked-byRe: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume
In reply to a message not in the archiveHi.
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.
Signed-off-by Cedric Le Goater <clg-NmTC/[email protected]>Signed-off-by Matt Helsley <matthltc-r/[email protected]>
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@@ -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
Re: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume
In reply to Matt HelsleyHi.
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.
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>
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@@ -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
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to a message not in the archiveHi.
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
Signed-off-by Cedric Le Goater <clg-NmTC/[email protected]>Signed-off-by Matt Helsley <matthltc-r/[email protected]>Acked-by Pavel Machek <[email protected]>--- 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 0x4000000Index:
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__ */
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Matt HelsleyHi.
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
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Pavel Machek <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>--- 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 0x4000000Index:
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__ */
Nigel Cunningham
Acked-byRe: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to a message not in the archiveHi.
Quoted 11 lines · Matt Helsley
Now that the
TIF_FREEZEflag is available in all architectures, extract therefrigerator()andfreeze_task()fromkernel/power/process.cand make it available to all.The
refrigerator()can now be used in a control group subsystem implementing a control group freezer.Signed-off-by Cedric Le Goater <clg-NmTC/[email protected]>Signed-off-by Matt Helsley <matthltc-r/[email protected]>
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Matt HelsleyHi.
Quoted 11 lines · Matt Helsley
Now that the
TIF_FREEZEflag is available in all architectures, extract therefrigerator()andfreeze_task()fromkernel/power/process.cand make it available to all.The
refrigerator()can now be used in a control group subsystem implementing a control group freezer.Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>
Re: [PATCH 4/6] Container Freezer: Skip frozen cgroups during power management resume
In reply to Matt HelsleyHi.
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.
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>
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@@ -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
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Matt HelsleyHi.
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
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Pavel Machek <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>--- 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 0x4000000Index:
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__ */
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Matt HelsleyHi.
Quoted 11 lines · Matt Helsley
Now that the
TIF_FREEZEflag is available in all architectures, extract therefrigerator()andfreeze_task()fromkernel/power/process.cand make it available to all.The
refrigerator()can now be used in a control group subsystem implementing a control group freezer.Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Nigel CunninghamQuoted 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
Signed-off-by Cedric Le Goater <clg-NmTC/[email protected]>Signed-off-by Matt Helsley <matthltc-r/[email protected]>Acked-by Pavel Machek <[email protected]>--- 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 0x4000000Index:
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__ */
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Nigel CunninghamQuoted 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
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Pavel Machek <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>--- 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 0x4000000Index:
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__ */
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Nigel CunninghamQuoted 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
Signed-off-by Cedric Le Goater <[email protected]>Signed-off-by Matt Helsley <[email protected]>Acked-by Pavel Machek <[email protected]>Acked-by Serge E. Hallyn <[email protected]>Tested-by Matt Helsley <[email protected]>--- 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 0x4000000Index:
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__ */
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
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
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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to a message not in the archiveHi,
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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Matt HelsleyHi,
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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Matt HelsleyHi,
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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Thomas PetazzoniOn 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.
---
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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Thomas PetazzoniQuoted 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.cwas compiled only ifCONFIG_PM_SLEEPwas set. Now that the code has been moved tokernel/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_SOMETHINGoption, 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
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Thomas PetazzoniQuoted 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.cwas compiled only ifCONFIG_PM_SLEEPwas set. Now that the code has been moved tokernel/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_SOMETHINGoption, 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
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to a message not in the archiveQuoted 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -89,6 +89,7 @@ static inline struct thread_info *currenTIF_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Cedric Le GoaterQuoted 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -89,6 +89,7 @@ static inline struct thread_info *currenTIF_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
Re: [PATCH 1/6] Container Freezer: Add TIF_FREEZE flag to all architectures
In reply to Cedric Le GoaterQuoted 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -89,6 +89,7 @@ static inline struct thread_info *currenTIF_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
Re: [PATCH 2/6] Container Freezer: Make refrigerator always available
In reply to Matt HelsleyOn 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 @@ configPM_SLEEP> depends on SUSPEND || HIBERNATION ||XEN_SAVE_RESTORE> default y> > +-config FREEZER> +-def_boolPM_SLEEP||CGROUP_FREEZER> +-> config SUSPEND> bool "Suspend to RAM and standby"> depends on PM &&ARCH_SUSPEND_POSSIBLE> > > > >