Skip to content

Commit b4b8f77

Browse files
author
Lorenzo Pieralisi
committed
ARM: kernel: update cpuinfo to print all online CPUs features
Currently, reading /proc/cpuinfo provides userspace with CPU ID of the CPU carrying out the read from the file. This is fine as long as all CPUs in the system are the same. With the advent of big.LITTLE and heterogenous ARM systems this approach provides user space with incorrect bits of information since CPU ids in the system might differ from the one provided by the CPU reading the file. This patch updates the cpuinfo show function so that a read from /proc/cpuinfo prints HW information for all online CPUs at once, mirroring x86 behaviour. Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Nicolas Pitre <[email protected]>
1 parent e8d432c commit b4b8f77

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

arch/arm/kernel/setup.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -841,58 +841,58 @@ static const char *hwcap_str[] = {
841841

842842
static int c_show(struct seq_file *m, void *v)
843843
{
844-
int i;
845-
846-
seq_printf(m, "Processor\t: %s rev %d (%s)\n",
847-
cpu_name, read_cpuid_id() & 15, elf_platform);
844+
int i, j;
845+
u32 cpuid;
848846

849-
#if defined(CONFIG_SMP)
850847
for_each_online_cpu(i) {
851848
/*
852849
* glibc reads /proc/cpuinfo to determine the number of
853850
* online processors, looking for lines beginning with
854851
* "processor". Give glibc what it expects.
855852
*/
856853
seq_printf(m, "processor\t: %d\n", i);
857-
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n",
854+
cpuid = is_smp() ? per_cpu(cpu_data, i).cpuid : read_cpuid_id();
855+
seq_printf(m, "model name\t: %s rev %d (%s)\n",
856+
cpu_name, cpuid & 15, elf_platform);
857+
858+
#if defined(CONFIG_SMP)
859+
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
858860
per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),
859861
(per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100);
860-
}
861-
#else /* CONFIG_SMP */
862-
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
863-
loops_per_jiffy / (500000/HZ),
864-
(loops_per_jiffy / (5000/HZ)) % 100);
862+
#else
863+
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
864+
loops_per_jiffy / (500000/HZ),
865+
(loops_per_jiffy / (5000/HZ)) % 100);
865866
#endif
867+
/* dump out the processor features */
868+
seq_puts(m, "Features\t: ");
866869

867-
/* dump out the processor features */
868-
seq_puts(m, "Features\t: ");
869-
870-
for (i = 0; hwcap_str[i]; i++)
871-
if (elf_hwcap & (1 << i))
872-
seq_printf(m, "%s ", hwcap_str[i]);
870+
for (j = 0; hwcap_str[j]; j++)
871+
if (elf_hwcap & (1 << j))
872+
seq_printf(m, "%s ", hwcap_str[j]);
873873

874-
seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
875-
seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]);
874+
seq_printf(m, "\nCPU implementer\t: 0x%02x\n", cpuid >> 24);
875+
seq_printf(m, "CPU architecture: %s\n",
876+
proc_arch[cpu_architecture()]);
876877

877-
if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
878-
/* pre-ARM7 */
879-
seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4);
880-
} else {
881-
if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
882-
/* ARM7 */
883-
seq_printf(m, "CPU variant\t: 0x%02x\n",
884-
(read_cpuid_id() >> 16) & 127);
878+
if ((cpuid & 0x0008f000) == 0x00000000) {
879+
/* pre-ARM7 */
880+
seq_printf(m, "CPU part\t: %07x\n", cpuid >> 4);
885881
} else {
886-
/* post-ARM7 */
887-
seq_printf(m, "CPU variant\t: 0x%x\n",
888-
(read_cpuid_id() >> 20) & 15);
882+
if ((cpuid & 0x0008f000) == 0x00007000) {
883+
/* ARM7 */
884+
seq_printf(m, "CPU variant\t: 0x%02x\n",
885+
(cpuid >> 16) & 127);
886+
} else {
887+
/* post-ARM7 */
888+
seq_printf(m, "CPU variant\t: 0x%x\n",
889+
(cpuid >> 20) & 15);
890+
}
891+
seq_printf(m, "CPU part\t: 0x%03x\n",
892+
(cpuid >> 4) & 0xfff);
889893
}
890-
seq_printf(m, "CPU part\t: 0x%03x\n",
891-
(read_cpuid_id() >> 4) & 0xfff);
894+
seq_printf(m, "CPU revision\t: %d\n\n", cpuid & 15);
892895
}
893-
seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
894-
895-
seq_puts(m, "\n");
896896

897897
seq_printf(m, "Hardware\t: %s\n", machine_name);
898898
seq_printf(m, "Revision\t: %04x\n", system_rev);

0 commit comments

Comments
 (0)