aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-11-15 08:52:29 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-27 12:58:36 -0500
commit3aa5939d71fa22a947808ba9c798b8537c35097a (patch)
treeb127f8c885ade7568c24230d0c9e68a693877eae /tools
parente944d3d7d151eea149c62310eaff7b92c7732f58 (diff)
perf record: Make per-cpu mmaps the default.
This affects the -p, -t and -u options that previously defaulted to per-thread mmaps. Consequently add an option to select per-thread mmaps to support the old behaviour. Note that per-thread can be used with a workload-only (i.e. none of -p, -t, -u, -a or -C is selected) to get a per-thread mmap with no inheritance. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/5286271D.3020808@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-record.txt10
-rw-r--r--tools/perf/builtin-record.c5
-rw-r--r--tools/perf/tests/attr/test-record-no-inherit2
-rw-r--r--tools/perf/util/evlist.c6
-rw-r--r--tools/perf/util/evsel.c5
-rw-r--r--tools/perf/util/target.c11
-rw-r--r--tools/perf/util/target.h4
7 files changed, 29 insertions, 14 deletions
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 43b42c4f4a91..6ac867e7667f 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -201,11 +201,11 @@ abort events and some memory events in precise mode on modern Intel CPUs.
201--transaction:: 201--transaction::
202Record transaction flags for transaction related events. 202Record transaction flags for transaction related events.
203 203
204--force-per-cpu:: 204--per-thread::
205Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p, 205Use per-thread mmaps. By default per-cpu mmaps are created. This option
206-t or -u options) per-thread mmaps are created. This option overrides that and 206overrides that and uses per-thread mmaps. A side-effect of that is that
207forces per-cpu mmaps. A side-effect of that is that inheritance is 207inheritance is automatically disabled. --per-thread is ignored with a warning
208automatically enabled. Add the -i option also to disable inheritance. 208if combined with -a or -C options.
209 209
210SEE ALSO 210SEE ALSO
211-------- 211--------
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7c8020a32784..f5b18b8fe8c9 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -800,6 +800,7 @@ static struct perf_record record = {
800 .freq = 4000, 800 .freq = 4000,
801 .target = { 801 .target = {
802 .uses_mmap = true, 802 .uses_mmap = true,
803 .default_per_cpu = true,
803 }, 804 },
804 }, 805 },
805}; 806};
@@ -888,8 +889,8 @@ const struct option record_options[] = {
888 "sample by weight (on special events only)"), 889 "sample by weight (on special events only)"),
889 OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction, 890 OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
890 "sample transaction flags (special events only)"), 891 "sample transaction flags (special events only)"),
891 OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu, 892 OPT_BOOLEAN(0, "per-thread", &record.opts.target.per_thread,
892 "force the use of per-cpu mmaps"), 893 "use per-thread mmaps"),
893 OPT_END() 894 OPT_END()
894}; 895};
895 896
diff --git a/tools/perf/tests/attr/test-record-no-inherit b/tools/perf/tests/attr/test-record-no-inherit
index 9079a25cd643..44edcb2edcd5 100644
--- a/tools/perf/tests/attr/test-record-no-inherit
+++ b/tools/perf/tests/attr/test-record-no-inherit
@@ -3,5 +3,5 @@ command = record
3args = -i kill >/dev/null 2>&1 3args = -i kill >/dev/null 2>&1
4 4
5[event:base-record] 5[event:base-record]
6sample_type=259 6sample_type=263
7inherit=0 7inherit=0
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index bbc746aa5716..76fa76431329 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -819,8 +819,10 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
819 if (evlist->threads == NULL) 819 if (evlist->threads == NULL)
820 return -1; 820 return -1;
821 821
822 if (target->force_per_cpu) 822 if (target->default_per_cpu)
823 evlist->cpus = cpu_map__new(target->cpu_list); 823 evlist->cpus = target->per_thread ?
824 cpu_map__dummy_new() :
825 cpu_map__new(target->cpu_list);
824 else if (target__has_task(target)) 826 else if (target__has_task(target))
825 evlist->cpus = cpu_map__dummy_new(); 827 evlist->cpus = cpu_map__dummy_new();
826 else if (!target__has_cpu(target) && !target->uses_mmap) 828 else if (!target__has_cpu(target) && !target->uses_mmap)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index dad64926170f..b5fe7f9b2e15 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -574,6 +574,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
574 struct perf_evsel *leader = evsel->leader; 574 struct perf_evsel *leader = evsel->leader;
575 struct perf_event_attr *attr = &evsel->attr; 575 struct perf_event_attr *attr = &evsel->attr;
576 int track = !evsel->idx; /* only the first counter needs these */ 576 int track = !evsel->idx; /* only the first counter needs these */
577 bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread;
577 578
578 attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1; 579 attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
579 attr->inherit = !opts->no_inherit; 580 attr->inherit = !opts->no_inherit;
@@ -647,7 +648,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
647 } 648 }
648 } 649 }
649 650
650 if (target__has_cpu(&opts->target) || opts->target.force_per_cpu) 651 if (target__has_cpu(&opts->target))
651 perf_evsel__set_sample_bit(evsel, CPU); 652 perf_evsel__set_sample_bit(evsel, CPU);
652 653
653 if (opts->period) 654 if (opts->period)
@@ -655,7 +656,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
655 656
656 if (!perf_missing_features.sample_id_all && 657 if (!perf_missing_features.sample_id_all &&
657 (opts->sample_time || !opts->no_inherit || 658 (opts->sample_time || !opts->no_inherit ||
658 target__has_cpu(&opts->target) || opts->target.force_per_cpu)) 659 target__has_cpu(&opts->target) || per_cpu))
659 perf_evsel__set_sample_bit(evsel, TIME); 660 perf_evsel__set_sample_bit(evsel, TIME);
660 661
661 if (opts->raw_samples) { 662 if (opts->raw_samples) {
diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c
index 3c778a07b7cc..e74c5963dc7a 100644
--- a/tools/perf/util/target.c
+++ b/tools/perf/util/target.c
@@ -55,6 +55,13 @@ enum target_errno target__validate(struct target *target)
55 ret = TARGET_ERRNO__UID_OVERRIDE_SYSTEM; 55 ret = TARGET_ERRNO__UID_OVERRIDE_SYSTEM;
56 } 56 }
57 57
58 /* THREAD and SYSTEM/CPU are mutually exclusive */
59 if (target->per_thread && (target->system_wide || target->cpu_list)) {
60 target->per_thread = false;
61 if (ret == TARGET_ERRNO__SUCCESS)
62 ret = TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD;
63 }
64
58 return ret; 65 return ret;
59} 66}
60 67
@@ -100,6 +107,7 @@ static const char *target__error_str[] = {
100 "UID switch overriding CPU", 107 "UID switch overriding CPU",
101 "PID/TID switch overriding SYSTEM", 108 "PID/TID switch overriding SYSTEM",
102 "UID switch overriding SYSTEM", 109 "UID switch overriding SYSTEM",
110 "SYSTEM/CPU switch overriding PER-THREAD",
103 "Invalid User: %s", 111 "Invalid User: %s",
104 "Problems obtaining information for user %s", 112 "Problems obtaining information for user %s",
105}; 113};
@@ -131,7 +139,8 @@ int target__strerror(struct target *target, int errnum,
131 msg = target__error_str[idx]; 139 msg = target__error_str[idx];
132 140
133 switch (errnum) { 141 switch (errnum) {
134 case TARGET_ERRNO__PID_OVERRIDE_CPU ... TARGET_ERRNO__UID_OVERRIDE_SYSTEM: 142 case TARGET_ERRNO__PID_OVERRIDE_CPU ...
143 TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD:
135 snprintf(buf, buflen, "%s", msg); 144 snprintf(buf, buflen, "%s", msg);
136 break; 145 break;
137 146
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index 2d0c50690892..31dd2e9a27d0 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -12,7 +12,8 @@ struct target {
12 uid_t uid; 12 uid_t uid;
13 bool system_wide; 13 bool system_wide;
14 bool uses_mmap; 14 bool uses_mmap;
15 bool force_per_cpu; 15 bool default_per_cpu;
16 bool per_thread;
16}; 17};
17 18
18enum target_errno { 19enum target_errno {
@@ -33,6 +34,7 @@ enum target_errno {
33 TARGET_ERRNO__UID_OVERRIDE_CPU, 34 TARGET_ERRNO__UID_OVERRIDE_CPU,
34 TARGET_ERRNO__PID_OVERRIDE_SYSTEM, 35 TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
35 TARGET_ERRNO__UID_OVERRIDE_SYSTEM, 36 TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
37 TARGET_ERRNO__SYSTEM_OVERRIDE_THREAD,
36 38
37 /* for target__parse_uid() */ 39 /* for target__parse_uid() */
38 TARGET_ERRNO__INVALID_UID, 40 TARGET_ERRNO__INVALID_UID,