Lines Matching +full:cpu +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0-only
13 void perf_cpu_map__set_nr(struct perf_cpu_map *map, int nr_cpus) in perf_cpu_map__set_nr() argument
15 RC_CHK_ACCESS(map)->nr = nr_cpus; in perf_cpu_map__set_nr()
24 cpus->nr = nr_cpus; in perf_cpu_map__alloc()
25 refcount_set(&cpus->refcnt, 1); in perf_cpu_map__alloc()
35 RC_CHK_ACCESS(cpus)->map[0].cpu = -1; in perf_cpu_map__dummy_new()
40 static void cpu_map__delete(struct perf_cpu_map *map) in cpu_map__delete() argument
42 if (map) { in cpu_map__delete()
43 WARN_ONCE(refcount_read(perf_cpu_map__refcnt(map)) != 0, in cpu_map__delete()
45 RC_CHK_FREE(map); in cpu_map__delete()
49 struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map) in perf_cpu_map__get() argument
53 if (RC_CHK_GET(result, map)) in perf_cpu_map__get()
54 refcount_inc(perf_cpu_map__refcnt(map)); in perf_cpu_map__get()
59 void perf_cpu_map__put(struct perf_cpu_map *map) in perf_cpu_map__put() argument
61 if (map) { in perf_cpu_map__put()
62 if (refcount_dec_and_test(perf_cpu_map__refcnt(map))) in perf_cpu_map__put()
63 cpu_map__delete(map); in perf_cpu_map__put()
65 RC_CHK_PUT(map); in perf_cpu_map__put()
83 RC_CHK_ACCESS(cpus)->map[i].cpu = i; in cpu_map__default_new()
99 return cpu_a->cpu - cpu_b->cpu; in cmp_cpu()
104 return RC_CHK_ACCESS(cpus)->map[idx]; in __perf_cpu_map__cpu()
114 memcpy(RC_CHK_ACCESS(cpus)->map, tmp_cpus, payload_size); in cpu_map__trim_new()
115 qsort(RC_CHK_ACCESS(cpus)->map, nr_cpus, sizeof(struct perf_cpu), cmp_cpu); in cpu_map__trim_new()
120 __perf_cpu_map__cpu(cpus, i).cpu != in cpu_map__trim_new()
121 __perf_cpu_map__cpu(cpus, i - 1).cpu) { in cpu_map__trim_new()
122 RC_CHK_ACCESS(cpus)->map[j++].cpu = in cpu_map__trim_new()
123 __perf_cpu_map__cpu(cpus, i).cpu; in cpu_map__trim_new()
138 int n, cpu, prev; in perf_cpu_map__read() local
142 prev = -1; in perf_cpu_map__read()
144 n = fscanf(file, "%u%c", &cpu, &sep); in perf_cpu_map__read()
148 int new_max = nr_cpus + cpu - prev - 1; in perf_cpu_map__read()
161 while (++prev < cpu) in perf_cpu_map__read()
162 tmp_cpus[nr_cpus++].cpu = prev; in perf_cpu_map__read()
172 tmp_cpus[nr_cpus++].cpu = cpu; in perf_cpu_map__read()
173 if (n == 2 && sep == '-') in perf_cpu_map__read()
174 prev = cpu; in perf_cpu_map__read()
176 prev = -1; in perf_cpu_map__read()
195 onlnf = fopen("/sys/devices/system/cpu/online", "r"); in cpu_map__read_all_cpu_map()
218 * TOPOLOGY header for NUMA nodes with no CPU in perf_cpu_map__new()
219 * ( e.g., because of CPU hotplug) in perf_cpu_map__new()
228 || (*p != '\0' && *p != ',' && *p != '-')) in perf_cpu_map__new()
231 if (*p == '-') { in perf_cpu_map__new()
251 if (tmp_cpus[i].cpu == (int)start_cpu) in perf_cpu_map__new()
261 tmp_cpus[nr_cpus++].cpu = (int)start_cpu; in perf_cpu_map__new()
283 return RC_CHK_ACCESS(cpus)->nr; in __perf_cpu_map__nr()
289 .cpu = -1 in perf_cpu_map__cpu()
303 bool perf_cpu_map__empty(const struct perf_cpu_map *map) in perf_cpu_map__empty() argument
305 return map ? __perf_cpu_map__cpu(map, 0).cpu == -1 : true; in perf_cpu_map__empty()
308 int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__idx() argument
313 return -1; in perf_cpu_map__idx()
321 if (cpu_at_idx.cpu == cpu.cpu) in perf_cpu_map__idx()
324 if (cpu_at_idx.cpu > cpu.cpu) in perf_cpu_map__idx()
330 return -1; in perf_cpu_map__idx()
333 bool perf_cpu_map__has(const struct perf_cpu_map *cpus, struct perf_cpu cpu) in perf_cpu_map__has() argument
335 return perf_cpu_map__idx(cpus, cpu) != -1; in perf_cpu_map__has()
353 if (__perf_cpu_map__cpu(lhs, idx).cpu != __perf_cpu_map__cpu(rhs, idx).cpu) in perf_cpu_map__equal()
359 bool perf_cpu_map__has_any_cpu(const struct perf_cpu_map *map) in perf_cpu_map__has_any_cpu() argument
361 return map && __perf_cpu_map__cpu(map, 0).cpu == -1; in perf_cpu_map__has_any_cpu()
364 struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map) in perf_cpu_map__max() argument
367 .cpu = -1 in perf_cpu_map__max()
371 return __perf_cpu_map__nr(map) > 0 in perf_cpu_map__max()
372 ? __perf_cpu_map__cpu(map, __perf_cpu_map__nr(map) - 1) in perf_cpu_map__max()
385 if (__perf_cpu_map__cpu(a, i).cpu > __perf_cpu_map__cpu(b, j).cpu) in perf_cpu_map__is_subset()
387 if (__perf_cpu_map__cpu(a, i).cpu == __perf_cpu_map__cpu(b, j).cpu) { in perf_cpu_map__is_subset()
399 * orig either gets freed and replaced with a new map, or reused
427 if (__perf_cpu_map__cpu(orig, i).cpu <= __perf_cpu_map__cpu(other, j).cpu) { in perf_cpu_map__merge()
428 if (__perf_cpu_map__cpu(orig, i).cpu == __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__merge()
468 if (__perf_cpu_map__cpu(orig, i).cpu < __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__intersect()
470 else if (__perf_cpu_map__cpu(orig, i).cpu > __perf_cpu_map__cpu(other, j).cpu) in perf_cpu_map__intersect()