diff options
author | Alexey Budankov <alexey.budankov@linux.intel.com> | 2019-01-22 12:47:43 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-06 08:00:39 -0500 |
commit | 9d2ed64587c045304efe8872b0258c30803d370c (patch) | |
tree | 719b794d0f9b543636b4bdef56d13516c2936d38 | |
parent | 159b0da50adb021fe452d849fb73b408f21de3f8 (diff) |
perf record: Allocate affinity masks
Allocate affinity option and masks for mmap data buffers and record
thread as well as initialize allocated objects.
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/526fa2b0-07de-6dbd-a7e9-26ba875593c9@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 13 | ||||
-rw-r--r-- | tools/perf/perf.h | 8 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 | ||||
-rw-r--r-- | tools/perf/util/mmap.c | 2 | ||||
-rw-r--r-- | tools/perf/util/mmap.h | 3 |
6 files changed, 28 insertions, 6 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 56e9d9e8c174..7ced5f3e8100 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -81,12 +81,17 @@ struct record { | |||
81 | bool timestamp_boundary; | 81 | bool timestamp_boundary; |
82 | struct switch_output switch_output; | 82 | struct switch_output switch_output; |
83 | unsigned long long samples; | 83 | unsigned long long samples; |
84 | cpu_set_t affinity_mask; | ||
84 | }; | 85 | }; |
85 | 86 | ||
86 | static volatile int auxtrace_record__snapshot_started; | 87 | static volatile int auxtrace_record__snapshot_started; |
87 | static DEFINE_TRIGGER(auxtrace_snapshot_trigger); | 88 | static DEFINE_TRIGGER(auxtrace_snapshot_trigger); |
88 | static DEFINE_TRIGGER(switch_output_trigger); | 89 | static DEFINE_TRIGGER(switch_output_trigger); |
89 | 90 | ||
91 | static const char *affinity_tags[PERF_AFFINITY_MAX] = { | ||
92 | "SYS", "NODE", "CPU" | ||
93 | }; | ||
94 | |||
90 | static bool switch_output_signal(struct record *rec) | 95 | static bool switch_output_signal(struct record *rec) |
91 | { | 96 | { |
92 | return rec->switch_output.signal && | 97 | return rec->switch_output.signal && |
@@ -533,7 +538,8 @@ static int record__mmap_evlist(struct record *rec, | |||
533 | 538 | ||
534 | if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, | 539 | if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, |
535 | opts->auxtrace_mmap_pages, | 540 | opts->auxtrace_mmap_pages, |
536 | opts->auxtrace_snapshot_mode, opts->nr_cblocks) < 0) { | 541 | opts->auxtrace_snapshot_mode, |
542 | opts->nr_cblocks, opts->affinity) < 0) { | ||
537 | if (errno == EPERM) { | 543 | if (errno == EPERM) { |
538 | pr_err("Permission error mapping pages.\n" | 544 | pr_err("Permission error mapping pages.\n" |
539 | "Consider increasing " | 545 | "Consider increasing " |
@@ -1977,6 +1983,9 @@ int cmd_record(int argc, const char **argv) | |||
1977 | # undef REASON | 1983 | # undef REASON |
1978 | #endif | 1984 | #endif |
1979 | 1985 | ||
1986 | CPU_ZERO(&rec->affinity_mask); | ||
1987 | rec->opts.affinity = PERF_AFFINITY_SYS; | ||
1988 | |||
1980 | rec->evlist = perf_evlist__new(); | 1989 | rec->evlist = perf_evlist__new(); |
1981 | if (rec->evlist == NULL) | 1990 | if (rec->evlist == NULL) |
1982 | return -ENOMEM; | 1991 | return -ENOMEM; |
@@ -2140,6 +2149,8 @@ int cmd_record(int argc, const char **argv) | |||
2140 | if (verbose > 0) | 2149 | if (verbose > 0) |
2141 | pr_info("nr_cblocks: %d\n", rec->opts.nr_cblocks); | 2150 | pr_info("nr_cblocks: %d\n", rec->opts.nr_cblocks); |
2142 | 2151 | ||
2152 | pr_debug("affinity: %s\n", affinity_tags[rec->opts.affinity]); | ||
2153 | |||
2143 | err = __cmd_record(&record, argc, argv); | 2154 | err = __cmd_record(&record, argc, argv); |
2144 | out: | 2155 | out: |
2145 | perf_evlist__delete(rec->evlist); | 2156 | perf_evlist__delete(rec->evlist); |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 5941fb6eccfc..b120e547ddc7 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
@@ -84,6 +84,14 @@ struct record_opts { | |||
84 | clockid_t clockid; | 84 | clockid_t clockid; |
85 | u64 clockid_res_ns; | 85 | u64 clockid_res_ns; |
86 | int nr_cblocks; | 86 | int nr_cblocks; |
87 | int affinity; | ||
88 | }; | ||
89 | |||
90 | enum perf_affinity { | ||
91 | PERF_AFFINITY_SYS = 0, | ||
92 | PERF_AFFINITY_NODE, | ||
93 | PERF_AFFINITY_CPU, | ||
94 | PERF_AFFINITY_MAX | ||
87 | }; | 95 | }; |
88 | 96 | ||
89 | struct option; | 97 | struct option; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 8c902276d4b4..08cedb643ea6 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -1022,7 +1022,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str, | |||
1022 | */ | 1022 | */ |
1023 | int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, | 1023 | int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, |
1024 | unsigned int auxtrace_pages, | 1024 | unsigned int auxtrace_pages, |
1025 | bool auxtrace_overwrite, int nr_cblocks) | 1025 | bool auxtrace_overwrite, int nr_cblocks, int affinity) |
1026 | { | 1026 | { |
1027 | struct perf_evsel *evsel; | 1027 | struct perf_evsel *evsel; |
1028 | const struct cpu_map *cpus = evlist->cpus; | 1028 | const struct cpu_map *cpus = evlist->cpus; |
@@ -1032,7 +1032,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, | |||
1032 | * Its value is decided by evsel's write_backward. | 1032 | * Its value is decided by evsel's write_backward. |
1033 | * So &mp should not be passed through const pointer. | 1033 | * So &mp should not be passed through const pointer. |
1034 | */ | 1034 | */ |
1035 | struct mmap_params mp = { .nr_cblocks = nr_cblocks }; | 1035 | struct mmap_params mp = { .nr_cblocks = nr_cblocks, .affinity = affinity }; |
1036 | 1036 | ||
1037 | if (!evlist->mmap) | 1037 | if (!evlist->mmap) |
1038 | evlist->mmap = perf_evlist__alloc_mmap(evlist, false); | 1038 | evlist->mmap = perf_evlist__alloc_mmap(evlist, false); |
@@ -1064,7 +1064,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, | |||
1064 | 1064 | ||
1065 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages) | 1065 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages) |
1066 | { | 1066 | { |
1067 | return perf_evlist__mmap_ex(evlist, pages, 0, false, 0); | 1067 | return perf_evlist__mmap_ex(evlist, pages, 0, false, 0, PERF_AFFINITY_SYS); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) | 1070 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 00ab43c6dd15..744906dd4887 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -165,7 +165,7 @@ unsigned long perf_event_mlock_kb_in_pages(void); | |||
165 | 165 | ||
166 | int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, | 166 | int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, |
167 | unsigned int auxtrace_pages, | 167 | unsigned int auxtrace_pages, |
168 | bool auxtrace_overwrite, int nr_cblocks); | 168 | bool auxtrace_overwrite, int nr_cblocks, int affinity); |
169 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages); | 169 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages); |
170 | void perf_evlist__munmap(struct perf_evlist *evlist); | 170 | void perf_evlist__munmap(struct perf_evlist *evlist); |
171 | 171 | ||
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 8fc39311a30d..e68ba754a8e2 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c | |||
@@ -343,6 +343,8 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int c | |||
343 | map->fd = fd; | 343 | map->fd = fd; |
344 | map->cpu = cpu; | 344 | map->cpu = cpu; |
345 | 345 | ||
346 | CPU_ZERO(&map->affinity_mask); | ||
347 | |||
346 | if (auxtrace_mmap__mmap(&map->auxtrace_mmap, | 348 | if (auxtrace_mmap__mmap(&map->auxtrace_mmap, |
347 | &mp->auxtrace_mp, map->base, fd)) | 349 | &mp->auxtrace_mp, map->base, fd)) |
348 | return -1; | 350 | return -1; |
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index aeb6942fdb00..e566c19b242b 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h | |||
@@ -38,6 +38,7 @@ struct perf_mmap { | |||
38 | int nr_cblocks; | 38 | int nr_cblocks; |
39 | } aio; | 39 | } aio; |
40 | #endif | 40 | #endif |
41 | cpu_set_t affinity_mask; | ||
41 | }; | 42 | }; |
42 | 43 | ||
43 | /* | 44 | /* |
@@ -69,7 +70,7 @@ enum bkw_mmap_state { | |||
69 | }; | 70 | }; |
70 | 71 | ||
71 | struct mmap_params { | 72 | struct mmap_params { |
72 | int prot, mask, nr_cblocks; | 73 | int prot, mask, nr_cblocks, affinity; |
73 | struct auxtrace_mmap_params auxtrace_mp; | 74 | struct auxtrace_mmap_params auxtrace_mp; |
74 | }; | 75 | }; |
75 | 76 | ||