Message ID | 20140718135738.GA17328@leverpostej |
---|---|
State | New |
Headers | show |
On 18 July 2014 14:57, Mark Rutland <mark.rutland@arm.com> wrote: > Comments are added to guide userspace developers in the right direction > (using the hwcaps provided in auxval). Hopefully where userspace > applications parse /proc/cpuinfo rather than using the readily available > hwcaps, they limit themselves to reading said first line. Comments in the kernel sources aren't going to guide anybody except kernel developers. I was expecting from this commit message that you were going to emit actual comments in /proc/cpuinfo... -- PMM
On Fri, Jul 18, 2014 at 04:52:37PM +0100, Peter Maydell wrote: > On 18 July 2014 14:57, Mark Rutland <mark.rutland@arm.com> wrote: > > Comments are added to guide userspace developers in the right direction > > (using the hwcaps provided in auxval). Hopefully where userspace > > applications parse /proc/cpuinfo rather than using the readily available > > hwcaps, they limit themselves to reading said first line. > > Comments in the kernel sources aren't going to guide > anybody except kernel developers. That's not entirely true, some people skim the kernel sources to figure out how they're meant to use syscalls and such (though admitedly this isn't all that common). > I was expecting from this commit message that you were going to emit > actual comments in /proc/cpuinfo... I don't think that's a good idea, and I can only see that reading when I squint quite hard. ;) Thanks, Mark
On 18 July 2014 16:58, Mark Rutland <mark.rutland@arm.com> wrote: > On Fri, Jul 18, 2014 at 04:52:37PM +0100, Peter Maydell wrote: >> Comments in the kernel sources aren't going to guide >> anybody except kernel developers. > > That's not entirely true, some people skim the kernel sources to figure > out how they're meant to use syscalls and such (though admitedly this > isn't all that common). Every time anybody has to do that it means you've failed to document something... >> I was expecting from this commit message that you were going to emit >> actual comments in /proc/cpuinfo... > > I don't think that's a good idea, and I can only see that reading when I > squint quite hard. ;) You have to admit it would put the documentation right where the people looking at cpuinfo can find it :-) How about a patch to Documentation/filesystems/proc.txt ? thanks -- PMM
On Fri, Jul 18, 2014 at 05:18:27PM +0100, Peter Maydell wrote: > On 18 July 2014 16:58, Mark Rutland <mark.rutland@arm.com> wrote: > > On Fri, Jul 18, 2014 at 04:52:37PM +0100, Peter Maydell wrote: > >> Comments in the kernel sources aren't going to guide > >> anybody except kernel developers. > > > > That's not entirely true, some people skim the kernel sources to figure > > out how they're meant to use syscalls and such (though admitedly this > > isn't all that common). > > Every time anybody has to do that it means you've failed to document > something... ...and in this case, the thing to document is the hwcaps. > >> I was expecting from this commit message that you were going to emit > >> actual comments in /proc/cpuinfo... > > > > I don't think that's a good idea, and I can only see that reading when I > > squint quite hard. ;) > > You have to admit it would put the documentation right where > the people looking at cpuinfo can find it :-) Sure :) > How about a patch to Documentation/filesystems/proc.txt ? Currently there seems to be a single relevant line, and it doesn't seem to be up-to-date for SMP: cpuinfo Info about the CPU It might make sense to have something under Documentation/arm64, but I don't know what precisely. Cheers, Mark.
On 07/18/2014 12:41 PM, Mark Rutland wrote: > On Fri, Jul 18, 2014 at 05:18:27PM +0100, Peter Maydell wrote: >> On 18 July 2014 16:58, Mark Rutland <mark.rutland@arm.com> wrote: >>> On Fri, Jul 18, 2014 at 04:52:37PM +0100, Peter Maydell wrote: >>>> Comments in the kernel sources aren't going to guide >>>> anybody except kernel developers. >>> >>> That's not entirely true, some people skim the kernel sources to figure >>> out how they're meant to use syscalls and such (though admitedly this >>> isn't all that common). >> >> Every time anybody has to do that it means you've failed to document >> something... > > ...and in this case, the thing to document is the hwcaps. > >>>> I was expecting from this commit message that you were going to emit >>>> actual comments in /proc/cpuinfo... >>> >>> I don't think that's a good idea, and I can only see that reading when I >>> squint quite hard. ;) >> >> You have to admit it would put the documentation right where >> the people looking at cpuinfo can find it :-) > > Sure :) > >> How about a patch to Documentation/filesystems/proc.txt ? > > Currently there seems to be a single relevant line, and it doesn't seem > to be up-to-date for SMP: > > cpuinfo Info about the CPU > > It might make sense to have something under Documentation/arm64, but I > don't know what precisely. If you're looking to communicate information to users I would highly recommend including an update to the Linux man page. http://man7.org/linux/man-pages/man5/proc.5.html https://www.kernel.org/doc/man-pages/contributing.html Regards, Christopher
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index edb146d..aaf1ddb 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -450,10 +450,21 @@ 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); + /* + * Dump out the common processor features in a single line. Userspace + * should read the hwcaps with getauxval(AT_HWCAP) rather than + * attempting to parse this. + */ + seq_puts(m, "features\t:"); + for (i = 0; hwcap_str[i]; i++) + if (elf_hwcap & (1 << i)) + seq_printf(m, " %s", hwcap_str[i]); + seq_puts(m, "\n\n"); for_each_online_cpu(i) { + struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i); + u32 midr = cpuinfo->reg_midr; + /* * glibc reads /proc/cpuinfo to determine the number of * online processors, looking for lines beginning with @@ -462,25 +473,13 @@ static int c_show(struct seq_file *m, void *v) #ifdef CONFIG_SMP seq_printf(m, "processor\t: %d\n", i); #endif + seq_printf(m, "implementer\t: 0x%02x\n", + MIDR_IMPLEMENTOR(midr)); + seq_printf(m, "variant\t\t: 0x%x\n", MIDR_VARIANT(midr)); + seq_printf(m, "partnum\t\t: 0x%03x\n", MIDR_PARTNUM(midr)); + seq_printf(m, "revision\t: 0x%x\n\n", MIDR_REVISION(midr)); } - /* 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]); - - 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, "Hardware\t: %s\n", machine_name); - return 0; }