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

perf cpumap: Synthetic events and const/static

Make the cpumap arguments const to make it clearer they are in rather
than out arguments. Make two functions static and remove external
declarations.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Colin Ian King <colin.king@intel.com>
Cc: Dave Marchevsky <davemarchevsky@fb.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kees Kook <keescook@chromium.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20220614143353.1559597-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
35ae6f09 e989bc3d

+12 -14
-4
tools/perf/util/event.h
··· 463 463 int kallsyms__get_function_start(const char *kallsyms_filename, 464 464 const char *symbol_name, u64 *addr); 465 465 466 - void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max); 467 - void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map, 468 - u16 type, int max); 469 - 470 466 void event_attr_init(struct perf_event_attr *attr); 471 467 472 468 int perf_event_paranoid(void);
+11 -9
tools/perf/util/synthetic-events.c
··· 1185 1185 } 1186 1186 1187 1187 static void synthesize_cpus(struct cpu_map_entries *cpus, 1188 - struct perf_cpu_map *map) 1188 + const struct perf_cpu_map *map) 1189 1189 { 1190 1190 int i, map_nr = perf_cpu_map__nr(map); 1191 1191 ··· 1196 1196 } 1197 1197 1198 1198 static void synthesize_mask(struct perf_record_record_cpu_map *mask, 1199 - struct perf_cpu_map *map, int max) 1199 + const struct perf_cpu_map *map, int max) 1200 1200 { 1201 1201 int i; 1202 1202 ··· 1207 1207 set_bit(perf_cpu_map__cpu(map, i).cpu, mask->mask); 1208 1208 } 1209 1209 1210 - static size_t cpus_size(struct perf_cpu_map *map) 1210 + static size_t cpus_size(const struct perf_cpu_map *map) 1211 1211 { 1212 1212 return sizeof(struct cpu_map_entries) + perf_cpu_map__nr(map) * sizeof(u16); 1213 1213 } 1214 1214 1215 - static size_t mask_size(struct perf_cpu_map *map, int *max) 1215 + static size_t mask_size(const struct perf_cpu_map *map, int *max) 1216 1216 { 1217 1217 int i; 1218 1218 ··· 1229 1229 return sizeof(struct perf_record_record_cpu_map) + BITS_TO_LONGS(*max) * sizeof(long); 1230 1230 } 1231 1231 1232 - void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max) 1232 + static void *cpu_map_data__alloc(const struct perf_cpu_map *map, size_t *size, 1233 + u16 *type, int *max) 1233 1234 { 1234 1235 size_t size_cpus, size_mask; 1235 1236 bool is_dummy = perf_cpu_map__empty(map); ··· 1264 1263 return zalloc(*size); 1265 1264 } 1266 1265 1267 - void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map, 1268 - u16 type, int max) 1266 + static void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, 1267 + const struct perf_cpu_map *map, 1268 + u16 type, int max) 1269 1269 { 1270 1270 data->type = type; 1271 1271 ··· 1281 1279 } 1282 1280 } 1283 1281 1284 - static struct perf_record_cpu_map *cpu_map_event__new(struct perf_cpu_map *map) 1282 + static struct perf_record_cpu_map *cpu_map_event__new(const struct perf_cpu_map *map) 1285 1283 { 1286 1284 size_t size = sizeof(struct perf_record_cpu_map); 1287 1285 struct perf_record_cpu_map *event; ··· 1301 1299 } 1302 1300 1303 1301 int perf_event__synthesize_cpu_map(struct perf_tool *tool, 1304 - struct perf_cpu_map *map, 1302 + const struct perf_cpu_map *map, 1305 1303 perf_event__handler_t process, 1306 1304 struct machine *machine) 1307 1305 {
+1 -1
tools/perf/util/synthetic-events.h
··· 46 46 int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process); 47 47 int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process); 48 48 int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine); 49 - int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); 49 + int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); 50 50 int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process); 51 51 int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process); 52 52 int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);