proc.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. /*
  13. * These flag bits must match the definitions in <asm/cpufeature.h>.
  14. * NULL means this bit is undefined or reserved; either way it doesn't
  15. * have meaning as far as Linux is concerned. Note that it's important
  16. * to realize there is a difference between this table and CPUID -- if
  17. * applications want to get the raw CPUID data, they should access
  18. * /dev/cpu/<cpu_nr>/cpuid instead.
  19. */
  20. static const char * const x86_cap_flags[] = {
  21. /* Intel-defined */
  22. "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
  23. "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
  24. "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
  25. "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
  26. /* AMD-defined */
  27. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  28. NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
  29. NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
  30. NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext", "3dnow",
  31. /* Transmeta-defined */
  32. "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
  33. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  34. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  35. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  36. /* Other (Linux-defined) */
  37. "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
  38. NULL, NULL, NULL, NULL,
  39. "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
  40. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  41. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  42. /* Intel-defined (#2) */
  43. "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
  44. "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
  45. NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
  46. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  47. /* VIA/Cyrix/Centaur-defined */
  48. NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
  49. "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
  50. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  51. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  52. /* AMD-defined (#2) */
  53. "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8legacy", "abm",
  54. "sse4a", "misalignsse",
  55. "3dnowprefetch", "osvw", "ibs", NULL, NULL, NULL, NULL, NULL,
  56. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  57. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  58. };
  59. static const char * const x86_power_flags[] = {
  60. "ts", /* temperature sensor */
  61. "fid", /* frequency id control */
  62. "vid", /* voltage id control */
  63. "ttp", /* thermal trip */
  64. "tm",
  65. "stc",
  66. "100mhzsteps",
  67. "hwpstate",
  68. "", /* constant_tsc - moved to flags */
  69. /* nothing */
  70. };
  71. struct cpuinfo_x86 *c = v;
  72. int i, n = c - cpu_data;
  73. int fpu_exception;
  74. #ifdef CONFIG_SMP
  75. if (!cpu_online(n))
  76. return 0;
  77. #endif
  78. seq_printf(m, "processor\t: %d\n"
  79. "vendor_id\t: %s\n"
  80. "cpu family\t: %d\n"
  81. "model\t\t: %d\n"
  82. "model name\t: %s\n",
  83. n,
  84. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  85. c->x86,
  86. c->x86_model,
  87. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  88. if (c->x86_mask || c->cpuid_level >= 0)
  89. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  90. else
  91. seq_printf(m, "stepping\t: unknown\n");
  92. if ( cpu_has(c, X86_FEATURE_TSC) ) {
  93. unsigned int freq = cpufreq_quick_get(n);
  94. if (!freq)
  95. freq = cpu_khz;
  96. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  97. freq / 1000, (freq % 1000));
  98. }
  99. /* Cache size */
  100. if (c->x86_cache_size >= 0)
  101. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  102. #ifdef CONFIG_X86_HT
  103. if (c->x86_max_cores * smp_num_siblings > 1) {
  104. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  105. seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
  106. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  107. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  108. }
  109. #endif
  110. /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
  111. fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
  112. seq_printf(m, "fdiv_bug\t: %s\n"
  113. "hlt_bug\t\t: %s\n"
  114. "f00f_bug\t: %s\n"
  115. "coma_bug\t: %s\n"
  116. "fpu\t\t: %s\n"
  117. "fpu_exception\t: %s\n"
  118. "cpuid level\t: %d\n"
  119. "wp\t\t: %s\n"
  120. "flags\t\t:",
  121. c->fdiv_bug ? "yes" : "no",
  122. c->hlt_works_ok ? "no" : "yes",
  123. c->f00f_bug ? "yes" : "no",
  124. c->coma_bug ? "yes" : "no",
  125. c->hard_math ? "yes" : "no",
  126. fpu_exception ? "yes" : "no",
  127. c->cpuid_level,
  128. c->wp_works_ok ? "yes" : "no");
  129. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  130. if ( test_bit(i, c->x86_capability) &&
  131. x86_cap_flags[i] != NULL )
  132. seq_printf(m, " %s", x86_cap_flags[i]);
  133. for (i = 0; i < 32; i++)
  134. if (c->x86_power & (1 << i)) {
  135. if (i < ARRAY_SIZE(x86_power_flags) &&
  136. x86_power_flags[i])
  137. seq_printf(m, "%s%s",
  138. x86_power_flags[i][0]?" ":"",
  139. x86_power_flags[i]);
  140. else
  141. seq_printf(m, " [%d]", i);
  142. }
  143. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  144. c->loops_per_jiffy/(500000/HZ),
  145. (c->loops_per_jiffy/(5000/HZ)) % 100);
  146. seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
  147. return 0;
  148. }
  149. static void *c_start(struct seq_file *m, loff_t *pos)
  150. {
  151. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  152. }
  153. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  154. {
  155. ++*pos;
  156. return c_start(m, pos);
  157. }
  158. static void c_stop(struct seq_file *m, void *v)
  159. {
  160. }
  161. struct seq_operations cpuinfo_op = {
  162. .start = c_start,
  163. .next = c_next,
  164. .stop = c_stop,
  165. .show = show_cpuinfo,
  166. };