{"action":"created","issue":{"url":"https://api.github.com/repos/opencontainers/runc/issues/608","repository_url":"https://api.github.com/repos/opencontainers/runc","labels_url":"https://api.github.com/repos/opencontainers/runc/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/opencontainers/runc/issues/608/comments","events_url":"https://api.github.com/repos/opencontainers/runc/issues/608/events","html_url":"https://github.com/opencontainers/runc/pull/608","id":137817548,"number":608,"title":"Eliminate redundant parsing of mountinfo","user":{"login":"inatatsu","id":9817764,"avatar_url":"https://avatars.githubusercontent.com/u/9817764?v=3","gravatar_id":"","url":"https://api.github.com/users/inatatsu","html_url":"https://github.com/inatatsu","followers_url":"https://api.github.com/users/inatatsu/followers","following_url":"https://api.github.com/users/inatatsu/following{/other_user}","gists_url":"https://api.github.com/users/inatatsu/gists{/gist_id}","starred_url":"https://api.github.com/users/inatatsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inatatsu/subscriptions","organizations_url":"https://api.github.com/users/inatatsu/orgs","repos_url":"https://api.github.com/users/inatatsu/repos","events_url":"https://api.github.com/users/inatatsu/events{/privacy}","received_events_url":"https://api.github.com/users/inatatsu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/opencontainers/runc/labels/status/0-triage","name":"status/0-triage","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-02T09:17:03Z","updated_at":"2016-03-25T12:37:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/opencontainers/runc/pulls/608","html_url":"https://github.com/opencontainers/runc/pull/608","diff_url":"https://github.com/opencontainers/runc/pull/608.diff","patch_url":"https://github.com/opencontainers/runc/pull/608.patch"},"body":"Fixes #631 (and the corresponding issue docker/docker#20851). The solutions here are:\r\n\r\n1. Skip parsing of `mountinfo` in [FindCgroupMountpoint()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L22) and [FindCgroupMountpointAndRoot()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L49) when a given cgroup subsystem is not enabled. The check is done by testing the subsystem is included in a result of [ParseCgroupFile()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L246).\r\n2. Break the parsing loop in [FindCgroupMountpointDir()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L73) when all the cgroup subsystems are found.\r\n3. Skip parsing of `mountinfo` in [getSelinuxMountPoint()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/selinux/selinux.go#L55) when the mount point is found, instead of invoking [mount.GetMounts()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/selinux/selinux.go#L61).\r\n4. Postpone parsing `mountinfo` by invoking [rootfsParentMountPrivate()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/rootfs_linux.go#L507) and [getParentMount()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/rootfs_linux.go#L475) until `pivot_root()` actually fails."},"comment":{"url":"https://api.github.com/repos/opencontainers/runc/issues/comments/201265441","html_url":"https://github.com/opencontainers/runc/pull/608#issuecomment-201265441","issue_url":"https://api.github.com/repos/opencontainers/runc/issues/608","id":201265441,"user":{"login":"rhatdan","id":2000835,"avatar_url":"https://avatars.githubusercontent.com/u/2000835?v=3","gravatar_id":"","url":"https://api.github.com/users/rhatdan","html_url":"https://github.com/rhatdan","followers_url":"https://api.github.com/users/rhatdan/followers","following_url":"https://api.github.com/users/rhatdan/following{/other_user}","gists_url":"https://api.github.com/users/rhatdan/gists{/gist_id}","starred_url":"https://api.github.com/users/rhatdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhatdan/subscriptions","organizations_url":"https://api.github.com/users/rhatdan/orgs","repos_url":"https://api.github.com/users/rhatdan/repos","events_url":"https://api.github.com/users/rhatdan/events{/privacy}","received_events_url":"https://api.github.com/users/rhatdan/received_events","type":"User","site_admin":false},"created_at":"2016-03-25T12:37:07Z","updated_at":"2016-03-25T12:37:07Z","body":"Looking at the code, this will only be called once.  selinuxfs=unknown to start, First call gets set to \"\", then if it is in SELInux mode it will get set to the path.  All future calls will return \"\" or SELINUXFSPATH.  And never call this code."}}