Lines Matching full:cpu
3 * Arch specific cpu topology information
10 #include <linux/cpu.h>
61 void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity) in topology_set_cpu_scale() argument
63 per_cpu(cpu_scale, cpu) = capacity; in topology_set_cpu_scale()
71 int cpu; in topology_set_thermal_pressure() local
73 for_each_cpu(cpu, cpus) in topology_set_thermal_pressure()
74 WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure); in topology_set_thermal_pressure()
81 struct cpu *cpu = container_of(dev, struct cpu, dev); in cpu_capacity_show() local
83 return sysfs_emit(buf, "%lu\n", topology_get_cpu_scale(cpu->dev.id)); in cpu_capacity_show()
94 struct device *cpu; in register_cpu_capacity_sysctl() local
97 cpu = get_cpu_device(i); in register_cpu_capacity_sysctl()
98 if (!cpu) { in register_cpu_capacity_sysctl()
99 pr_err("%s: too early to get CPU%d device!\n", in register_cpu_capacity_sysctl()
103 device_create_file(cpu, &dev_attr_cpu_capacity); in register_cpu_capacity_sysctl()
144 int cpu; in topology_normalize_cpu_scale() local
150 for_each_possible_cpu(cpu) { in topology_normalize_cpu_scale()
151 capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu); in topology_normalize_cpu_scale()
156 for_each_possible_cpu(cpu) { in topology_normalize_cpu_scale()
157 capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu); in topology_normalize_cpu_scale()
160 topology_set_cpu_scale(cpu, capacity); in topology_normalize_cpu_scale()
161 pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n", in topology_normalize_cpu_scale()
162 cpu, topology_get_cpu_scale(cpu)); in topology_normalize_cpu_scale()
166 bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) in topology_parse_cpu_capacity() argument
188 raw_capacity[cpu] = cpu_capacity; in topology_parse_cpu_capacity()
190 cpu_node, raw_capacity[cpu]); in topology_parse_cpu_capacity()
193 * Update freq_factor for calculating early boot cpu capacities. in topology_parse_cpu_capacity()
194 * For non-clk CPU DVFS mechanism, there's no way to get the in topology_parse_cpu_capacity()
200 per_cpu(freq_factor, cpu) = in topology_parse_cpu_capacity()
228 int cpu; in init_cpu_capacity_callback() local
236 pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n", in init_cpu_capacity_callback()
242 for_each_cpu(cpu, policy->related_cpus) in init_cpu_capacity_callback()
243 per_cpu(freq_factor, cpu) = policy->cpuinfo.max_freq / 1000; in init_cpu_capacity_callback()
265 * on ACPI-based systems we need to use the default cpu capacity in register_cpufreq_notifier()
266 * until we have the necessary code to parse the cpu capacity, so in register_cpufreq_notifier()
300 * This function returns the logic cpu number of the node.
302 * (1) logic cpu number which is > 0.
304 * there is no possible logical CPU in the kernel to match. This happens
306 * CPU nodes in DT. We need to just ignore this case.
312 int cpu; in get_cpu_for_node() local
314 cpu_node = of_parse_phandle(node, "cpu", 0); in get_cpu_for_node()
318 cpu = of_cpu_node_to_id(cpu_node); in get_cpu_for_node()
319 if (cpu >= 0) in get_cpu_for_node()
320 topology_parse_cpu_capacity(cpu_node, cpu); in get_cpu_for_node()
322 pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n", in get_cpu_for_node()
326 return cpu; in get_cpu_for_node()
335 int cpu; in parse_core() local
343 cpu = get_cpu_for_node(t); in parse_core()
344 if (cpu >= 0) { in parse_core()
345 cpu_topology[cpu].package_id = package_id; in parse_core()
346 cpu_topology[cpu].core_id = core_id; in parse_core()
347 cpu_topology[cpu].thread_id = i; in parse_core()
348 } else if (cpu != -ENODEV) { in parse_core()
349 pr_err("%pOF: Can't get CPU for thread\n", t); in parse_core()
358 cpu = get_cpu_for_node(core); in parse_core()
359 if (cpu >= 0) { in parse_core()
361 pr_err("%pOF: Core has both threads and CPU\n", in parse_core()
366 cpu_topology[cpu].package_id = package_id; in parse_core()
367 cpu_topology[cpu].core_id = core_id; in parse_core()
368 } else if (leaf && cpu != -ENODEV) { in parse_core()
369 pr_err("%pOF: Can't get CPU for leaf core\n", core); in parse_core()
414 pr_err("%pOF: cpu-map children should be clusters\n", in parse_cluster()
448 int cpu; in parse_dt_topology() local
452 pr_err("No CPU information found in DT\n"); in parse_dt_topology()
457 * When topology is provided cpu-map is essentially a root in parse_dt_topology()
460 map = of_get_child_by_name(cn, "cpu-map"); in parse_dt_topology()
474 for_each_possible_cpu(cpu) in parse_dt_topology()
475 if (cpu_topology[cpu].package_id == -1) in parse_dt_topology()
487 * cpu topology table
492 const struct cpumask *cpu_coregroup_mask(int cpu) in cpu_coregroup_mask() argument
494 const cpumask_t *core_mask = cpumask_of_node(cpu_to_node(cpu)); in cpu_coregroup_mask()
497 if (cpumask_subset(&cpu_topology[cpu].core_sibling, core_mask)) { in cpu_coregroup_mask()
499 core_mask = &cpu_topology[cpu].core_sibling; in cpu_coregroup_mask()
501 if (cpu_topology[cpu].llc_id != -1) { in cpu_coregroup_mask()
502 if (cpumask_subset(&cpu_topology[cpu].llc_sibling, core_mask)) in cpu_coregroup_mask()
503 core_mask = &cpu_topology[cpu].llc_sibling; in cpu_coregroup_mask()
512 int cpu; in update_siblings_masks() local
515 for_each_online_cpu(cpu) { in update_siblings_masks()
516 cpu_topo = &cpu_topology[cpu]; in update_siblings_masks()
519 cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling); in update_siblings_masks()
527 cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); in update_siblings_masks()
533 cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling); in update_siblings_masks()
537 static void clear_cpu_topology(int cpu) in clear_cpu_topology() argument
539 struct cpu_topology *cpu_topo = &cpu_topology[cpu]; in clear_cpu_topology()
542 cpumask_set_cpu(cpu, &cpu_topo->llc_sibling); in clear_cpu_topology()
545 cpumask_set_cpu(cpu, &cpu_topo->core_sibling); in clear_cpu_topology()
547 cpumask_set_cpu(cpu, &cpu_topo->thread_sibling); in clear_cpu_topology()
552 unsigned int cpu; in reset_cpu_topology() local
554 for_each_possible_cpu(cpu) { in reset_cpu_topology()
555 struct cpu_topology *cpu_topo = &cpu_topology[cpu]; in reset_cpu_topology()
562 clear_cpu_topology(cpu); in reset_cpu_topology()
566 void remove_cpu_topology(unsigned int cpu) in remove_cpu_topology() argument
570 for_each_cpu(sibling, topology_core_cpumask(cpu)) in remove_cpu_topology()
571 cpumask_clear_cpu(cpu, topology_core_cpumask(sibling)); in remove_cpu_topology()
572 for_each_cpu(sibling, topology_sibling_cpumask(cpu)) in remove_cpu_topology()
573 cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); in remove_cpu_topology()
574 for_each_cpu(sibling, topology_llc_cpumask(cpu)) in remove_cpu_topology()
575 cpumask_clear_cpu(cpu, topology_llc_cpumask(sibling)); in remove_cpu_topology()
577 clear_cpu_topology(cpu); in remove_cpu_topology()
611 pr_debug("CPU%u: package %d core %d thread %d\n", in store_cpu_topology()