Lines Matching +full:cpu +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0-only
14 void perf_cpu_map__set_nr(struct perf_cpu_map *map, int nr_cpus) in perf_cpu_map__set_nr() argument
16 RC_CHK_ACCESS(map)->nr = nr_cpus; in perf_cpu_map__set_nr()
25 cpus->nr = nr_cpus; in perf_cpu_map__alloc()
26 refcount_set(&cpus->refcnt, 1); in perf_cpu_map__alloc()
36 RC_CHK_ACCESS(cpus)->map[0].cpu = -1; in perf_cpu_map__new_any_cpu()
41 static void cpu_map__delete(struct perf_cpu_map *map) in cpu_map__delete() argument
43 if (map) { in cpu_map__delete()
44 WARN_ONCE(refcount_read(perf_cpu_map__refcnt(map)) != 0, in cpu_map__delete()
46 RC_CHK_FREE(map); in cpu_map__delete()
50 struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map) in perf_cpu_map__get() argument
54 if (RC_CHK_GET(result, map)) in perf_cpu_map__get()
55 refcount_inc(perf_cpu_map__refcnt(map)); in perf_cpu_map__get()
60 void perf_cpu_map__put(struct perf_cpu_map *map) in perf_cpu_map__put() argument
62 if (map) { in perf_cpu_map__put()
63 if (refcount_dec_and_test(perf_cpu_map__refcnt(map))) in perf_cpu_map__put()
64 cpu_map__delete(map); in perf_cpu_map__put()
66 RC_CHK_PUT(map); in perf_cpu_map__put()
81 …pr_warning("Number of online CPUs (%d) differs from the number configured (%d) the CPU map will on… in cpu_map__new_sysconf()
90 RC_CHK_ACCESS(cpus)->map[i].cpu = i; in cpu_map__new_sysconf()
101 onlnf = fopen("/sys/devices/system/cpu/online", "r"); in cpu_map__new_sysfs_online()
124 return cpu_a->cpu - cpu_b->cpu; in cmp_cpu()
129 return RC_CHK_ACCESS(cpus)->map[idx]; in __perf_cpu_map__cpu()
139 memcpy(RC_CHK_ACCESS(cpus)->map, tmp_cpus, payload_size); in cpu_map__trim_new()
140 qsort(RC_CHK_ACCESS(cpus)->map, nr_cpus, sizeof(struct perf_cpu), cmp_cpu); in cpu_map__trim_new()
145 __perf_cpu_map__cpu(cpus, i).cpu != in cpu_map__trim_new()
146 __perf_cpu_map__cpu(cpus, i - 1).cpu) { in cpu_map__trim_new()
147 RC_CHK_ACCESS(cpus)->map[j++].cpu = in cpu_map__trim_new()
148 __perf_cpu_map__cpu(cpus, i).cpu; in cpu_map__trim_new()
163 int n, cpu, prev; in perf_cpu_map__read() local
167 prev = -1; in perf_cpu_map__read()
169 n = fscanf(file, "%u%c", &cpu, &sep); in perf_cpu_map__read()
173 int new_max = nr_cpus + cpu - prev - 1; in perf_cpu_map__read()
186 while (++prev < cpu) in perf_cpu_map__read()
187 tmp_cpus[nr_cpus++].cpu = prev; in perf_cpu_map__read()
197 tmp_cpus[nr_cpus++].cpu = cpu; in perf_cpu_map__read()
198 if (n == 2 && sep == '-') in perf_cpu_map__read()
199 prev = cpu; in perf_cpu_map__read()
201 prev = -1; in perf_cpu_map__read()
227 * TOPOLOGY header for NUMA nodes with no CPU in perf_cpu_map__new()
228 * ( e.g., because of CPU hotplug) in perf_cpu_map__new()
237 || (*p != '\0' && *p != ',' && *p != '-')) in perf_cpu_map__new()
240 if (*p == '-') { in perf_cpu_map__new()
260 if (tmp_cpus[i].cpu == (int)start_cpu) in perf_cpu_map__new()
270 tmp_cpus[nr_cpus++].cpu = (int)start_cpu; in perf_cpu_map__new()
281 pr_warning("Unexpected characters at end of cpu list ('%s'), using online CPUs.", in perf_cpu_map__new()
294 return RC_CHK_ACCESS(cpus)->nr; in __perf_cpu_map__nr()
300 .cpu = -1 in perf_cpu_map__cpu()
314 bool perf_cpu_map__has_any_cpu_or_is_empty(const struct perf_cpu_map *map) in perf_cpu_map__has_any_cpu_or_is_empty() argument
316 return map ? __perf_cpu_map__cpu(map, 0).cpu == -1 : true; in perf_cpu_map__has_any_cpu_or_is_empty()
319 int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__idx() argument
324 return -1; in perf_cpu_map__idx()
332 if (cpu_at_idx.cpu == cpu.cpu) in perf_cpu_map__idx()
335 if (cpu_at_idx.cpu > cpu.cpu) in perf_cpu_map__idx()
341 return -1; in perf_cpu_map__idx()
344 bool perf_cpu_map__has(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__has() argument
346 return perf_cpu_map__idx(cpus, cpu) != -1; in perf_cpu_map__has()
364 if (__perf_cpu_map__cpu(lhs, idx).cpu != __perf_cpu_map__cpu(rhs, idx).cpu) in perf_cpu_map__equal()
370 bool perf_cpu_map__has_any_cpu(const struct perf_cpu_map *map) in perf_cpu_map__has_any_cpu() argument
372 return map && __perf_cpu_map__cpu(map, 0).cpu == -1; in perf_cpu_map__has_any_cpu()
375 struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map) in perf_cpu_map__max() argument
378 .cpu = -1 in perf_cpu_map__max()
382 return __perf_cpu_map__nr(map) > 0 in perf_cpu_map__max()
383 ? __perf_cpu_map__cpu(map, __perf_cpu_map__nr(map) - 1) in perf_cpu_map__max()
396 if (__perf_cpu_map__cpu(a, i).cpu > __perf_cpu_map__cpu(b, j).cpu) in perf_cpu_map__is_subset()
398 if (__perf_cpu_map__cpu(a, i).cpu == __perf_cpu_map__cpu(b, j).cpu) { in perf_cpu_map__is_subset()
410 * orig either gets freed and replaced with a new map, or reused
438 if (__perf_cpu_map__cpu(orig, i).cpu <= __perf_cpu_map__cpu(other, j).cpu) { in perf_cpu_map__merge()
439 if (__perf_cpu_map__cpu(orig, i).cpu == __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__merge()
479 if (__perf_cpu_map__cpu(orig, i).cpu < __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__intersect()
481 else if (__perf_cpu_map__cpu(orig, i).cpu > __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__intersect()