| 1 | |
| 2 |
|
| 3 | #include <linux/debugfs.h>
|
| 4 |
|
| 5 | #include <asm/apic.h>
|
| 6 | #include <asm/processor.h>
|
| 7 |
|
| 8 | #include "cpu.h"
|
| 9 |
|
| 10 | static int cpu_debug_show(struct seq_file *m, void *p)
|
| 11 | {
|
| 12 | unsigned long cpu = (unsigned long)m->private;
|
| 13 | struct cpuinfo_x86 *c = per_cpu_ptr(&cpu_info, cpu);
|
| 14 |
|
| 15 | seq_printf(m, "online: %d\n", cpu_online(cpu));
|
| 16 | if (!c->initialized)
|
| 17 | return 0;
|
| 18 |
|
| 19 | seq_printf(m, "initial_apicid: 0x%x\n", c->topo.initial_apicid);
|
| 20 | seq_printf(m, "apicid: 0x%x\n", c->topo.apicid);
|
| 21 | seq_printf(m, "pkg_id: %u\n", c->topo.pkg_id);
|
| 22 | seq_printf(m, "die_id: %u\n", c->topo.die_id);
|
| 23 | seq_printf(m, "cu_id: %u\n", c->topo.cu_id);
|
| 24 | seq_printf(m, "core_id: %u\n", c->topo.core_id);
|
| 25 | seq_printf(m, "cpu_type: %s\n", get_topology_cpu_type_name(c));
|
| 26 | seq_printf(m, "logical_pkg_id: %u\n", c->topo.logical_pkg_id);
|
| 27 | seq_printf(m, "logical_die_id: %u\n", c->topo.logical_die_id);
|
| 28 | seq_printf(m, "logical_core_id: %u\n", c->topo.logical_core_id);
|
| 29 | seq_printf(m, "llc_id: %u\n", c->topo.llc_id);
|
| 30 | seq_printf(m, "l2c_id: %u\n", c->topo.l2c_id);
|
| 31 | seq_printf(m, "amd_node_id: %u\n", c->topo.amd_node_id);
|
| 32 | seq_printf(m, "amd_nodes_per_pkg: %u\n", topology_amd_nodes_per_pkg());
|
| 33 | seq_printf(m, "num_threads: %u\n", __num_threads_per_package);
|
| 34 | seq_printf(m, "num_cores: %u\n", __num_cores_per_package);
|
| 35 | seq_printf(m, "max_dies_per_pkg: %u\n", __max_dies_per_package);
|
| 36 | seq_printf(m, "max_threads_per_core:%u\n", __max_threads_per_core);
|
| 37 | return 0;
|
| 38 | }
|
| 39 |
|
| 40 | static int cpu_debug_open(struct inode *inode, struct file *file)
|
| 41 | {
|
| 42 | return single_open(file, cpu_debug_show, inode->i_private);
|
| 43 | }
|
| 44 |
|
| 45 | static const struct file_operations dfs_cpu_ops = {
|
| 46 | .open = cpu_debug_open,
|
| 47 | .read = seq_read,
|
| 48 | .llseek = seq_lseek,
|
| 49 | .release = single_release,
|
| 50 | };
|
| 51 |
|
| 52 | static int dom_debug_show(struct seq_file *m, void *p)
|
| 53 | {
|
| 54 | static const char *domain_names[TOPO_MAX_DOMAIN] = {
|
| 55 | [TOPO_SMT_DOMAIN] = "Thread",
|
| 56 | [TOPO_CORE_DOMAIN] = "Core",
|
| 57 | [TOPO_MODULE_DOMAIN] = "Module",
|
| 58 | [TOPO_TILE_DOMAIN] = "Tile",
|
| 59 | [TOPO_DIE_DOMAIN] = "Die",
|
| 60 | [TOPO_DIEGRP_DOMAIN] = "DieGrp",
|
| 61 | [TOPO_PKG_DOMAIN] = "Package",
|
| 62 | };
|
| 63 | unsigned int dom, nthreads = 1;
|
| 64 |
|
| 65 | for (dom = 0; dom < TOPO_MAX_DOMAIN; dom++) {
|
| 66 | nthreads *= x86_topo_system.dom_size[dom];
|
| 67 | seq_printf(m, "domain: %-10s shift: %u dom_size: %5u max_threads: %5u\n",
|
| 68 | domain_names[dom], x86_topo_system.dom_shifts[dom],
|
| 69 | x86_topo_system.dom_size[dom], nthreads);
|
| 70 | }
|
| 71 | return 0;
|
| 72 | }
|
| 73 |
|
| 74 | static int dom_debug_open(struct inode *inode, struct file *file)
|
| 75 | {
|
| 76 | return single_open(file, dom_debug_show, inode->i_private);
|
| 77 | }
|
| 78 |
|
| 79 | static const struct file_operations dfs_dom_ops = {
|
| 80 | .open = dom_debug_open,
|
| 81 | .read = seq_read,
|
| 82 | .llseek = seq_lseek,
|
| 83 | .release = single_release,
|
| 84 | };
|
| 85 |
|
| 86 | static __init int cpu_init_debugfs(void)
|
| 87 | {
|
| 88 | struct dentry *dir, *base = debugfs_create_dir("topo", arch_debugfs_dir);
|
| 89 | unsigned long id;
|
| 90 | char name[24];
|
| 91 |
|
| 92 | debugfs_create_file("domains", 0444, base, NULL, &dfs_dom_ops);
|
| 93 |
|
| 94 | dir = debugfs_create_dir("cpus", base);
|
| 95 | for_each_possible_cpu(id) {
|
| 96 | sprintf(name, "%lu", id);
|
| 97 | debugfs_create_file(name, 0444, dir, (void *)id, &dfs_cpu_ops);
|
| 98 | }
|
| 99 | return 0;
|
| 100 | }
|
| 101 | late_initcall(cpu_init_debugfs);
|