]> git.baikalelectronics.ru Git - kernel.git/commit
perf: Add cgroup support
authorStephane Eranian <eranian@google.com>
Mon, 14 Feb 2011 09:20:01 +0000 (11:20 +0200)
committerIngo Molnar <mingo@elte.hu>
Wed, 16 Feb 2011 12:30:48 +0000 (13:30 +0100)
commit3cbf766a40775fa13a4e42df40399ca62da5b517
tree5862b4cddb7c88e0513e503cb3f46c60da2eeb6f
parentcc65bd7867c43e45a3b632381fa0ed163f4cd6ec
perf: Add cgroup support

This kernel patch adds the ability to filter monitoring based on
container groups (cgroups). This is for use in per-cpu mode only.

The cgroup to monitor is passed as a file descriptor in the pid
argument to the syscall. The file descriptor must be opened to
the cgroup name in the cgroup filesystem. For instance, if the
cgroup name is foo and cgroupfs is mounted in /cgroup, then the
file descriptor is opened to /cgroup/foo. Cgroup mode is
activated by passing PERF_FLAG_PID_CGROUP in the flags argument
to the syscall.

For instance to measure in cgroup foo on CPU1 assuming
cgroupfs is mounted under /cgroup:

struct perf_event_attr attr;
int cgroup_fd, fd;

cgroup_fd = open("/cgroup/foo", O_RDONLY);
fd = perf_event_open(&attr, cgroup_fd, 1, -1, PERF_FLAG_PID_CGROUP);
close(cgroup_fd);

Signed-off-by: Stephane Eranian <eranian@google.com>
[ added perf_cgroup_{exit,attach} ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <4d590250.114ddf0a.689e.4482@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/cgroup.h
include/linux/cgroup_subsys.h
include/linux/perf_event.h
init/Kconfig
kernel/cgroup.c
kernel/perf_event.c