[PATCH 5/5] perf_events: add cgroup support to perf tool (v7)

Previous thread: [PATCH 3/5] perf_events: add perf_event_time() (v7) by Stephane Eranian on Monday, January 3, 2011 - 9:20 am. (1 message)

Next thread: [GIT PULL] perf callchain fixlet by Frederic Weisbecker on Monday, January 3, 2011 - 10:45 am. (1 message)
From: Stephane Eranian
Date: Monday, January 3, 2011 - 9:20 am

This patch adds the ability to filter monitoring based on container groups
(cgroups) for both perf stat and perf record. It is possible to monitor
multiple cgroup in parallel. There is one cgroup per event. The cgroups to
monitor are passed via a new -G option followed by a comma separated list of
cgroup names.

The cgroup filesystem has to be mounted. Given a cgroup name, the perf tool
finds the corresponding directory in the cgroup filesystem and opens it. It
then passes that file descriptor to the kernel.

Example:
$ perf stat -B -a -e cycles:u,cycles:u,cycles:u -G test1,,test2 -- sleep 1
 Performance counter stats for 'sleep 1':

      2,368,667,414  cycles                   test1
      2,369,661,459  cycles                  
      <not counted>  cycles                   test2

        1.001856890  seconds time elapsed

Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 52462ae..2ddd13b 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -134,6 +134,14 @@ Do not update the builid cache. This saves some overhead in situations
 where the information in the perf.data file (which includes buildids)
 is sufficient.
 
+-G name,...::
+--cgroup name,...::
+monitor only in the container (cgroup) called "name". This option is available only
+in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
+container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
+can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
+to first event, second cgroup to second event and so on.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index b6da7af..a72251a 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ ...
Previous thread: [PATCH 3/5] perf_events: add perf_event_time() (v7) by Stephane Eranian on Monday, January 3, 2011 - 9:20 am. (1 message)

Next thread: [GIT PULL] perf callchain fixlet by Frederic Weisbecker on Monday, January 3, 2011 - 10:45 am. (1 message)