proc.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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",
  31. "3dnowext", "3dnow",
  32. /* Transmeta-defined */
  33. "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
  34. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  35. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  36. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  37. /* Other (Linux-defined) */
  38. "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
  39. NULL, NULL, NULL, NULL,
  40. "constant_tsc", "up", NULL, "arch_perfmon",
  41. "pebs", "bts", NULL, "sync_rdtsc",
  42. "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  43. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  44. /* Intel-defined (#2) */
  45. "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
  46. "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
  47. NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
  48. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  49. /* VIA/Cyrix/Centaur-defined */
  50. NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
  51. "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
  52. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  53. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  54. /* AMD-defined (#2) */
  55. "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
  56. "altmovcr8", "abm", "sse4a",
  57. "misalignsse", "3dnowprefetch",
  58. "osvw", "ibs", NULL, NULL, NULL, NULL,
  59. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  60. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  61. /* Auxiliary (Linux-defined) */
  62. "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  63. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  64. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  65. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  66. };
  67. static const char * const x86_power_flags[] = {
  68. "ts", /* temperature sensor */
  69. "fid", /* frequency id control */
  70. "vid", /* voltage id control */
  71. "ttp", /* thermal trip */
  72. "tm",
  73. "stc",
  74. "100mhzsteps",
  75. "hwpstate",
  76. "", /* constant_tsc - moved to flags */
  77. /* nothing */
  78. };
  79. struct cpuinfo_x86 *c = v;
  80. int i, n = c - cpu_data;
  81. int fpu_exception;
  82. #ifdef CONFIG_SMP
  83. if (!cpu_online(n))
  84. return 0;
  85. #endif
  86. seq_printf(m, "processor\t: %d\n"
  87. "vendor_id\t: %s\n"
  88. "cpu family\t: %d\n"
  89. "model\t\t: %d\n"
  90. "model name\t: %s\n",
  91. n,
  92. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  93. c->x86,
  94. c->x86_model,
  95. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  96. if (c->x86_mask || c->cpuid_level >= 0)
  97. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  98. else
  99. seq_printf(m, "stepping\t: unknown\n");
  100. if ( cpu_has(c, X86_FEATURE_TSC) ) {
  101. unsigned int freq = cpufreq_quick_get(n);
  102. if (!freq)
  103. freq = cpu_khz;
  104. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  105. freq / 1000, (freq % 1000));
  106. }
  107. /* Cache size */
  108. if (c->x86_cache_size >= 0)
  109. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  110. #ifdef CONFIG_X86_HT
  111. if (c->x86_max_cores * smp_num_siblings > 1) {
  112. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  113. seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
  114. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  115. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  116. }
  117. #endif
  118. /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
  119. fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
  120. seq_printf(m, "fdiv_bug\t: %s\n"
  121. "hlt_bug\t\t: %s\n"
  122. "f00f_bug\t: %s\n"
  123. "coma_bug\t: %s\n"
  124. "fpu\t\t: %s\n"
  125. "fpu_exception\t: %s\n"
  126. "cpuid level\t: %d\n"
  127. "wp\t\t: %s\n"
  128. "flags\t\t:",
  129. c->fdiv_bug ? "yes" : "no",
  130. c->hlt_works_ok ? "no" : "yes",
  131. c->f00f_bug ? "yes" : "no",
  132. c->coma_bug ? "yes" : "no",
  133. c->hard_math ? "yes" : "no",
  134. fpu_exception ? "yes" : "no",
  135. c->cpuid_level,
  136. c->wp_works_ok ? "yes" : "no");
  137. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  138. if ( test_bit(i, c->x86_capability) &&
  139. x86_cap_flags[i] != NULL )
  140. seq_printf(m, " %s", x86_cap_flags[i]);
  141. for (i = 0; i < 32; i++)
  142. if (c->x86_power & (1 << i)) {
  143. if (i < ARRAY_SIZE(x86_power_flags) &&
  144. x86_power_flags[i])
  145. seq_printf(m, "%s%s",
  146. x86_power_flags[i][0]?" ":"",
  147. x86_power_flags[i]);
  148. else
  149. seq_printf(m, " [%d]", i);
  150. }
  151. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  152. c->loops_per_jiffy/(500000/HZ),
  153. (c->loops_per_jiffy/(5000/HZ)) % 100);
  154. seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
  155. return 0;
  156. }
  157. static void *c_start(struct seq_file *m, loff_t *pos)
  158. {
  159. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  160. }
  161. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  162. {
  163. ++*pos;
  164. return c_start(m, pos);
  165. }
  166. static void c_stop(struct seq_file *m, void *v)
  167. {
  168. }
  169. struct seq_operations cpuinfo_op = {
  170. .start = c_start,
  171. .next = c_next,
  172. .stop = c_stop,
  173. .show = show_cpuinfo,
  174. };