From 6a5ba1109cde9103a77fc628b31c51d888797d16 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 29 Sep 2015 15:42:29 +0800 Subject: [PATCH] Systemd: Join perf_event cgroup Signed-off-by: Qiang Huang --- libcontainer/cgroups/systemd/apply_systemd.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libcontainer/cgroups/systemd/apply_systemd.go b/libcontainer/cgroups/systemd/apply_systemd.go index 7b523da9..205aca21 100644 --- a/libcontainer/cgroups/systemd/apply_systemd.go +++ b/libcontainer/cgroups/systemd/apply_systemd.go @@ -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) +}