proc.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include <linux/smp.h>
  2. #include <linux/timex.h>
  3. #include <linux/string.h>
  4. #include <asm/semaphore.h>
  5. #include <linux/seq_file.h>
  6. #include <linux/cpufreq.h>
  7. /*
  8. * Get CPU information for use by the procfs.
  9. */
  10. static int show_cpuinfo(struct seq_file *m, void *v)
  11. {
  12. struct cpuinfo_x86 *c = v;
  13. int i, n = 0;
  14. int fpu_exception;
  15. #ifdef CONFIG_SMP
  16. n = c->cpu_index;
  17. #endif
  18. seq_printf(m, "processor\t: %d\n"
  19. "vendor_id\t: %s\n"
  20. "cpu family\t: %d\n"
  21. "model\t\t: %d\n"
  22. "model name\t: %s\n",
  23. n,
  24. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  25. c->x86,
  26. c->x86_model,
  27. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  28. if (c->x86_mask || c->cpuid_level >= 0)
  29. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  30. else
  31. seq_printf(m, "stepping\t: unknown\n");
  32. if ( cpu_has(c, X86_FEATURE_TSC) ) {
  33. unsigned int freq = cpufreq_quick_get(n);
  34. if (!freq)
  35. freq = cpu_khz;
  36. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  37. freq / 1000, (freq % 1000));
  38. }
  39. /* Cache size */
  40. if (c->x86_cache_size >= 0)
  41. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  42. #ifdef CONFIG_X86_HT
  43. if (c->x86_max_cores * smp_num_siblings > 1) {
  44. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  45. seq_printf(m, "siblings\t: %d\n",
  46. cpus_weight(per_cpu(cpu_core_map, n)));
  47. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  48. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  49. }
  50. #endif
  51. /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
  52. fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
  53. seq_printf(m, "fdiv_bug\t: %s\n"
  54. "hlt_bug\t\t: %s\n"
  55. "f00f_bug\t: %s\n"
  56. "coma_bug\t: %s\n"
  57. "fpu\t\t: %s\n"
  58. "fpu_exception\t: %s\n"
  59. "cpuid level\t: %d\n"
  60. "wp\t\t: %s\n"
  61. "flags\t\t:",
  62. c->fdiv_bug ? "yes" : "no",
  63. c->hlt_works_ok ? "no" : "yes",
  64. c->f00f_bug ? "yes" : "no",
  65. c->coma_bug ? "yes" : "no",
  66. c->hard_math ? "yes" : "no",
  67. fpu_exception ? "yes" : "no",
  68. c->cpuid_level,
  69. c->wp_works_ok ? "yes" : "no");
  70. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  71. if ( test_bit(i, c->x86_capability) &&
  72. x86_cap_flags[i] != NULL )
  73. seq_printf(m, " %s", x86_cap_flags[i]);
  74. for (i = 0; i < 32; i++)
  75. if (c->x86_power & (1 << i)) {
  76. if (i < ARRAY_SIZE(x86_power_flags) &&
  77. x86_power_flags[i])
  78. seq_printf(m, "%s%s",
  79. x86_power_flags[i][0]?" ":"",
  80. x86_power_flags[i]);
  81. else
  82. seq_printf(m, " [%d]", i);
  83. }
  84. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  85. c->loops_per_jiffy/(500000/HZ),
  86. (c->loops_per_jiffy/(5000/HZ)) % 100);
  87. seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
  88. return 0;
  89. }
  90. static void *c_start(struct seq_file *m, loff_t *pos)
  91. {
  92. if (*pos == 0) /* just in case, cpu 0 is not the first */
  93. *pos = first_cpu(cpu_online_map);
  94. if ((*pos) < NR_CPUS && cpu_online(*pos))
  95. return &cpu_data(*pos);
  96. return NULL;
  97. }
  98. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  99. {
  100. *pos = next_cpu(*pos, cpu_online_map);
  101. return c_start(m, pos);
  102. }
  103. static void c_stop(struct seq_file *m, void *v)
  104. {
  105. }
  106. const struct seq_operations cpuinfo_op = {
  107. .start = c_start,
  108. .next = c_next,
  109. .stop = c_stop,
  110. .show = show_cpuinfo,
  111. };