From 42ef78911e4266648b0314e2458b59b3219275ac Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Tue, 7 Jun 2016 15:05:43 -0400 Subject: [PATCH] Implementing support for --cpu-rt-period and --cpu-rt-runtime so that containers may specify these cgroup values at runtime. This will allow processes to change their priority to real-time within the container when CONFIG_RT_GROUP_SCHED is enabled in the kernel. See #22380. Also added sanity checks for the new --cpu-rt-runtime and --cpu-rt-period flags to ensure that that the kernel supports these features and that runtime is not greater than period. Daemon will support a --cpu-rt-runtime flag to initialize the parent cgroup on startup, this prevents the administrator from alotting runtime to docker after each restart. There are additional checks that could be added but maybe too far? Check parent cgroups to ensure values are <= parent, inspecting rtprio ulimit and issuing a warning. Signed-off-by: Erik St. Martin --- contrib/completion/bash/docker | 4 ++++ contrib/completion/zsh/_docker | 2 ++ docs/reference/commandline/create.md | 2 ++ docs/reference/commandline/run.md | 2 ++ docs/reference/commandline/update.md | 2 ++ docs/reference/run.md | 2 ++ man/docker-create.1.md | 17 +++++++++++++++++ man/docker-run.1.md | 15 +++++++++++++++ man/docker-update.1.md | 17 +++++++++++++++++ 9 files changed, 63 insertions(+) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index e76be9b785..129d5c5b14 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1316,6 +1316,8 @@ _docker_container_run() { --cidfile --cpu-period --cpu-quota + --cpu-rt-period + --cpu-rt-runtime --cpuset-cpus --cpuset-mems --cpu-shares -c @@ -1667,6 +1669,8 @@ _docker_container_update() { --blkio-weight --cpu-period --cpu-quota + --cpu-rt-period + --cpu-rt-runtime --cpuset-cpus --cpuset-mems --cpu-shares -c diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 2a61fbe504..5c6f26e729 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -1433,6 +1433,8 @@ __docker_subcommand() { "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " + "($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: " + "($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: " "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " diff --git a/docs/reference/commandline/create.md b/docs/reference/commandline/create.md index 91c5f30ff5..784b4940e1 100644 --- a/docs/reference/commandline/create.md +++ b/docs/reference/commandline/create.md @@ -35,6 +35,8 @@ Options: --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota -c, --cpu-shares int CPU shares (relative weight) + --cpu-rt-period int Limit the CPU real-time period in microseconds + --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) --device value Add a host device to the container (default []) diff --git a/docs/reference/commandline/run.md b/docs/reference/commandline/run.md index 2a35ebc8c5..ec6a412009 100644 --- a/docs/reference/commandline/run.md +++ b/docs/reference/commandline/run.md @@ -33,6 +33,8 @@ Options: --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota -c, --cpu-shares int CPU shares (relative weight) + --cpu-rt-period int Limit the CPU real-time period in microseconds + --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) -d, --detach Run container in background and print container ID diff --git a/docs/reference/commandline/update.md b/docs/reference/commandline/update.md index 1a6a2690ba..9ba7993bf7 100644 --- a/docs/reference/commandline/update.md +++ b/docs/reference/commandline/update.md @@ -25,6 +25,8 @@ Options: --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota -c, --cpu-shares int CPU shares (relative weight) + --cpu-rt-period int Limit the CPU real-time period in microseconds + --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) --help Print usage diff --git a/docs/reference/run.md b/docs/reference/run.md index 24c695e24d..a48b44d4bf 100644 --- a/docs/reference/run.md +++ b/docs/reference/run.md @@ -690,6 +690,8 @@ container: | `--cpuset-cpus=""` | CPUs in which to allow execution (0-3, 0,1) | | `--cpuset-mems=""` | Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. | | `--cpu-quota=0` | Limit the CPU CFS (Completely Fair Scheduler) quota | +| `--cpu-rt-period=0` | Limit the CPU real-time period. In microseconds. Requires parent cgroups be set and cannot be higher than parent. Also check rtprio ulimits. | +| `--cpu-rt-runtime=0` | Limit the CPU real-time runtime. In microseconds. Requires parent cgroups be set and cannot be higher than parent. Also check rtprio ulimits. | | `--blkio-weight=0` | Block IO weight (relative weight) accepts a weight value between 10 and 1000. | | `--blkio-weight-device=""` | Block IO weight (relative device weight, format: `DEVICE_NAME:WEIGHT`) | | `--device-read-bps=""` | Limit read rate from a device (format: `:[]`). Number is a positive integer. Unit can be one of `kb`, `mb`, or `gb`. | diff --git a/man/docker-create.1.md b/man/docker-create.1.md index ece8a91f5f..08e8665903 100644 --- a/man/docker-create.1.md +++ b/man/docker-create.1.md @@ -17,6 +17,8 @@ docker-create - Create a new container [**--cidfile**[=*CIDFILE*]] [**--cpu-period**[=*0*]] [**--cpu-quota**[=*0*]] +[**--cpu-rt-period**[=*0*]] +[**--cpu-rt-runtime**[=*0*]] [**--cpuset-cpus**[=*CPUSET-CPUS*]] [**--cpuset-mems**[=*CPUSET-MEMS*]] [**--device**[=*[]*]] @@ -123,6 +125,8 @@ The initial status of the container created with **docker create** is 'created'. **--cpu-period**=*0* Limit the CPU CFS (Completely Fair Scheduler) period + Limit the container's CPU usage. This flag tell the kernel to restrict the container's CPU usage to the period you specify. + **--cpuset-cpus**="" CPUs in which to allow execution (0-3, 0,1) @@ -136,6 +140,19 @@ two memory nodes. **--cpu-quota**=*0* Limit the CPU CFS (Completely Fair Scheduler) quota +**--cpu-rt-period**=0 + Limit the CPU real-time period in microseconds + + Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. + +**--cpu-rt-runtime**=0 + Limit the CPU real-time runtime in microseconds + + Limit the containers Real Time CPU usage. This flag tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: + Period of 1,000,000us and Runtime of 950,000us means that this container could consume 95% of available CPU and leave the remaining 5% to normal priority tasks. + + The sum of all runtimes across containers cannot exceed the amount alotted to the parent cgroup. + **--device**=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) diff --git a/man/docker-run.1.md b/man/docker-run.1.md index a18bae469e..8cbd26242c 100644 --- a/man/docker-run.1.md +++ b/man/docker-run.1.md @@ -17,6 +17,8 @@ docker-run - Run a command in a new container [**--cidfile**[=*CIDFILE*]] [**--cpu-period**[=*0*]] [**--cpu-quota**[=*0*]] +[**--cpu-rt-period**[=*0*]] +[**--cpu-rt-runtime**[=*0*]] [**--cpuset-cpus**[=*CPUSET-CPUS*]] [**--cpuset-mems**[=*CPUSET-MEMS*]] [**-d**|**--detach**] @@ -192,6 +194,19 @@ two memory nodes. CPU resource. This flag tell the kernel to restrict the container's CPU usage to the quota you specify. +**--cpu-rt-period**=0 + Limit the CPU real-time period in microseconds + + Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. + +**--cpu-rt-runtime**=0 + Limit the CPU real-time runtime in microseconds + + Limit the containers Real Time CPU usage. This flag tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: + Period of 1,000,000us and Runtime of 950,000us means that this container could consume 95% of available CPU and leave the remaining 5% to normal priority tasks. + + The sum of all runtimes across containers cannot exceed the amount alotted to the parent cgroup. + **-d**, **--detach**=*true*|*false* Detached mode: run the container in the background and print the new container ID. The default is *false*. diff --git a/man/docker-update.1.md b/man/docker-update.1.md index 71fb6e476a..7ae7099344 100644 --- a/man/docker-update.1.md +++ b/man/docker-update.1.md @@ -10,6 +10,8 @@ docker-update - Update configuration of one or more containers [**--cpu-shares**[=*0*]] [**--cpu-period**[=*0*]] [**--cpu-quota**[=*0*]] +[**--cpu-rt-period**[=*0*]] +[**--cpu-rt-runtime**[=*0*]] [**--cpuset-cpus**[=*CPUSET-CPUS*]] [**--cpuset-mems**[=*CPUSET-MEMS*]] [**--help**] @@ -44,9 +46,24 @@ a running container with kernel memory initialized. **--cpu-period**=0 Limit the CPU CFS (Completely Fair Scheduler) period + Limit the container's CPU usage. This flag tell the kernel to restrict the container's CPU usage to the period you specify. + **--cpu-quota**=0 Limit the CPU CFS (Completely Fair Scheduler) quota +**--cpu-rt-period**=0 + Limit the CPU real-time period in microseconds + + Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. + +**--cpu-rt-runtime**=0 + Limit the CPU real-time runtime in microseconds + + Limit the containers Real Time CPU usage. This flag tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: + Period of 1,000,000us and Runtime of 950,000us means that this container could consume 95% of available CPU and leave the remaining 5% to normal priority tasks. + + The sum of all runtimes across containers cannot exceed the amount alotted to the parent cgroup. + **--cpuset-cpus**="" CPUs in which to allow execution (0-3, 0,1)