blob: af11d31dce0ae0df0b8a15772b2da15059a1871a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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>
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -08006#include <linux/cpufreq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8/*
9 * Get CPU information for use by the procfs.
10 */
11static int show_cpuinfo(struct seq_file *m, void *v)
12{
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 struct cpuinfo_x86 *c = v;
Mike Travis92cb7612007-10-19 20:35:04 +020014 int i, n = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 int fpu_exception;
16
17#ifdef CONFIG_SMP
Mike Travis92cb7612007-10-19 20:35:04 +020018 n = c->cpu_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#endif
20 seq_printf(m, "processor\t: %d\n"
21 "vendor_id\t: %s\n"
22 "cpu family\t: %d\n"
23 "model\t\t: %d\n"
24 "model name\t: %s\n",
25 n,
26 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
27 c->x86,
28 c->x86_model,
29 c->x86_model_id[0] ? c->x86_model_id : "unknown");
30
31 if (c->x86_mask || c->cpuid_level >= 0)
32 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
33 else
34 seq_printf(m, "stepping\t: unknown\n");
35
36 if ( cpu_has(c, X86_FEATURE_TSC) ) {
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -080037 unsigned int freq = cpufreq_quick_get(n);
38 if (!freq)
39 freq = cpu_khz;
Andrew Mortona3a255e2005-06-23 00:08:34 -070040 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -080041 freq / 1000, (freq % 1000));
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 }
43
44 /* Cache size */
45 if (c->x86_cache_size >= 0)
46 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
47#ifdef CONFIG_X86_HT
Siddha, Suresh B94605ef2005-11-05 17:25:54 +010048 if (c->x86_max_cores * smp_num_siblings > 1) {
Rohit Seth4b89aff2006-06-27 02:53:46 -070049 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
Mike Travis08357612007-10-16 01:24:04 -070050 seq_printf(m, "siblings\t: %d\n",
51 cpus_weight(per_cpu(cpu_core_map, n)));
Rohit Seth4b89aff2006-06-27 02:53:46 -070052 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
Siddha, Suresh B94605ef2005-11-05 17:25:54 +010053 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
Andi Kleendb468682005-04-16 15:24:51 -070054 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#endif
56
57 /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
58 fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
59 seq_printf(m, "fdiv_bug\t: %s\n"
60 "hlt_bug\t\t: %s\n"
61 "f00f_bug\t: %s\n"
62 "coma_bug\t: %s\n"
63 "fpu\t\t: %s\n"
64 "fpu_exception\t: %s\n"
65 "cpuid level\t: %d\n"
66 "wp\t\t: %s\n"
67 "flags\t\t:",
68 c->fdiv_bug ? "yes" : "no",
69 c->hlt_works_ok ? "no" : "yes",
70 c->f00f_bug ? "yes" : "no",
71 c->coma_bug ? "yes" : "no",
72 c->hard_math ? "yes" : "no",
73 fpu_exception ? "yes" : "no",
74 c->cpuid_level,
75 c->wp_works_ok ? "yes" : "no");
76
77 for ( i = 0 ; i < 32*NCAPINTS ; i++ )
78 if ( test_bit(i, c->x86_capability) &&
79 x86_cap_flags[i] != NULL )
80 seq_printf(m, " %s", x86_cap_flags[i]);
81
Andi Kleen3f98bc42006-01-11 22:42:51 +010082 for (i = 0; i < 32; i++)
83 if (c->x86_power & (1 << i)) {
84 if (i < ARRAY_SIZE(x86_power_flags) &&
85 x86_power_flags[i])
86 seq_printf(m, "%s%s",
87 x86_power_flags[i][0]?" ":"",
88 x86_power_flags[i]);
89 else
90 seq_printf(m, " [%d]", i);
91 }
92
Andi Kleen770d1322006-12-07 02:14:05 +010093 seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 c->loops_per_jiffy/(500000/HZ),
95 (c->loops_per_jiffy/(5000/HZ)) % 100);
Andi Kleen770d1322006-12-07 02:14:05 +010096 seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
Andi Kleen3dd9d512005-04-16 15:25:15 -070097
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 return 0;
99}
100
101static void *c_start(struct seq_file *m, loff_t *pos)
102{
Mike Travis92cb7612007-10-19 20:35:04 +0200103 if (*pos == 0) /* just in case, cpu 0 is not the first */
Andreas Herrmannc0c52d22007-11-01 19:32:17 +0100104 *pos = first_cpu(cpu_online_map);
105 if ((*pos) < NR_CPUS && cpu_online(*pos))
Mike Travis92cb7612007-10-19 20:35:04 +0200106 return &cpu_data(*pos);
107 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108}
109static void *c_next(struct seq_file *m, void *v, loff_t *pos)
110{
Andreas Herrmannc0c52d22007-11-01 19:32:17 +0100111 *pos = next_cpu(*pos, cpu_online_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 return c_start(m, pos);
113}
114static void c_stop(struct seq_file *m, void *v)
115{
116}
Jan Engelhardt8a45eb32008-01-30 13:33:32 +0100117const struct seq_operations cpuinfo_op = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 .start = c_start,
119 .next = c_next,
120 .stop = c_stop,
121 .show = show_cpuinfo,
122};