Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexey Budankov and committed by
Arnaldo Carvalho de Melo
9d2ed645 159b0da5

+28 -6
+12 -1
tools/perf/builtin-record.c
··· 81 81 bool timestamp_boundary; 82 82 struct switch_output switch_output; 83 83 unsigned long long samples; 84 + cpu_set_t affinity_mask; 84 85 }; 85 86 86 87 static volatile int auxtrace_record__snapshot_started; 87 88 static DEFINE_TRIGGER(auxtrace_snapshot_trigger); 88 89 static DEFINE_TRIGGER(switch_output_trigger); 90 + 91 + static const char *affinity_tags[PERF_AFFINITY_MAX] = { 92 + "SYS", "NODE", "CPU" 93 + }; 89 94 90 95 static bool switch_output_signal(struct record *rec) 91 96 { ··· 538 533 539 534 if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, 540 535 opts->auxtrace_mmap_pages, 541 - opts->auxtrace_snapshot_mode, opts->nr_cblocks) < 0) { 536 + opts->auxtrace_snapshot_mode, 537 + opts->nr_cblocks, opts->affinity) < 0) { 542 538 if (errno == EPERM) { 543 539 pr_err("Permission error mapping pages.\n" 544 540 "Consider increasing " ··· 1983 1977 # undef REASON 1984 1978 #endif 1985 1979 1980 + CPU_ZERO(&rec->affinity_mask); 1981 + rec->opts.affinity = PERF_AFFINITY_SYS; 1982 + 1986 1983 rec->evlist = perf_evlist__new(); 1987 1984 if (rec->evlist == NULL) 1988 1985 return -ENOMEM; ··· 2148 2139 rec->opts.nr_cblocks = nr_cblocks_max; 2149 2140 if (verbose > 0) 2150 2141 pr_info("nr_cblocks: %d\n", rec->opts.nr_cblocks); 2142 + 2143 + pr_debug("affinity: %s\n", affinity_tags[rec->opts.affinity]); 2151 2144 2152 2145 err = __cmd_record(&record, argc, argv); 2153 2146 out:
+8
tools/perf/perf.h
··· 84 84 clockid_t clockid; 85 85 u64 clockid_res_ns; 86 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 97 struct option;
+3 -3
tools/perf/util/evlist.c
··· 1022 1022 */ 1023 1023 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, 1024 1024 unsigned int auxtrace_pages, 1025 - bool auxtrace_overwrite, int nr_cblocks) 1025 + bool auxtrace_overwrite, int nr_cblocks, int affinity) 1026 1026 { 1027 1027 struct perf_evsel *evsel; 1028 1028 const struct cpu_map *cpus = evlist->cpus; ··· 1032 1032 * Its value is decided by evsel's write_backward. 1033 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 1037 if (!evlist->mmap) 1038 1038 evlist->mmap = perf_evlist__alloc_mmap(evlist, false); ··· 1064 1064 1065 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 1070 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
+1 -1
tools/perf/util/evlist.h
··· 165 165 166 166 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, 167 167 unsigned int auxtrace_pages, 168 - bool auxtrace_overwrite, int nr_cblocks); 168 + bool auxtrace_overwrite, int nr_cblocks, int affinity); 169 169 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages); 170 170 void perf_evlist__munmap(struct perf_evlist *evlist); 171 171
+2
tools/perf/util/mmap.c
··· 343 343 map->fd = fd; 344 344 map->cpu = cpu; 345 345 346 + CPU_ZERO(&map->affinity_mask); 347 + 346 348 if (auxtrace_mmap__mmap(&map->auxtrace_mmap, 347 349 &mp->auxtrace_mp, map->base, fd)) 348 350 return -1;
+2 -1
tools/perf/util/mmap.h
··· 38 38 int nr_cblocks; 39 39 } aio; 40 40 #endif 41 + cpu_set_t affinity_mask; 41 42 }; 42 43 43 44 /* ··· 70 69 }; 71 70 72 71 struct mmap_params { 73 - int prot, mask, nr_cblocks; 72 + int prot, mask, nr_cblocks, affinity; 74 73 struct auxtrace_mmap_params auxtrace_mp; 75 74 }; 76 75