{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/79246685","id":79246685,"diff_hunk":"@@ -51,6 +53,8 @@ func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {\n \tflags.Uint16Var(&opts.blkioWeight, \"blkio-weight\", 0, \"Block IO (relative weight), between 10 and 1000\")\n \tflags.Int64Var(&opts.cpuPeriod, \"cpu-period\", 0, \"Limit CPU CFS (Completely Fair Scheduler) period\")\n \tflags.Int64Var(&opts.cpuQuota, \"cpu-quota\", 0, \"Limit CPU CFS (Completely Fair Scheduler) quota\")\n+\tflags.Int64Var(&opts.cpuRtPeriod, \"cpu-rt-period\", 0, \"Limit the CPU real-time period\")","path":"cli/command/container/update.go","position":13,"original_position":13,"commit_id":"c140fe9b96febab47a92efb8575d7feb0766da76","original_commit_id":"c140fe9b96febab47a92efb8575d7feb0766da76","user":{"login":"stevvooe","id":120601,"avatar_url":"https://avatars.githubusercontent.com/u/120601?v=3","gravatar_id":"","url":"https://api.github.com/users/stevvooe","html_url":"https://github.com/stevvooe","followers_url":"https://api.github.com/users/stevvooe/followers","following_url":"https://api.github.com/users/stevvooe/following{/other_user}","gists_url":"https://api.github.com/users/stevvooe/gists{/gist_id}","starred_url":"https://api.github.com/users/stevvooe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevvooe/subscriptions","organizations_url":"https://api.github.com/users/stevvooe/orgs","repos_url":"https://api.github.com/users/stevvooe/repos","events_url":"https://api.github.com/users/stevvooe/events{/privacy}","received_events_url":"https://api.github.com/users/stevvooe/received_events","type":"User","site_admin":false},"body":"What are the units of these flags?","created_at":"2016-09-16T20:37:17Z","updated_at":"2016-09-16T20:37:21Z","html_url":"https://github.com/docker/docker/pull/23430#discussion_r79246685","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/23430","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/79246685"},"html":{"href":"https://github.com/docker/docker/pull/23430#discussion_r79246685"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/23430"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/23430","id":73370632,"html_url":"https://github.com/docker/docker/pull/23430","diff_url":"https://github.com/docker/docker/pull/23430.diff","patch_url":"https://github.com/docker/docker/pull/23430.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/23430","number":23430,"state":"open","locked":false,"title":"Implementing support for --cpu-rt-period and --cpu-rt-runtime","user":{"login":"erikstmartin","id":50041,"avatar_url":"https://avatars.githubusercontent.com/u/50041?v=3","gravatar_id":"","url":"https://api.github.com/users/erikstmartin","html_url":"https://github.com/erikstmartin","followers_url":"https://api.github.com/users/erikstmartin/followers","following_url":"https://api.github.com/users/erikstmartin/following{/other_user}","gists_url":"https://api.github.com/users/erikstmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/erikstmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikstmartin/subscriptions","organizations_url":"https://api.github.com/users/erikstmartin/orgs","repos_url":"https://api.github.com/users/erikstmartin/repos","events_url":"https://api.github.com/users/erikstmartin/events{/privacy}","received_events_url":"https://api.github.com/users/erikstmartin/received_events","type":"User","site_admin":false},"body":"**- What I did**\r\nAdded support for two new flags `--cpu-rt-period` and `--cpu-rt-runtime` combined with either the `--privileged` flag or `--cap-add=sys_nice` this allows processes within a container to prioritize themselves as real-time when `CONFIG_RT_GROUP_SCHED` is enabled in the kernel. See #22380. When this option is enabled each docker container's cgroup has to have `cpu.rt_runtime_us` set in order for the container to be able to prioritize its threads.\r\n\r\n**- How I did it**\r\n\r\nSupport for changing the cgroup value already existed in runc, I updated all the necessary container configs to pass these values down to runc. I also implemented some sanity checks in the daemon.\r\n\r\n**- How to verify it**\r\nEnsure `CONFIG_RT_GROUP_SCHED` is enabled in the kernel (standard CentOS 7 install has this enabled). You can verify it's enabled by running\r\n```zcat /proc/config.gz | grep CONFIG_RT_GROUP_SCHED``` or by checking for the existence of `/sys/fs/cgroup/cpu.rt_runtime_us`\r\n\r\nYou will also need to ensure that the system and all parent cgroups have values set for the period and runtime as this limits what the children can be set to. If you're familiar with these values you can set them appropriately, sane defaults would be `rt_period_us = 1000000` and `rt_runtime_us = 950000`, they only need to be set once on the system.\r\n\r\n```\r\nsysctl kernel.sched_rt_period_us\r\nsysctl kernel.sched_rt_runtime_us\r\n\r\ncat /sys/fs/cgroup/cpu.rt_period_us\r\ncat /sys/fs/cgroup/cpu.rt_runtime_us\r\n\r\ncat /sys/fs/cgroup/docker/cpu.rt_period_us\r\ncat /sys/fs/cgroup/docker/cpu.rt_runtime_us\r\n```\r\n\r\n**Update:** You can now set the values for the parent cgroups with a new set of daemon flags. The system value will still need to be set using sysctl.\r\n`docker daemon --cpu-rt-runtime=950000`\r\n\r\nNow you have a system you can test on. To validate this works start a container with the new flags (we'll add a ulimit just to test that works as expected too)\r\n\r\n`docker run --it --cpu-rt-runtime=95000 --ulimit rtprio=99 --cap-add=sys_nice debian:jessie`\r\n\r\nIf you receive an error like this, it's because your parent cgroups dont have `rt_runtime_us` set, or it's a lower value than you're trying to set for your container. Also ensure they are set for your container `/sys/fs/cgroup/docker/<container id>/cpu.rt_runtime_us` (after the container has been started). if you're testing this inside a container.\r\n```\r\ndocker: Error response from daemon: oci runtime error: process_linux.go:286: setting cgroup config for ready process caused \"failed to write 950000 to cpu.rt_runtime_us: write /sys/fs/cgroup/cpu,cpuacct/docker/5024d2730a83e86efd9042ea99972d582c66830f4a3aa21c747d1c25c824eb75/cpu.rt_runtime_us: invalid argument\".\r\n```\r\n\r\nOnce inside the container you can attempt to change the priority of your shell\r\n`chrt -r -p 99 1`\r\n\r\nThen validate by calling\r\n`chrt -p 1`\r\n\r\n```\r\nroot@c1d2f4b7d579:/# chrt -r -p 99 1\r\nroot@c1d2f4b7d579:/# chrt -p 1\r\npid 1's current scheduling policy: SCHED_RR\r\npid 1's current scheduling priority: 99\r\n```\r\n\r\nYou can also test the following error conditions.\r\n- Passing either flag without having the `sys_nice` capability or being `privileged` results in error (no point setting your runtime if you dont have permission to change your priority)\r\n- Passing either flag on a host with the kernel option disabled results in error\r\n- Passing a runtime greater than the period results in an error\r\n\r\n**- Description for the changelog**\r\nSupport for --cpu-rt-period and --cpu-rt-runtime flags, allowing containers to run real-time threads when CONFIG_RT_GROUP_SCHED is enabled in the kernel.\r\n\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n\r\n![Picture of Gopher](https://lh3.googleusercontent.com/-dPJphRXYIU0/TWuMDPIv5qI/AAAAAAAABJY/d9-H_bACph4/s1600/gopher2.jpg)\r\n","created_at":"2016-06-10T13:07:38Z","updated_at":"2016-09-16T20:37:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c6da53012f0962469470f4f1142d19defce2cbb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/23430/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/23430/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/23430/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/c140fe9b96febab47a92efb8575d7feb0766da76","head":{"label":"erikstmartin:realtime-threads","ref":"realtime-threads","sha":"c140fe9b96febab47a92efb8575d7feb0766da76","user":{"login":"erikstmartin","id":50041,"avatar_url":"https://avatars.githubusercontent.com/u/50041?v=3","gravatar_id":"","url":"https://api.github.com/users/erikstmartin","html_url":"https://github.com/erikstmartin","followers_url":"https://api.github.com/users/erikstmartin/followers","following_url":"https://api.github.com/users/erikstmartin/following{/other_user}","gists_url":"https://api.github.com/users/erikstmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/erikstmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikstmartin/subscriptions","organizations_url":"https://api.github.com/users/erikstmartin/orgs","repos_url":"https://api.github.com/users/erikstmartin/repos","events_url":"https://api.github.com/users/erikstmartin/events{/privacy}","received_events_url":"https://api.github.com/users/erikstmartin/received_events","type":"User","site_admin":false},"repo":{"id":60630554,"name":"docker","full_name":"erikstmartin/docker","owner":{"login":"erikstmartin","id":50041,"avatar_url":"https://avatars.githubusercontent.com/u/50041?v=3","gravatar_id":"","url":"https://api.github.com/users/erikstmartin","html_url":"https://github.com/erikstmartin","followers_url":"https://api.github.com/users/erikstmartin/followers","following_url":"https://api.github.com/users/erikstmartin/following{/other_user}","gists_url":"https://api.github.com/users/erikstmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/erikstmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikstmartin/subscriptions","organizations_url":"https://api.github.com/users/erikstmartin/orgs","repos_url":"https://api.github.com/users/erikstmartin/repos","events_url":"https://api.github.com/users/erikstmartin/events{/privacy}","received_events_url":"https://api.github.com/users/erikstmartin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erikstmartin/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/erikstmartin/docker","forks_url":"https://api.github.com/repos/erikstmartin/docker/forks","keys_url":"https://api.github.com/repos/erikstmartin/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erikstmartin/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erikstmartin/docker/teams","hooks_url":"https://api.github.com/repos/erikstmartin/docker/hooks","issue_events_url":"https://api.github.com/repos/erikstmartin/docker/issues/events{/number}","events_url":"https://api.github.com/repos/erikstmartin/docker/events","assignees_url":"https://api.github.com/repos/erikstmartin/docker/assignees{/user}","branches_url":"https://api.github.com/repos/erikstmartin/docker/branches{/branch}","tags_url":"https://api.github.com/repos/erikstmartin/docker/tags","blobs_url":"https://api.github.com/repos/erikstmartin/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erikstmartin/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erikstmartin/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/erikstmartin/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erikstmartin/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/erikstmartin/docker/languages","stargazers_url":"https://api.github.com/repos/erikstmartin/docker/stargazers","contributors_url":"https://api.github.com/repos/erikstmartin/docker/contributors","subscribers_url":"https://api.github.com/repos/erikstmartin/docker/subscribers","subscription_url":"https://api.github.com/repos/erikstmartin/docker/subscription","commits_url":"https://api.github.com/repos/erikstmartin/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/erikstmartin/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/erikstmartin/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/erikstmartin/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/erikstmartin/docker/contents/{+path}","compare_url":"https://api.github.com/repos/erikstmartin/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erikstmartin/docker/merges","archive_url":"https://api.github.com/repos/erikstmartin/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erikstmartin/docker/downloads","issues_url":"https://api.github.com/repos/erikstmartin/docker/issues{/number}","pulls_url":"https://api.github.com/repos/erikstmartin/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/erikstmartin/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/erikstmartin/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erikstmartin/docker/labels{/name}","releases_url":"https://api.github.com/repos/erikstmartin/docker/releases{/id}","deployments_url":"https://api.github.com/repos/erikstmartin/docker/deployments","created_at":"2016-06-07T16:52:20Z","updated_at":"2016-06-07T16:52:33Z","pushed_at":"2016-09-16T13:33:01Z","git_url":"git://github.com/erikstmartin/docker.git","ssh_url":"git@github.com:erikstmartin/docker.git","clone_url":"https://github.com/erikstmartin/docker.git","svn_url":"https://github.com/erikstmartin/docker","homepage":"http://www.docker.com","size":101604,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"76ee0e8185d4219bd8539ca8f33d387376422ef4","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-09-16T20:27:32Z","pushed_at":"2016-09-16T20:21:10Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":209631,"stargazers_count":35026,"watchers_count":35026,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10300,"mirror_url":null,"open_issues_count":2026,"forks":10300,"open_issues":2026,"watchers":35026,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/23430"},"html":{"href":"https://github.com/docker/docker/pull/23430"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/23430"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/23430/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/23430/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/23430/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/c140fe9b96febab47a92efb8575d7feb0766da76"}}}}
{"actor":{"display_login":"stevvooe"}}