Merge pull request #306 from hqhq/hq_join_perfevent_systemd

Systemd: Join perf_event cgroup
This commit is contained in:
Alexander Morozov 2015-10-01 10:05:35 -07:00
commit 0954faba13
1 changed files with 14 additions and 0 deletions

View File

@ -236,6 +236,10 @@ func (m *Manager) Apply(pid int) error {
if err := joinHugetlb(c, pid); err != nil {
return err
}
if err := joinPerfEvent(c, pid); err != nil {
return err
}
// FIXME: Systemd does have `BlockIODeviceWeight` property, but we got problem
// using that (at least on systemd 208, see https://github.com/opencontainers/runc/libcontainer/pull/354),
// so use fs work around for now.
@ -585,3 +589,13 @@ func joinHugetlb(c *configs.Cgroup, pid int) error {
hugetlb := subsystems["hugetlb"]
return hugetlb.Set(path, c)
}
func joinPerfEvent(c *configs.Cgroup, pid int) error {
path, err := join(c, "perf_event", pid)
if err != nil && !cgroups.IsNotFound(err) {
return err
}
perfEvent := subsystems["perf_event"]
return perfEvent.Set(path, c)
}