Lines Matching +full:data +full:- +full:path

1 // SPDX-License-Identifier: GPL-2.0
27 const struct perf_record_cpu_map_data *data) in perf_record_cpu_map_data__test_bit() argument
34 return (data->mask32_data.long_size == 4) in perf_record_cpu_map_data__test_bit()
35 ? (bit_word32 < data->mask32_data.nr) && in perf_record_cpu_map_data__test_bit()
36 (data->mask32_data.mask[bit_word32] & bit_mask32) != 0 in perf_record_cpu_map_data__test_bit()
37 : (bit_word64 < data->mask64_data.nr) && in perf_record_cpu_map_data__test_bit()
38 (data->mask64_data.mask[bit_word64] & bit_mask64) != 0; in perf_record_cpu_map_data__test_bit()
41 /* Read ith mask value from data into the given 64-bit sized bitmap */
42 static void perf_record_cpu_map_data__read_one_mask(const struct perf_record_cpu_map_data *data, in perf_record_cpu_map_data__read_one_mask() argument
46 if (data->mask32_data.long_size == 4) in perf_record_cpu_map_data__read_one_mask()
47 bitmap[0] = data->mask32_data.mask[i]; in perf_record_cpu_map_data__read_one_mask()
49 bitmap[0] = data->mask64_data.mask[i]; in perf_record_cpu_map_data__read_one_mask()
51 if (data->mask32_data.long_size == 4) { in perf_record_cpu_map_data__read_one_mask()
52 bitmap[0] = data->mask32_data.mask[i]; in perf_record_cpu_map_data__read_one_mask()
56 bitmap[0] = (unsigned long)(data->mask64_data.mask[i] >> 32); in perf_record_cpu_map_data__read_one_mask()
57 bitmap[1] = (unsigned long)data->mask64_data.mask[i]; in perf_record_cpu_map_data__read_one_mask()
59 bitmap[0] = (unsigned long)data->mask64_data.mask[i]; in perf_record_cpu_map_data__read_one_mask()
60 bitmap[1] = (unsigned long)(data->mask64_data.mask[i] >> 32); in perf_record_cpu_map_data__read_one_mask()
65 static struct perf_cpu_map *cpu_map__from_entries(const struct perf_record_cpu_map_data *data) in cpu_map__from_entries() argument
69 map = perf_cpu_map__empty_new(data->cpus_data.nr); in cpu_map__from_entries()
73 for (i = 0; i < data->cpus_data.nr; i++) { in cpu_map__from_entries()
75 * Special treatment for -1, which is not real cpu number, in cpu_map__from_entries()
76 * and we need to use (int) -1 to initialize map[i], in cpu_map__from_entries()
79 if (data->cpus_data.cpu[i] == (u16) -1) in cpu_map__from_entries()
80 RC_CHK_ACCESS(map)->map[i].cpu = -1; in cpu_map__from_entries()
82 RC_CHK_ACCESS(map)->map[i].cpu = (int) data->cpus_data.cpu[i]; in cpu_map__from_entries()
89 static struct perf_cpu_map *cpu_map__from_mask(const struct perf_record_cpu_map_data *data) in cpu_map__from_mask() argument
92 int weight = 0, mask_nr = data->mask32_data.nr; in cpu_map__from_mask()
96 perf_record_cpu_map_data__read_one_mask(data, i, local_copy); in cpu_map__from_mask()
105 int cpus_per_i = (i * data->mask32_data.long_size * BITS_PER_BYTE); in cpu_map__from_mask()
108 perf_record_cpu_map_data__read_one_mask(data, i, local_copy); in cpu_map__from_mask()
110 RC_CHK_ACCESS(map)->map[j++].cpu = cpu + cpus_per_i; in cpu_map__from_mask()
116 static struct perf_cpu_map *cpu_map__from_range(const struct perf_record_cpu_map_data *data) in cpu_map__from_range() argument
121 map = perf_cpu_map__empty_new(data->range_cpu_data.end_cpu - in cpu_map__from_range()
122 data->range_cpu_data.start_cpu + 1 + data->range_cpu_data.any_cpu); in cpu_map__from_range()
126 if (data->range_cpu_data.any_cpu) in cpu_map__from_range()
127 RC_CHK_ACCESS(map)->map[i++].cpu = -1; in cpu_map__from_range()
129 for (int cpu = data->range_cpu_data.start_cpu; cpu <= data->range_cpu_data.end_cpu; in cpu_map__from_range()
131 RC_CHK_ACCESS(map)->map[i].cpu = cpu; in cpu_map__from_range()
136 struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *data) in cpu_map__new_data() argument
138 switch (data->type) { in cpu_map__new_data()
140 return cpu_map__from_entries(data); in cpu_map__new_data()
142 return cpu_map__from_mask(data); in cpu_map__new_data()
144 return cpu_map__from_range(data); in cpu_map__new_data()
146 pr_err("cpu_map__new_data unknown type %d\n", data->type); in cpu_map__new_data()
167 RC_CHK_ACCESS(cpus)->map[i].cpu = -1; in perf_cpu_map__empty_new()
180 cpus->nr = nr; in cpu_aggr_map__empty_new()
182 cpus->map[i] = aggr_cpu_id__empty(); in cpu_aggr_map__empty_new()
190 char path[PATH_MAX]; in cpu__get_topology_int() local
192 snprintf(path, PATH_MAX, in cpu__get_topology_int()
195 return sysfs__read_int(path, value); in cpu__get_topology_int()
204 struct aggr_cpu_id aggr_cpu_id__socket(struct perf_cpu cpu, void *data __maybe_unused) in aggr_cpu_id__socket()
217 if (a->node != b->node) in aggr_cpu_id__cmp()
218 return a->node - b->node; in aggr_cpu_id__cmp()
219 else if (a->socket != b->socket) in aggr_cpu_id__cmp()
220 return a->socket - b->socket; in aggr_cpu_id__cmp()
221 else if (a->die != b->die) in aggr_cpu_id__cmp()
222 return a->die - b->die; in aggr_cpu_id__cmp()
223 else if (a->cluster != b->cluster) in aggr_cpu_id__cmp()
224 return a->cluster - b->cluster; in aggr_cpu_id__cmp()
225 else if (a->cache_lvl != b->cache_lvl) in aggr_cpu_id__cmp()
226 return a->cache_lvl - b->cache_lvl; in aggr_cpu_id__cmp()
227 else if (a->cache != b->cache) in aggr_cpu_id__cmp()
228 return a->cache - b->cache; in aggr_cpu_id__cmp()
229 else if (a->core != b->core) in aggr_cpu_id__cmp()
230 return a->core - b->core; in aggr_cpu_id__cmp()
232 return a->thread_idx - b->thread_idx; in aggr_cpu_id__cmp()
237 void *data, bool needs_sort) in cpu_aggr_map__new() argument
247 c->nr = 0; in cpu_aggr_map__new()
251 struct aggr_cpu_id cpu_id = get_id(cpu, data); in cpu_aggr_map__new()
253 for (int j = 0; j < c->nr; j++) { in cpu_aggr_map__new()
254 if (aggr_cpu_id__equal(&cpu_id, &c->map[j])) { in cpu_aggr_map__new()
260 c->map[c->nr] = cpu_id; in cpu_aggr_map__new()
261 c->nr++; in cpu_aggr_map__new()
265 if (c->nr != perf_cpu_map__nr(cpus)) { in cpu_aggr_map__new()
268 sizeof(struct cpu_aggr_map) + sizeof(struct aggr_cpu_id) * c->nr); in cpu_aggr_map__new()
276 qsort(c->map, c->nr, sizeof(struct aggr_cpu_id), aggr_cpu_id__cmp); in cpu_aggr_map__new()
289 struct aggr_cpu_id aggr_cpu_id__die(struct perf_cpu cpu, void *data) in aggr_cpu_id__die() argument
296 if (die == -1) in aggr_cpu_id__die()
304 id = aggr_cpu_id__socket(cpu, data); in aggr_cpu_id__die()
319 struct aggr_cpu_id aggr_cpu_id__cluster(struct perf_cpu cpu, void *data) in aggr_cpu_id__cluster() argument
325 if (cluster == -1) in aggr_cpu_id__cluster()
328 id = aggr_cpu_id__die(cpu, data); in aggr_cpu_id__cluster()
342 struct aggr_cpu_id aggr_cpu_id__core(struct perf_cpu cpu, void *data) in aggr_cpu_id__core() argument
348 id = aggr_cpu_id__cluster(cpu, data); in aggr_cpu_id__core()
361 struct aggr_cpu_id aggr_cpu_id__cpu(struct perf_cpu cpu, void *data) in aggr_cpu_id__cpu() argument
366 id = aggr_cpu_id__core(cpu, data); in aggr_cpu_id__cpu()
375 struct aggr_cpu_id aggr_cpu_id__node(struct perf_cpu cpu, void *data __maybe_unused) in aggr_cpu_id__node()
383 struct aggr_cpu_id aggr_cpu_id__global(struct perf_cpu cpu, void *data __maybe_unused) in aggr_cpu_id__global()
394 static int get_max_num(char *path, int *max) in get_max_num() argument
400 if (filename__read_str(path, &buf, &num)) in get_max_num()
401 return -1; in get_max_num()
406 while (--num) { in get_max_num()
407 if ((buf[num] == ',') || (buf[num] == '-')) { in get_max_num()
413 err = -1; in get_max_num()
417 /* convert from 0-based to 1-based */ in get_max_num()
429 char path[PATH_MAX]; in set_max_cpu_num() local
430 int ret = -1; in set_max_cpu_num()
441 ret = snprintf(path, PATH_MAX, "%s/devices/system/cpu/possible", mnt); in set_max_cpu_num()
443 pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); in set_max_cpu_num()
447 ret = get_max_num(path, &max_cpu_num.cpu); in set_max_cpu_num()
452 ret = snprintf(path, PATH_MAX, "%s/devices/system/cpu/present", mnt); in set_max_cpu_num()
454 pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); in set_max_cpu_num()
458 ret = get_max_num(path, &max_present_cpu_num.cpu); in set_max_cpu_num()
469 char path[PATH_MAX]; in set_max_node_num() local
470 int ret = -1; in set_max_node_num()
480 ret = snprintf(path, PATH_MAX, "%s/devices/system/node/possible", mnt); in set_max_node_num()
482 pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); in set_max_node_num()
486 ret = get_max_num(path, &max_node_num); in set_max_node_num()
522 return -1; in cpu__get_node()
538 return -1; in init_cpunode_map()
542 cpunode_map[i] = -1; in init_cpunode_map()
553 char path[PATH_MAX]; in cpu__setup_cpunode_map() local
559 return -1; in cpu__setup_cpunode_map()
565 n = snprintf(path, PATH_MAX, "%s/devices/system/node", mnt); in cpu__setup_cpunode_map()
567 pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); in cpu__setup_cpunode_map()
568 return -1; in cpu__setup_cpunode_map()
571 dir1 = opendir(path); in cpu__setup_cpunode_map()
577 if (dent1->d_type != DT_DIR || sscanf(dent1->d_name, "node%u", &mem) < 1) in cpu__setup_cpunode_map()
580 n = snprintf(buf, PATH_MAX, "%s/%s", path, dent1->d_name); in cpu__setup_cpunode_map()
582 pr_err("sysfs path crossed PATH_MAX(%d) size\n", PATH_MAX); in cpu__setup_cpunode_map()
590 if (dent2->d_type != DT_LNK || sscanf(dent2->d_name, "cpu%u", &cpu) < 1) in cpu__setup_cpunode_map()
602 int i, start = -1; in cpu_map__snprint()
615 if (start == -1) { in cpu_map__snprint()
618 ret += snprintf(buf + ret, size - ret, in cpu_map__snprint()
622 } else if (((i - start) != (cpu.cpu - perf_cpu_map__cpu(map, start).cpu)) || last) { in cpu_map__snprint()
623 int end = i - 1; in cpu_map__snprint()
626 ret += snprintf(buf + ret, size - ret, in cpu_map__snprint()
630 ret += snprintf(buf + ret, size - ret, in cpu_map__snprint()
631 "%s%d-%d", COMMA, in cpu_map__snprint()
650 return val - 10 + 'a'; in hex_char()
673 for (int cpu = last_cpu.cpu / 4 * 4; cpu >= 0; cpu -= 4) { in cpu_map__snprint_mask()
688 buf[size - 1] = '\0'; in cpu_map__snprint_mask()
689 return ptr - buf; in cpu_map__snprint_mask()
704 return a->thread_idx == b->thread_idx && in aggr_cpu_id__equal()
705 a->node == b->node && in aggr_cpu_id__equal()
706 a->socket == b->socket && in aggr_cpu_id__equal()
707 a->die == b->die && in aggr_cpu_id__equal()
708 a->cluster == b->cluster && in aggr_cpu_id__equal()
709 a->cache_lvl == b->cache_lvl && in aggr_cpu_id__equal()
710 a->cache == b->cache && in aggr_cpu_id__equal()
711 a->core == b->core && in aggr_cpu_id__equal()
712 a->cpu.cpu == b->cpu.cpu; in aggr_cpu_id__equal()
717 return a->thread_idx == -1 && in aggr_cpu_id__is_empty()
718 a->node == -1 && in aggr_cpu_id__is_empty()
719 a->socket == -1 && in aggr_cpu_id__is_empty()
720 a->die == -1 && in aggr_cpu_id__is_empty()
721 a->cluster == -1 && in aggr_cpu_id__is_empty()
722 a->cache_lvl == -1 && in aggr_cpu_id__is_empty()
723 a->cache == -1 && in aggr_cpu_id__is_empty()
724 a->core == -1 && in aggr_cpu_id__is_empty()
725 a->cpu.cpu == -1; in aggr_cpu_id__is_empty()
731 .thread_idx = -1, in aggr_cpu_id__empty()
732 .node = -1, in aggr_cpu_id__empty()
733 .socket = -1, in aggr_cpu_id__empty()
734 .die = -1, in aggr_cpu_id__empty()
735 .cluster = -1, in aggr_cpu_id__empty()
736 .cache_lvl = -1, in aggr_cpu_id__empty()
737 .cache = -1, in aggr_cpu_id__empty()
738 .core = -1, in aggr_cpu_id__empty()
739 .cpu = (struct perf_cpu){ .cpu = -1 }, in aggr_cpu_id__empty()