Lines Matching +full:cpu +full:- +full:nr

1 // SPDX-License-Identifier: GPL-2.0
19 "%s/devices/system/cpu/cpu%d/topology/package_cpus_list"
21 "%s/devices/system/cpu/cpu%d/topology/core_siblings_list"
23 "%s/devices/system/cpu/cpu%d/topology/die_cpus_list"
25 "%s/devices/system/cpu/cpu%d/topology/core_cpus_list"
27 "%s/devices/system/cpu/cpu%d/topology/thread_siblings_list"
35 static int build_cpu_topology(struct cpu_topology *tp, int cpu) in build_cpu_topology() argument
43 int ret = -1; in build_cpu_topology()
46 sysfs__mountpoint(), cpu); in build_cpu_topology()
47 if (access(filename, F_OK) == -1) { in build_cpu_topology()
49 sysfs__mountpoint(), cpu); in build_cpu_topology()
64 for (i = 0; i < tp->package_cpus_lists; i++) { in build_cpu_topology()
65 if (!strcmp(buf, tp->package_cpus_list[i])) in build_cpu_topology()
68 if (i == tp->package_cpus_lists) { in build_cpu_topology()
69 tp->package_cpus_list[i] = buf; in build_cpu_topology()
70 tp->package_cpus_lists++; in build_cpu_topology()
77 if (!tp->die_cpus_list) in build_cpu_topology()
81 sysfs__mountpoint(), cpu); in build_cpu_topology()
95 for (i = 0; i < tp->die_cpus_lists; i++) { in build_cpu_topology()
96 if (!strcmp(buf, tp->die_cpus_list[i])) in build_cpu_topology()
99 if (i == tp->die_cpus_lists) { in build_cpu_topology()
100 tp->die_cpus_list[i] = buf; in build_cpu_topology()
101 tp->die_cpus_lists++; in build_cpu_topology()
109 sysfs__mountpoint(), cpu); in build_cpu_topology()
110 if (access(filename, F_OK) == -1) { in build_cpu_topology()
112 sysfs__mountpoint(), cpu); in build_cpu_topology()
125 for (i = 0; i < tp->core_cpus_lists; i++) { in build_cpu_topology()
126 if (!strcmp(buf, tp->core_cpus_list[i])) in build_cpu_topology()
129 if (i == tp->core_cpus_lists) { in build_cpu_topology()
130 tp->core_cpus_list[i] = buf; in build_cpu_topology()
131 tp->core_cpus_lists++; in build_cpu_topology()
149 for (i = 0 ; i < tp->package_cpus_lists; i++) in cpu_topology__delete()
150 zfree(&tp->package_cpus_list[i]); in cpu_topology__delete()
152 for (i = 0 ; i < tp->die_cpus_lists; i++) in cpu_topology__delete()
153 zfree(&tp->die_cpus_list[i]); in cpu_topology__delete()
155 for (i = 0 ; i < tp->core_cpus_lists; i++) in cpu_topology__delete()
156 zfree(&tp->core_cpus_list[i]); in cpu_topology__delete()
163 for (u32 i = 0; i < topology->core_cpus_lists; i++) { in cpu_topology__smt_on()
164 const char *cpu_list = topology->core_cpus_list[i]; in cpu_topology__smt_on()
170 if (strchr(cpu_list, ',') || strchr(cpu_list, '-')) in cpu_topology__smt_on()
189 /* Check that every user requested CPU is the complete set of SMT threads on a core. */ in cpu_topology__core_wide()
190 for (u32 i = 0; i < topology->core_cpus_lists; i++) { in cpu_topology__core_wide()
191 const char *core_cpu_list = topology->core_cpus_list[i]; in cpu_topology__core_wide()
193 struct perf_cpu cpu; in cpu_topology__core_wide() local
197 perf_cpu_map__for_each_cpu(cpu, idx, core_cpus) { in cpu_topology__core_wide()
199 has_first = perf_cpu_map__has(user_requested_cpus, cpu); in cpu_topology__core_wide()
203 * If the first core CPU is user requested then in cpu_topology__core_wide()
205 * requested too. If the first CPU isn't user in cpu_topology__core_wide()
209 if (perf_cpu_map__has(user_requested_cpus, cpu) != has_first) { in cpu_topology__core_wide()
236 if (access(filename, F_OK) == -1) in has_die_topology()
249 pr_err("Error creating CPU topology"); in online_topology()
260 u32 nr, i, nr_addr; in cpu_topology__new() local
263 int ret = -1; in cpu_topology__new()
267 ncpus = cpu__max_present_cpu().cpu; in cpu_topology__new()
269 /* build online CPU map */ in cpu_topology__new()
276 nr = (u32)(ncpus & UINT_MAX); in cpu_topology__new()
278 sz = nr * sizeof(char *); in cpu_topology__new()
289 tp->package_cpus_list = addr; in cpu_topology__new()
292 tp->die_cpus_list = addr; in cpu_topology__new()
295 tp->core_cpus_list = addr; in cpu_topology__new()
297 for (i = 0; i < nr; i++) { in cpu_topology__new()
298 if (!perf_cpu_map__has(map, (struct perf_cpu){ .cpu = i })) in cpu_topology__new()
315 static int load_numa_node(struct numa_topology_node *node, int nr) in load_numa_node() argument
321 int ret = -1; in load_numa_node()
325 node->node = (u32) nr; in load_numa_node()
328 sysfs__mountpoint(), nr); in load_numa_node()
331 return -1; in load_numa_node()
340 node->mem_total = mem; in load_numa_node()
342 node->mem_free = mem; in load_numa_node()
343 if (node->mem_total && node->mem_free) in load_numa_node()
351 sysfs__mountpoint(), nr); in load_numa_node()
355 return -1; in load_numa_node()
364 node->cpus = buf; in load_numa_node()
382 u32 nr, i; in numa_topology__new() local
404 nr = (u32) perf_cpu_map__nr(node_map); in numa_topology__new()
406 tp = zalloc(sizeof(*tp) + sizeof(tp->nodes[0])*nr); in numa_topology__new()
410 tp->nr = nr; in numa_topology__new()
412 for (i = 0; i < nr; i++) { in numa_topology__new()
413 if (load_numa_node(&tp->nodes[i], perf_cpu_map__cpu(node_map, i).cpu)) { in numa_topology__new()
431 for (i = 0; i < tp->nr; i++) in numa_topology__delete()
432 zfree(&tp->nodes[i].cpus); in numa_topology__delete()
444 node->pmu_name = strdup(pmu->name); in load_hybrid_node()
445 if (!node->pmu_name) in load_hybrid_node()
446 return -1; in load_hybrid_node()
462 node->cpus = buf; in load_hybrid_node()
466 zfree(&node->pmu_name); in load_hybrid_node()
468 return -1; in load_hybrid_node()
475 int nr = perf_pmus__num_core_pmus(), i = 0; in hybrid_topology__new() local
477 if (nr <= 1) in hybrid_topology__new()
480 tp = zalloc(sizeof(*tp) + sizeof(tp->nodes[0]) * nr); in hybrid_topology__new()
484 tp->nr = nr; in hybrid_topology__new()
486 if (load_hybrid_node(&tp->nodes[i], pmu)) { in hybrid_topology__new()
500 for (i = 0; i < tp->nr; i++) { in hybrid_topology__delete()
501 zfree(&tp->nodes[i].pmu_name); in hybrid_topology__delete()
502 zfree(&tp->nodes[i].cpus); in hybrid_topology__delete()