container freezer: implement freezer cgroup subsystem
This patch implements a new freezer subsystem in the control groups framework. It provides a way to stop and resume execution of all tasks in a cgroup by writing in the cgroup filesystem. The freezer subsystem in the container filesystem defines a file named freezer.state. Writing "FROZEN" to the state file will freeze all tasks in the cgroup. Subsequently writing "RUNNING" will unfreeze the tasks in the cgroup. Reading will return the current state. * Examples of usage : # mkdir /containers/freezer # mount -t cgroup -ofreezer freezer /containers # mkdir /containers/0 # echo $some_pid > /containers/0/tasks to get status of the freezer subsystem : # cat /containers/0/freezer.state RUNNING to freeze all tasks in the container : # echo FROZEN > /containers/0/freezer.state # cat /containers/0/freezer.state FREEZING # cat /containers/0/freezer.state FROZEN to unfreeze all tasks in the container : # echo RUNNING > /containers/0/freezer.state # cat /containers/0/freezer.state RUNNING This is the basic mechanism which should do the right thing for user space task in a simple scenario. It's important to note that freezing can be incomplete. In that case we return EBUSY. This means that some tasks in the cgroup are busy doing something that prevents us from completely freezing the cgroup at this time. After EBUSY, the cgroup will remain partially frozen -- reflected by freezer.state reporting "FREEZING" when read. The state will remain "FREEZING" until one of these things happens: 1) Userspace cancels the freezing operation by writing "RUNNING" to the freezer.state file 2) Userspace retries the freezing operation by writing "FROZEN" to the freezer.state file (writing "FREEZING" is not legal and returns EIO) 3) The tasks that blocked the cgroup from entering the "FROZEN" state disappear from the cgroup's set of tasks. [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: export thaw_process] Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Matt Helsley <matthltc@us.ibm.com> Acked-by: Serge E. Hallyn <serue@us.ibm.com> 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>
This commit is contained in:
committed by
Linus Torvalds
parent
8174f1503f
commit
dc52ddc0e6
@@ -70,6 +70,7 @@ config AUTO_IRQ_AFFINITY
|
||||
default y
|
||||
|
||||
source "init/Kconfig"
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
|
||||
menu "System setup"
|
||||
|
@@ -192,6 +192,8 @@ config VECTORS_BASE
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "System Type"
|
||||
|
||||
choice
|
||||
|
@@ -72,6 +72,8 @@ config GENERIC_BUG
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "System Type and features"
|
||||
|
||||
source "kernel/time/Kconfig"
|
||||
|
@@ -64,8 +64,11 @@ config HARDWARE_PM
|
||||
depends on OPROFILE
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.preempt"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Blackfin Processor Options"
|
||||
|
||||
comment "Processor and Board Settings"
|
||||
|
@@ -62,6 +62,8 @@ config HZ
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "General setup"
|
||||
|
||||
source "fs/Kconfig.binfmt"
|
||||
|
@@ -66,6 +66,8 @@ mainmenu "Fujitsu FR-V Kernel Configuration"
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
|
||||
menu "Fujitsu FR-V system setup"
|
||||
|
||||
|
@@ -90,6 +90,8 @@ config HZ
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
source "arch/h8300/Kconfig.cpu"
|
||||
|
||||
menu "Executable file formats"
|
||||
|
@@ -7,6 +7,8 @@ mainmenu "IA-64 Linux Kernel Configuration"
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
config IA64
|
||||
|
@@ -42,6 +42,8 @@ config HZ
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
|
@@ -62,6 +62,8 @@ mainmenu "Linux/68k Kernel Configuration"
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Platform dependent setup"
|
||||
|
||||
config EISA
|
||||
|
@@ -75,6 +75,8 @@ config NO_IOPORT
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
choice
|
||||
|
@@ -1885,6 +1885,8 @@ config PROBE_INITRD_HEADER
|
||||
add initrd or initramfs image to the kernel image.
|
||||
Otherwise, say N.
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Bus options (PCI, PCMCIA, EISA, ISA, TC)"
|
||||
|
||||
config HW_HAS_EISA
|
||||
|
@@ -68,6 +68,8 @@ mainmenu "Matsushita MN10300/AM33 Kernel Configuration"
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
|
||||
menu "Matsushita MN10300 system setup"
|
||||
|
||||
|
@@ -90,6 +90,8 @@ config ARCH_MAY_HAVE_PC_FDC
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
|
@@ -230,6 +230,8 @@ config PPC_OF_PLATFORM_PCI
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
source "arch/powerpc/sysdev/Kconfig"
|
||||
source "arch/powerpc/platforms/Kconfig"
|
||||
|
||||
|
@@ -78,6 +78,8 @@ config S390
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Base setup"
|
||||
|
||||
comment "Processor type and features"
|
||||
|
@@ -106,6 +106,8 @@ config IO_TRAPPED
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "System type"
|
||||
|
||||
#
|
||||
|
@@ -37,6 +37,8 @@ config HZ
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "General machine setup"
|
||||
|
||||
config SMP
|
||||
|
@@ -96,6 +96,7 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
|
||||
def_bool y
|
||||
|
||||
source "init/Kconfig"
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
|
@@ -229,6 +229,8 @@ endmenu
|
||||
|
||||
source "init/Kconfig"
|
||||
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
source "drivers/block/Kconfig"
|
||||
|
||||
source "arch/um/Kconfig.char"
|
||||
|
@@ -193,6 +193,7 @@ config X86_TRAMPOLINE
|
||||
config KTIME_SCALAR
|
||||
def_bool X86_32
|
||||
source "init/Kconfig"
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
|
@@ -55,6 +55,7 @@ config HZ
|
||||
default 100
|
||||
|
||||
source "init/Kconfig"
|
||||
source "kernel/Kconfig.freezer"
|
||||
|
||||
menu "Processor type and features"
|
||||
|
||||
|
Reference in New Issue
Block a user