Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

container freezer: add TIF_FREEZE flag to all architectures

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

This patch:

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.

[akpm@linux-foundation.org: fix sparc]
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
Acked-by: Pavel Machek <pavel@suse.cz>
Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Nigel Cunningham <nigel@tuxonice.net>
Tested-by: Matt Helsley <matthltc@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matt Helsley and committed by
Linus Torvalds
83224b08 5e9a0f02

+22
+2
arch/alpha/include/asm/thread_info.h
··· 74 74 #define TIF_UAC_SIGBUS 7 75 75 #define TIF_MEMDIE 8 76 76 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */ 77 + #define TIF_FREEZE 16 /* is freezing for suspend */ 77 78 78 79 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 79 80 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 80 81 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 81 82 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 82 83 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 84 + #define _TIF_FREEZE (1<<TIF_FREEZE) 83 85 84 86 /* Work to do on interrupt/exception return. */ 85 87 #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
+1
arch/avr32/include/asm/thread_info.h
··· 96 96 #define _TIF_MEMDIE (1 << TIF_MEMDIE) 97 97 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 98 98 #define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) 99 + #define _TIF_FREEZE (1 << TIF_FREEZE) 99 100 100 101 /* Note: The masks below must never span more than 16 bits! */ 101 102
+2
arch/h8300/include/asm/thread_info.h
··· 89 89 TIF_NEED_RESCHED */ 90 90 #define TIF_MEMDIE 4 91 91 #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */ 92 + #define TIF_FREEZE 16 /* is freezing for suspend */ 92 93 93 94 /* as above, but as bit values */ 94 95 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) ··· 97 96 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 98 97 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 99 98 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 99 + #define _TIF_FREEZE (1<<TIF_FREEZE) 100 100 101 101 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 102 102
+2
arch/m68knommu/include/asm/thread_info.h
··· 84 84 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling 85 85 TIF_NEED_RESCHED */ 86 86 #define TIF_MEMDIE 4 87 + #define TIF_FREEZE 16 /* is freezing for suspend */ 87 88 88 89 /* as above, but as bit values */ 89 90 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 90 91 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 91 92 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 92 93 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 94 + #define _TIF_FREEZE (1<<TIF_FREEZE) 93 95 94 96 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 95 97
+2
arch/s390/include/asm/thread_info.h
··· 99 99 #define TIF_31BIT 18 /* 32bit process */ 100 100 #define TIF_MEMDIE 19 101 101 #define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */ 102 + #define TIF_FREEZE 21 /* thread is freezing for suspend */ 102 103 103 104 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 104 105 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) ··· 113 112 #define _TIF_USEDFPU (1<<TIF_USEDFPU) 114 113 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 115 114 #define _TIF_31BIT (1<<TIF_31BIT) 115 + #define _TIF_FREEZE (1<<TIF_FREEZE) 116 116 117 117 #endif /* __KERNEL__ */ 118 118
+2
arch/sparc/include/asm/thread_info_32.h
··· 135 135 #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling 136 136 * TIF_NEED_RESCHED */ 137 137 #define TIF_MEMDIE 10 138 + #define TIF_FREEZE 11 /* is freezing for suspend */ 138 139 139 140 /* as above, but as bit values */ 140 141 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) ··· 149 148 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \ 150 149 _TIF_SIGPENDING | \ 151 150 _TIF_RESTORE_SIGMASK) 151 + #define _TIF_FREEZE (1<<TIF_FREEZE) 152 152 153 153 #endif /* __KERNEL__ */ 154 154
+2
arch/sparc/include/asm/thread_info_64.h
··· 237 237 #define TIF_ABI_PENDING 12 238 238 #define TIF_MEMDIE 13 239 239 #define TIF_POLLING_NRFLAG 14 240 + #define TIF_FREEZE 15 /* is freezing for suspend */ 240 241 241 242 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 242 243 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) ··· 250 249 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 251 250 #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 252 251 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 252 + #define _TIF_FREEZE (1<<TIF_FREEZE) 253 253 254 254 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \ 255 255 _TIF_DO_NOTIFY_RESUME_MASK | \
+2
include/asm-cris/thread_info.h
··· 88 88 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ 89 89 #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 90 90 #define TIF_MEMDIE 17 91 + #define TIF_FREEZE 18 /* is freezing for suspend */ 91 92 92 93 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 93 94 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) ··· 96 95 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 97 96 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 98 97 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 98 + #define _TIF_FREEZE (1<<TIF_FREEZE) 99 99 100 100 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 101 101 #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
+1
include/asm-m68k/thread_info.h
··· 52 52 #define TIF_DELAYED_TRACE 14 /* single step a syscall */ 53 53 #define TIF_SYSCALL_TRACE 15 /* syscall trace active */ 54 54 #define TIF_MEMDIE 16 55 + #define TIF_FREEZE 17 /* thread is freezing for suspend */ 55 56 56 57 #endif /* _ASM_M68K_THREAD_INFO_H */
+2
include/asm-parisc/thread_info.h
··· 58 58 #define TIF_32BIT 4 /* 32 bit binary */ 59 59 #define TIF_MEMDIE 5 60 60 #define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */ 61 + #define TIF_FREEZE 7 /* is freezing for suspend */ 61 62 62 63 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 63 64 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) ··· 66 65 #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 67 66 #define _TIF_32BIT (1 << TIF_32BIT) 68 67 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 68 + #define _TIF_FREEZE (1 << TIF_FREEZE) 69 69 70 70 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | \ 71 71 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
+2
include/asm-um/thread_info.h
··· 69 69 #define TIF_MEMDIE 5 70 70 #define TIF_SYSCALL_AUDIT 6 71 71 #define TIF_RESTORE_SIGMASK 7 72 + #define TIF_FREEZE 16 /* is freezing for suspend */ 72 73 73 74 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 74 75 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) ··· 78 77 #define _TIF_MEMDIE (1 << TIF_MEMDIE) 79 78 #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 80 79 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 80 + #define _TIF_FREEZE (1 << TIF_FREEZE) 81 81 82 82 #endif
+2
include/asm-xtensa/thread_info.h
··· 134 134 #define TIF_MEMDIE 5 135 135 #define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 136 136 #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 137 + #define TIF_FREEZE 17 /* is freezing for suspend */ 137 138 138 139 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 139 140 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) ··· 143 142 #define _TIF_IRET (1<<TIF_IRET) 144 143 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 145 144 #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 145 + #define _TIF_FREEZE (1<<TIF_FREEZE) 146 146 147 147 #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 148 148 #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */