diff options
author | Mike Travis <travis@sgi.com> | 2007-10-19 14:35:04 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-19 14:35:04 -0400 |
commit | 92cb7612aee39642d109b8d935ad265e602c0563 (patch) | |
tree | 307f4183226f52418bd6842b5d970f03524ad1c1 /arch/x86/kernel/setup_64.c | |
parent | f1df280f53d7c3ce8613a3b25d1efe009b9860dd (diff) |
x86: convert cpuinfo_x86 array to a per_cpu array
cpu_data is currently an array defined using NR_CPUS. This means that
we overallocate since we will rarely really use maximum configured cpus.
When NR_CPU count is raised to 4096 the size of cpu_data becomes
3,145,728 bytes.
These changes were adopted from the sparc64 (and ia64) code. An
additional field was added to cpuinfo_x86 to be a non-ambiguous cpu
index. This corresponds to the index into a cpumask_t as well as the
per_cpu index. It's used in various places like show_cpuinfo().
cpu_data is defined to be the boot_cpu_data structure for the NON-SMP
case.
Signed-off-by: Mike Travis <travis@sgi.com>
Acked-by: Christoph Lameter <clameter@sgi.com>
Cc: Andi Kleen <ak@suse.de>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/setup_64.c')
-rw-r--r-- | arch/x86/kernel/setup_64.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index 94630c66470e..0f0d9d4a6650 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -534,7 +534,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c) | |||
534 | but in the same order as the HT nodeids. | 534 | but in the same order as the HT nodeids. |
535 | If that doesn't result in a usable node fall back to the | 535 | If that doesn't result in a usable node fall back to the |
536 | path for the previous case. */ | 536 | path for the previous case. */ |
537 | int ht_nodeid = apicid - (cpu_data[0].phys_proc_id << bits); | 537 | int ht_nodeid = apicid - (cpu_data(0).phys_proc_id << bits); |
538 | if (ht_nodeid >= 0 && | 538 | if (ht_nodeid >= 0 && |
539 | apicid_to_node[ht_nodeid] != NUMA_NO_NODE) | 539 | apicid_to_node[ht_nodeid] != NUMA_NO_NODE) |
540 | node = apicid_to_node[ht_nodeid]; | 540 | node = apicid_to_node[ht_nodeid]; |
@@ -858,6 +858,7 @@ void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c) | |||
858 | 858 | ||
859 | #ifdef CONFIG_SMP | 859 | #ifdef CONFIG_SMP |
860 | c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff; | 860 | c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff; |
861 | c->cpu_index = 0; | ||
861 | #endif | 862 | #endif |
862 | } | 863 | } |
863 | 864 | ||
@@ -964,6 +965,7 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) | |||
964 | static int show_cpuinfo(struct seq_file *m, void *v) | 965 | static int show_cpuinfo(struct seq_file *m, void *v) |
965 | { | 966 | { |
966 | struct cpuinfo_x86 *c = v; | 967 | struct cpuinfo_x86 *c = v; |
968 | int cpu = 0; | ||
967 | 969 | ||
968 | /* | 970 | /* |
969 | * These flag bits must match the definitions in <asm/cpufeature.h>. | 971 | * These flag bits must match the definitions in <asm/cpufeature.h>. |
@@ -1042,8 +1044,9 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1042 | 1044 | ||
1043 | 1045 | ||
1044 | #ifdef CONFIG_SMP | 1046 | #ifdef CONFIG_SMP |
1045 | if (!cpu_online(c-cpu_data)) | 1047 | if (!cpu_online(c->cpu_index)) |
1046 | return 0; | 1048 | return 0; |
1049 | cpu = c->cpu_index; | ||
1047 | #endif | 1050 | #endif |
1048 | 1051 | ||
1049 | seq_printf(m,"processor\t: %u\n" | 1052 | seq_printf(m,"processor\t: %u\n" |
@@ -1051,7 +1054,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1051 | "cpu family\t: %d\n" | 1054 | "cpu family\t: %d\n" |
1052 | "model\t\t: %d\n" | 1055 | "model\t\t: %d\n" |
1053 | "model name\t: %s\n", | 1056 | "model name\t: %s\n", |
1054 | (unsigned)(c-cpu_data), | 1057 | (unsigned)cpu, |
1055 | c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown", | 1058 | c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown", |
1056 | c->x86, | 1059 | c->x86, |
1057 | (int)c->x86_model, | 1060 | (int)c->x86_model, |
@@ -1063,7 +1066,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1063 | seq_printf(m, "stepping\t: unknown\n"); | 1066 | seq_printf(m, "stepping\t: unknown\n"); |
1064 | 1067 | ||
1065 | if (cpu_has(c,X86_FEATURE_TSC)) { | 1068 | if (cpu_has(c,X86_FEATURE_TSC)) { |
1066 | unsigned int freq = cpufreq_quick_get((unsigned)(c-cpu_data)); | 1069 | unsigned int freq = cpufreq_quick_get((unsigned)cpu); |
1067 | if (!freq) | 1070 | if (!freq) |
1068 | freq = cpu_khz; | 1071 | freq = cpu_khz; |
1069 | seq_printf(m, "cpu MHz\t\t: %u.%03u\n", | 1072 | seq_printf(m, "cpu MHz\t\t: %u.%03u\n", |
@@ -1076,7 +1079,6 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1076 | 1079 | ||
1077 | #ifdef CONFIG_SMP | 1080 | #ifdef CONFIG_SMP |
1078 | if (smp_num_siblings * c->x86_max_cores > 1) { | 1081 | if (smp_num_siblings * c->x86_max_cores > 1) { |
1079 | int cpu = c - cpu_data; | ||
1080 | seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); | 1082 | seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); |
1081 | seq_printf(m, "siblings\t: %d\n", | 1083 | seq_printf(m, "siblings\t: %d\n", |
1082 | cpus_weight(per_cpu(cpu_core_map, cpu))); | 1084 | cpus_weight(per_cpu(cpu_core_map, cpu))); |
@@ -1134,12 +1136,16 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1134 | 1136 | ||
1135 | static void *c_start(struct seq_file *m, loff_t *pos) | 1137 | static void *c_start(struct seq_file *m, loff_t *pos) |
1136 | { | 1138 | { |
1137 | return *pos < NR_CPUS ? cpu_data + *pos : NULL; | 1139 | if (*pos == 0) /* just in case, cpu 0 is not the first */ |
1140 | *pos = first_cpu(cpu_possible_map); | ||
1141 | if ((*pos) < NR_CPUS && cpu_possible(*pos)) | ||
1142 | return &cpu_data(*pos); | ||
1143 | return NULL; | ||
1138 | } | 1144 | } |
1139 | 1145 | ||
1140 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | 1146 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
1141 | { | 1147 | { |
1142 | ++*pos; | 1148 | *pos = next_cpu(*pos, cpu_possible_map); |
1143 | return c_start(m, pos); | 1149 | return c_start(m, pos); |
1144 | } | 1150 | } |
1145 | 1151 | ||