Lines Matching +full:cpu +full:- +full:map

1 // SPDX-License-Identifier: GPL-2.0-only
18 cpus->nr = nr_cpus; in perf_cpu_map__alloc()
19 refcount_set(&cpus->refcnt, 1); in perf_cpu_map__alloc()
30 cpus->map[0].cpu = -1; in perf_cpu_map__dummy_new()
35 static void cpu_map__delete(struct perf_cpu_map *map) in cpu_map__delete() argument
37 if (map) { in cpu_map__delete()
38 WARN_ONCE(refcount_read(&map->refcnt) != 0, in cpu_map__delete()
40 free(map); in cpu_map__delete()
44 struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map) in perf_cpu_map__get() argument
46 if (map) in perf_cpu_map__get()
47 refcount_inc(&map->refcnt); in perf_cpu_map__get()
48 return map; in perf_cpu_map__get()
51 void perf_cpu_map__put(struct perf_cpu_map *map) in perf_cpu_map__put() argument
53 if (map && refcount_dec_and_test(&map->refcnt)) in perf_cpu_map__put()
54 cpu_map__delete(map); in perf_cpu_map__put()
71 cpus->map[i].cpu = i; in cpu_map__default_new()
87 return cpu_a->cpu - cpu_b->cpu; in cmp_cpu()
97 memcpy(cpus->map, tmp_cpus, payload_size); in cpu_map__trim_new()
98 qsort(cpus->map, nr_cpus, sizeof(struct perf_cpu), cmp_cpu); in cpu_map__trim_new()
102 if (i == 0 || cpus->map[i].cpu != cpus->map[i - 1].cpu) in cpu_map__trim_new()
103 cpus->map[j++].cpu = cpus->map[i].cpu; in cpu_map__trim_new()
105 cpus->nr = j; in cpu_map__trim_new()
117 int n, cpu, prev; in perf_cpu_map__read() local
121 prev = -1; in perf_cpu_map__read()
123 n = fscanf(file, "%u%c", &cpu, &sep); in perf_cpu_map__read()
127 int new_max = nr_cpus + cpu - prev - 1; in perf_cpu_map__read()
140 while (++prev < cpu) in perf_cpu_map__read()
141 tmp_cpus[nr_cpus++].cpu = prev; in perf_cpu_map__read()
151 tmp_cpus[nr_cpus++].cpu = cpu; in perf_cpu_map__read()
152 if (n == 2 && sep == '-') in perf_cpu_map__read()
153 prev = cpu; in perf_cpu_map__read()
155 prev = -1; in perf_cpu_map__read()
174 onlnf = fopen("/sys/devices/system/cpu/online", "r"); in cpu_map__read_all_cpu_map()
197 * TOPOLOGY header for NUMA nodes with no CPU in perf_cpu_map__new()
198 * ( e.g., because of CPU hotplug) in perf_cpu_map__new()
207 || (*p != '\0' && *p != ',' && *p != '-')) in perf_cpu_map__new()
210 if (*p == '-') { in perf_cpu_map__new()
230 if (tmp_cpus[i].cpu == (int)start_cpu) in perf_cpu_map__new()
240 tmp_cpus[nr_cpus++].cpu = (int)start_cpu; in perf_cpu_map__new()
263 .cpu = -1 in perf_cpu_map__cpu()
266 if (cpus && idx < cpus->nr) in perf_cpu_map__cpu()
267 return cpus->map[idx]; in perf_cpu_map__cpu()
274 return cpus ? cpus->nr : 1; in perf_cpu_map__nr()
277 bool perf_cpu_map__empty(const struct perf_cpu_map *map) in perf_cpu_map__empty() argument
279 return map ? map->map[0].cpu == -1 : true; in perf_cpu_map__empty()
282 int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__idx() argument
287 return -1; in perf_cpu_map__idx()
290 high = cpus->nr; in perf_cpu_map__idx()
293 struct perf_cpu cpu_at_idx = cpus->map[idx]; in perf_cpu_map__idx()
295 if (cpu_at_idx.cpu == cpu.cpu) in perf_cpu_map__idx()
298 if (cpu_at_idx.cpu > cpu.cpu) in perf_cpu_map__idx()
304 return -1; in perf_cpu_map__idx()
307 bool perf_cpu_map__has(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__has() argument
309 return perf_cpu_map__idx(cpus, cpu) != -1; in perf_cpu_map__has()
312 struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map) in perf_cpu_map__max() argument
315 .cpu = -1 in perf_cpu_map__max()
319 return map->nr > 0 ? map->map[map->nr - 1] : result; in perf_cpu_map__max()
327 if (!a || b->nr > a->nr) in perf_cpu_map__is_subset()
330 for (int i = 0, j = 0; i < a->nr; i++) { in perf_cpu_map__is_subset()
331 if (a->map[i].cpu > b->map[j].cpu) in perf_cpu_map__is_subset()
333 if (a->map[i].cpu == b->map[j].cpu) { in perf_cpu_map__is_subset()
335 if (j == b->nr) in perf_cpu_map__is_subset()
345 * orig either gets freed and replaced with a new map, or reused
365 tmp_len = orig->nr + other->nr; in perf_cpu_map__merge()
372 while (i < orig->nr && j < other->nr) { in perf_cpu_map__merge()
373 if (orig->map[i].cpu <= other->map[j].cpu) { in perf_cpu_map__merge()
374 if (orig->map[i].cpu == other->map[j].cpu) in perf_cpu_map__merge()
376 tmp_cpus[k++] = orig->map[i++]; in perf_cpu_map__merge()
378 tmp_cpus[k++] = other->map[j++]; in perf_cpu_map__merge()
381 while (i < orig->nr) in perf_cpu_map__merge()
382 tmp_cpus[k++] = orig->map[i++]; in perf_cpu_map__merge()
384 while (j < other->nr) in perf_cpu_map__merge()
385 tmp_cpus[k++] = other->map[j++]; in perf_cpu_map__merge()