proc.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #include <linux/smp.h>
  2. #include <linux/timex.h>
  3. #include <linux/string.h>
  4. #include <linux/seq_file.h>
  5. /*
  6. * Get CPU information for use by the procfs.
  7. */
  8. static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
  9. unsigned int cpu)
  10. {
  11. #ifdef CONFIG_SMP
  12. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  13. seq_printf(m, "siblings\t: %d\n",
  14. cpumask_weight(topology_core_cpumask(cpu)));
  15. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  16. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  17. seq_printf(m, "apicid\t\t: %d\n", c->apicid);
  18. seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
  19. #endif
  20. }
  21. #ifdef CONFIG_X86_32
  22. static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
  23. {
  24. seq_printf(m,
  25. "fdiv_bug\t: %s\n"
  26. "f00f_bug\t: %s\n"
  27. "coma_bug\t: %s\n"
  28. "fpu\t\t: %s\n"
  29. "fpu_exception\t: %s\n"
  30. "cpuid level\t: %d\n"
  31. "wp\t\t: yes\n",
  32. static_cpu_has_bug(X86_BUG_FDIV) ? "yes" : "no",
  33. static_cpu_has_bug(X86_BUG_F00F) ? "yes" : "no",
  34. static_cpu_has_bug(X86_BUG_COMA) ? "yes" : "no",
  35. static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
  36. static_cpu_has(X86_FEATURE_FPU) ? "yes" : "no",
  37. c->cpuid_level);
  38. }
  39. #else
  40. static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
  41. {
  42. seq_printf(m,
  43. "fpu\t\t: yes\n"
  44. "fpu_exception\t: yes\n"
  45. "cpuid level\t: %d\n"
  46. "wp\t\t: yes\n",
  47. c->cpuid_level);
  48. }
  49. #endif
  50. static int show_cpuinfo(struct seq_file *m, void *v)
  51. {
  52. struct cpuinfo_x86 *c = v;
  53. unsigned int cpu;
  54. int i;
  55. cpu = c->cpu_index;
  56. seq_printf(m, "processor\t: %u\n"
  57. "vendor_id\t: %s\n"
  58. "cpu family\t: %d\n"
  59. "model\t\t: %u\n"
  60. "model name\t: %s\n",
  61. cpu,
  62. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  63. c->x86,
  64. c->x86_model,
  65. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  66. if (c->x86_mask || c->cpuid_level >= 0)
  67. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  68. else
  69. seq_puts(m, "stepping\t: unknown\n");
  70. if (c->microcode)
  71. seq_printf(m, "microcode\t: 0x%x\n", c->microcode);
  72. if (cpu_has(c, X86_FEATURE_TSC))
  73. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  74. cpu_khz / 1000, (cpu_khz % 1000));
  75. /* Cache size */
  76. if (c->x86_cache_size >= 0)
  77. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  78. show_cpuinfo_core(m, c, cpu);
  79. show_cpuinfo_misc(m, c);
  80. seq_puts(m, "flags\t\t:");
  81. for (i = 0; i < 32*NCAPINTS; i++)
  82. if (cpu_has(c, i) && x86_cap_flags[i] != NULL)
  83. seq_printf(m, " %s", x86_cap_flags[i]);
  84. seq_puts(m, "\nbugs\t\t:");
  85. for (i = 0; i < 32*NBUGINTS; i++) {
  86. unsigned int bug_bit = 32*NCAPINTS + i;
  87. if (cpu_has_bug(c, bug_bit) && x86_bug_flags[i])
  88. seq_printf(m, " %s", x86_bug_flags[i]);
  89. }
  90. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  91. c->loops_per_jiffy/(500000/HZ),
  92. (c->loops_per_jiffy/(5000/HZ)) % 100);
  93. #ifdef CONFIG_X86_64
  94. if (c->x86_tlbsize > 0)
  95. seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize);
  96. #endif
  97. seq_printf(m, "clflush size\t: %u\n", c->x86_clflush_size);
  98. seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment);
  99. seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n",
  100. c->x86_phys_bits, c->x86_virt_bits);
  101. seq_puts(m, "power management:");
  102. for (i = 0; i < 32; i++) {
  103. if (c->x86_power & (1 << i)) {
  104. if (i < ARRAY_SIZE(x86_power_flags) &&
  105. x86_power_flags[i])
  106. seq_printf(m, "%s%s",
  107. x86_power_flags[i][0] ? " " : "",
  108. x86_power_flags[i]);
  109. else
  110. seq_printf(m, " [%d]", i);
  111. }
  112. }
  113. seq_puts(m, "\n\n");
  114. return 0;
  115. }
  116. static void *c_start(struct seq_file *m, loff_t *pos)
  117. {
  118. *pos = cpumask_next(*pos - 1, cpu_online_mask);
  119. if ((*pos) < nr_cpu_ids)
  120. return &cpu_data(*pos);
  121. return NULL;
  122. }
  123. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  124. {
  125. (*pos)++;
  126. return c_start(m, pos);
  127. }
  128. static void c_stop(struct seq_file *m, void *v)
  129. {
  130. }
  131. const struct seq_operations cpuinfo_op = {
  132. .start = c_start,
  133. .next = c_next,
  134. .stop = c_stop,
  135. .show = show_cpuinfo,
  136. };