aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2011-02-14 04:20:01 -0500
committerIngo Molnar <mingo@elte.hu>2011-02-16 07:30:48 -0500
commit023695d96ee06f36cf5014e286edcd623e9fb847 (patch)
treeff7483b7a1aa0cfd5de95475ed059822d2a35499 /tools/perf/builtin-record.c
parente5d1367f17ba6a6fed5fd8b74e4d5720923e0c25 (diff)
perf tool: Add cgroup support
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> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <4d590290.825bdf0a.7d0a.4890@mx.google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 12e0e41696d9..a4aaadcb4c8b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -807,6 +807,9 @@ const struct option record_options[] = {
807 "do not update the buildid cache"), 807 "do not update the buildid cache"),
808 OPT_BOOLEAN('B', "no-buildid", &no_buildid, 808 OPT_BOOLEAN('B', "no-buildid", &no_buildid,
809 "do not collect buildids in perf.data"), 809 "do not collect buildids in perf.data"),
810 OPT_CALLBACK('G', "cgroup", &evsel_list, "name",
811 "monitor event in cgroup name only",
812 parse_cgroups),
810 OPT_END() 813 OPT_END()
811}; 814};
812 815
@@ -835,6 +838,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
835 write_mode = WRITE_FORCE; 838 write_mode = WRITE_FORCE;
836 } 839 }
837 840
841 if (nr_cgroups && !system_wide) {
842 fprintf(stderr, "cgroup monitoring only available in"
843 " system-wide mode\n");
844 usage_with_options(record_usage, record_options);
845 }
846
838 symbol__init(); 847 symbol__init();
839 848
840 if (no_buildid_cache || no_buildid) 849 if (no_buildid_cache || no_buildid)