proc.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. NULL,
  69. NULL, /* constant_tsc - moved to flags */
  70. /* nothing */
  71. };
  72. struct cpuinfo_x86 *c = v;
  73. int i, n = c - cpu_data;
  74. int fpu_exception;
  75. #ifdef CONFIG_SMP
  76. if (!cpu_online(n))
  77. return 0;
  78. #endif
  79. seq_printf(m, "processor\t: %d\n"
  80. "vendor_id\t: %s\n"
  81. "cpu family\t: %d\n"
  82. "model\t\t: %d\n"
  83. "model name\t: %s\n",
  84. n,
  85. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  86. c->x86,
  87. c->x86_model,
  88. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  89. if (c->x86_mask || c->cpuid_level >= 0)
  90. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  91. else
  92. seq_printf(m, "stepping\t: unknown\n");
  93. if ( cpu_has(c, X86_FEATURE_TSC) ) {
  94. unsigned int freq = cpufreq_quick_get(n);
  95. if (!freq)
  96. freq = cpu_khz;
  97. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  98. freq / 1000, (freq % 1000));
  99. }
  100. /* Cache size */
  101. if (c->x86_cache_size >= 0)
  102. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  103. #ifdef CONFIG_X86_HT
  104. if (c->x86_max_cores * smp_num_siblings > 1) {
  105. seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
  106. seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
  107. seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
  108. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  109. }
  110. #endif
  111. /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
  112. fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
  113. seq_printf(m, "fdiv_bug\t: %s\n"
  114. "hlt_bug\t\t: %s\n"
  115. "f00f_bug\t: %s\n"
  116. "coma_bug\t: %s\n"
  117. "fpu\t\t: %s\n"
  118. "fpu_exception\t: %s\n"
  119. "cpuid level\t: %d\n"
  120. "wp\t\t: %s\n"
  121. "flags\t\t:",
  122. c->fdiv_bug ? "yes" : "no",
  123. c->hlt_works_ok ? "no" : "yes",
  124. c->f00f_bug ? "yes" : "no",
  125. c->coma_bug ? "yes" : "no",
  126. c->hard_math ? "yes" : "no",
  127. fpu_exception ? "yes" : "no",
  128. c->cpuid_level,
  129. c->wp_works_ok ? "yes" : "no");
  130. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  131. if ( test_bit(i, c->x86_capability) &&
  132. x86_cap_flags[i] != NULL )
  133. seq_printf(m, " %s", x86_cap_flags[i]);
  134. for (i = 0; i < 32; i++)
  135. if (c->x86_power & (1 << i)) {
  136. if (i < ARRAY_SIZE(x86_power_flags) &&
  137. x86_power_flags[i])
  138. seq_printf(m, "%s%s",
  139. x86_power_flags[i][0]?" ":"",
  140. x86_power_flags[i]);
  141. else
  142. seq_printf(m, " [%d]", i);
  143. }
  144. seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
  145. c->loops_per_jiffy/(500000/HZ),
  146. (c->loops_per_jiffy/(5000/HZ)) % 100);
  147. seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
  148. return 0;
  149. }
  150. static void *c_start(struct seq_file *m, loff_t *pos)
  151. {
  152. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  153. }
  154. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  155. {
  156. ++*pos;
  157. return c_start(m, pos);
  158. }
  159. static void c_stop(struct seq_file *m, void *v)
  160. {
  161. }
  162. struct seq_operations cpuinfo_op = {
  163. .start = c_start,
  164. .next = c_next,
  165. .stop = c_stop,
  166. .show = show_cpuinfo,
  167. };