Skip to contentSkip to conversation

arm64: clean up /proc/cpuinfo

PATCH New Bjorn Helgaas 3 participants 6 messages Jun 28, 2014 – Jun 30, 2014 arm64

lore
Share & tools
lore
#0 lore raw

cover arm64: clean up /proc/cpuinfo

On arm64, /proc/cpuinfo currently looks like:

    Processor       : AArch64 Processor rev 0 (aarch64)
    processor       : 0
    processor       : 1

...
Features : ...

Compared to most other architectures (including arm), this has an extra "Processor" header, and the "Features" and other bits only appear once, so there's no way to have per-CPU features, variants, etc.

These patches make arm64 more consistent with the other architectures by removing the extra header and printing the CPU ID information for each CPU.

---

Bjorn Helgaas (2):
arm64: add MIDR to per-CPU information
arm64: kernel: update cpuinfo to print all online CPUs features

 arch/arm64/kernel/setup.c |   46 +++++++++++++++++++++++----------------------
 arch/arm64/kernel/smp.c   |    5 +++++
 2 files changed, 28 insertions(+), 23 deletions(-)
#1 lore raw

PATCH 1/2 arm64: add MIDR to per-CPU information

Save the MIDR of each CPU we bring online instead of assuming they're all the same.

Based on e8d432c9cf0a ("ARM: kernel: add MIDR to per-CPU information data").

---
 arch/arm64/kernel/setup.c |   13 +++++++------
 arch/arm64/kernel/smp.c   |    5 +++++
 2 files changed, 12 insertions(+), 6 deletions(-)
arch/arm64/kernel/setup.c +7 -6
index 46d1125571f6..37cc2bb9f3ae 100644
@@ -45,6 +45,7 @@
 #include <linux/efi.h>
 
 #include <asm/fixmap.h>
+#include <asm/cpu.h>
 #include <asm/cputype.h>
 #include <asm/elf.h>
 #include <asm/cputable.h>
@@ -417,16 +418,16 @@ static int __init arm64_device_init(void)
 }
 arch_initcall_sync(arm64_device_init);
 
-static DEFINE_PER_CPU(struct cpu, cpu_data);
+DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data);
 
 static int __init topology_init(void)
 {
-	int i;
+	int cpu;
 
-	for_each_possible_cpu(i) {
-		struct cpu *cpu = &per_cpu(cpu_data, i);
-		cpu->hotpluggable = 1;
-		register_cpu(cpu, i);
+	for_each_possible_cpu(cpu) {
+		struct cpuinfo_arm *cpuinfo = &per_cpu(cpu_data, cpu);
+		cpuinfo->cpu.hotpluggable = 1;
+		register_cpu(&cpuinfo->cpu, cpu);
 	}
 
 	return 0;
arch/arm64/kernel/smp.c +5 -0
index 40f38f46c8e0..c69963496dc6 100644
@@ -39,6 +39,7 @@
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
+#include <asm/cpu.h>
 #include <asm/cputype.h>
 #include <asm/cpu_ops.h>
 #include <asm/mmu_context.h>
@@ -118,6 +119,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
 
 static void smp_store_cpu_info(unsigned int cpuid)
 {
+	struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
+
+	cpu_info->cpuid = read_cpuid_id();
+
 	store_cpu_topology(cpuid);
 }
 
#2 lore raw

PATCH 2/2 arm64: kernel: update cpuinfo to print all online CPUs features

In reply to Bjorn Helgaas

Update the /proc/cpuinfo show function so that it shows the CPU ID of each CPU instead of using the ID of the CPU that happens to be running the code.

Based on b4b8f770eb10 ("ARM: kernel: update cpuinfo to print all online CPUs features").

---
 arch/arm64/kernel/setup.c |   33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
arch/arm64/kernel/setup.c +16 -17
index 37cc2bb9f3ae..dd301ceaa655 100644
@@ -448,10 +448,8 @@ static const char *hwcap_str[] = {
 
 static int c_show(struct seq_file *m, void *v)
 {
-	int i;
-
-	seq_printf(m, "Processor\t: %s rev %d (%s)\n",
-		   cpu_name, read_cpuid_id() & 15, ELF_PLATFORM);
+	int i, j;
+	u32 cpuid;
 
 	for_each_online_cpu(i) {
 		/*
@@ -461,23 +459,24 @@ static int c_show(struct seq_file *m, void *v)
 		 */
 #ifdef CONFIG_SMP
 		seq_printf(m, "processor\t: %d\n", i);
+		cpuid = per_cpu(cpu_data, i).cpuid;
+#else
+		cpuid = read_cpuid_id();
 #endif
-	}
 
-	/* dump out the processor features */
-	seq_puts(m, "Features\t: ");
+		/* dump out the processor features */
+		seq_puts(m, "Features\t: ");
 
-	for (i = 0; hwcap_str[i]; i++)
-		if (elf_hwcap & (1 << i))
-			seq_printf(m, "%s ", hwcap_str[i]);
+		for (i = 0; hwcap_str[i]; i++)
+			if (elf_hwcap & (1 << i))
+				seq_printf(m, "%s ", hwcap_str[i]);
 
-	seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
-	seq_printf(m, "CPU architecture: AArch64\n");
-	seq_printf(m, "CPU variant\t: 0x%x\n", (read_cpuid_id() >> 20) & 15);
-	seq_printf(m, "CPU part\t: 0x%03x\n", (read_cpuid_id() >> 4) & 0xfff);
-	seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
-
-	seq_puts(m, "\n");
+		seq_printf(m, "\nCPU implementer\t: 0x%02x\n", cpuid >> 24);
+		seq_printf(m, "CPU architecture: AArch64\n");
+		seq_printf(m, "CPU variant\t: 0x%x\n", (cpuid >> 20) & 15);
+		seq_printf(m, "CPU part\t: 0x%03x\n", (cpuid >> 4) & 0xfff);
+		seq_printf(m, "CPU revision\t: %d\n\n", cpuid & 15);
+	}
 
 	seq_printf(m, "Hardware\t: %s\n", machine_name);
 
maintainer
#3 lore raw

cover arm64: clean up /proc/cpuinfo

In reply to Bjorn Helgaas

Bjorn,

Quoted 3 lines · Bjorn Helgaas

Bjorn Helgaas (2):
arm64: add MIDR to per-CPU information
arm64: kernel: update cpuinfo to print all online CPUs features

Have you looked at Mark Rutland?s recent cpuinfo patches? There is some overlap and I think they address some of your issues.

Thanks,

Catalin

reviewer
#4 lore raw

cover arm64: clean up /proc/cpuinfo

In reply to Bjorn Helgaas

Hi Bjorn,

Quoted 8 lines · Bjorn Helgaas

On arm64, /proc/cpuinfo currently looks like:

    Processor       : AArch64 Processor rev 0 (aarch64)
    processor       : 0
    processor       : 1

...
Features : ...

Quoted 7 lines

Compared to most other architectures (including arm), this has an extra "Processor" header, and the "Features" and other bits only appear once, so there's no way to have per-CPU features, variants, etc.

These patches make arm64 more consistent with the other architectures by removing the extra header and printing the CPU ID information for each CPU.

This looks very much like the series I've been working on [1,2,3], that reports the MIDR information and performs some additional sanity checking (expecting CPUs to have identical hwcap features).

Did you need this for any reason it particular, or was this just a clean up?

Does my series look OK to you?

Cheers,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/255389.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/264387.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/266973.html

#5 lore raw

cover arm64: clean up /proc/cpuinfo

Quoted 19 lines · Mark Rutland

Hi Bjorn,

Quoted 8 lines · Bjorn Helgaas

On arm64, /proc/cpuinfo currently looks like:

    Processor       : AArch64 Processor rev 0 (aarch64)
    processor       : 0
    processor       : 1

...
Features : ...

Quoted 7 lines

Compared to most other architectures (including arm), this has an extra "Processor" header, and the "Features" and other bits only appear once, so there's no way to have per-CPU features, variants, etc.

These patches make arm64 more consistent with the other architectures by removing the extra header and printing the CPU ID information for each CPU.

Quoted 6 lines

This looks very much like the series I've been working on [1,2,3], that reports the MIDR information and performs some additional sanity checking (expecting CPUs to have identical hwcap features).

Did you need this for any reason it particular, or was this just a clean up?

I want this because /proc/cpuinfo on arm64 is needlessly different from other arches, which causes problems for code that parses it.

Quoted 1 line

Does my series look OK to you?

Yep, yours looks fine to me. Thanks, I wasn't aware of your previous work.

Quoted 6 lines

Cheers,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/255389.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/264387.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/266973.html