Commit c0c52d28 authored by Andreas Herrmann's avatar Andreas Herrmann Committed by Thomas Gleixner

x86: show cpuinfo only for online CPUs

Fix regressions introduced with 92cb7612.

It can happen that cpuinfo is displayed for CPUs that are not online or
even worse for CPUs not present at all. As an example, following was
shown for a "second" CPU of a single core K8 variant:

    processor       : 0
    vendor_id       : unknown
    cpu family      : 0
    model           : 0
    model name      : unknown
    stepping        : 0
    cache size      : 0 KB
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 0
    wp              : yes
    flags           :
    bogomips        : 0.00
    clflush size    : 0
    cache_alignment : 0
    address sizes   : 0 bits physical, 0 bits virtual
    power management:
Signed-off-by: default avatarAndreas Herrmann <andreas.herrmann3@amd.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 90367556
...@@ -89,8 +89,6 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -89,8 +89,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
int fpu_exception; int fpu_exception;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (!cpu_online(n))
return 0;
n = c->cpu_index; n = c->cpu_index;
#endif #endif
seq_printf(m, "processor\t: %d\n" seq_printf(m, "processor\t: %d\n"
...@@ -177,14 +175,14 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -177,14 +175,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
static void *c_start(struct seq_file *m, loff_t *pos) static void *c_start(struct seq_file *m, loff_t *pos)
{ {
if (*pos == 0) /* just in case, cpu 0 is not the first */ if (*pos == 0) /* just in case, cpu 0 is not the first */
*pos = first_cpu(cpu_possible_map); *pos = first_cpu(cpu_online_map);
if ((*pos) < NR_CPUS && cpu_possible(*pos)) if ((*pos) < NR_CPUS && cpu_online(*pos))
return &cpu_data(*pos); return &cpu_data(*pos);
return NULL; return NULL;
} }
static void *c_next(struct seq_file *m, void *v, loff_t *pos) static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{ {
*pos = next_cpu(*pos, cpu_possible_map); *pos = next_cpu(*pos, cpu_online_map);
return c_start(m, pos); return c_start(m, pos);
} }
static void c_stop(struct seq_file *m, void *v) static void c_stop(struct seq_file *m, void *v)
......
...@@ -1078,8 +1078,6 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -1078,8 +1078,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (!cpu_online(c->cpu_index))
return 0;
cpu = c->cpu_index; cpu = c->cpu_index;
#endif #endif
...@@ -1171,15 +1169,15 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -1171,15 +1169,15 @@ static int show_cpuinfo(struct seq_file *m, void *v)
static void *c_start(struct seq_file *m, loff_t *pos) static void *c_start(struct seq_file *m, loff_t *pos)
{ {
if (*pos == 0) /* just in case, cpu 0 is not the first */ if (*pos == 0) /* just in case, cpu 0 is not the first */
*pos = first_cpu(cpu_possible_map); *pos = first_cpu(cpu_online_map);
if ((*pos) < NR_CPUS && cpu_possible(*pos)) if ((*pos) < NR_CPUS && cpu_online(*pos))
return &cpu_data(*pos); return &cpu_data(*pos);
return NULL; return NULL;
} }
static void *c_next(struct seq_file *m, void *v, loff_t *pos) static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{ {
*pos = next_cpu(*pos, cpu_possible_map); *pos = next_cpu(*pos, cpu_online_map);
return c_start(m, pos); return c_start(m, pos);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment