proc.c 4.8 KB

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