Message ID | 20181223225224.23042-1-hauke@hauke-m.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | MIPS: Add CPU option reporting to /proc/cpuinfo | expand |
> On 23 Dec 2018, at 22:52, Hauke Mehrtens <hauke@hauke-m.de> wrote: > > Many MIPS CPUs have optional CPU features which are not activates for > all CPU cores. Print the CPU options which are implemented in the core > in /proc/cpuinfo. This makes it possible to see what features are > supported and which are not supported. This should cover all standard > MIPS extensions, before it only printed information about the main MIPS > ASEs. > > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> > --- Hi Hauke (& lists) Apologies if I speak out of turn and/or ignorance. The problem I have with this is that cpu_has_foo macros can (and often are in openwrt) overridden in by cpu-feature-overrides.h (e.g. arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h) and thus the info shown represents features that the kernel is capable of using and not features that the cpu core is actually capable. As you know we ended up printing cpu config registers to be sure of what the cpu was really (in theory) capable vs features that had been masked out due to overrides (and to cut a very long story short, found them to be the same in the end but they may not have been) Cheers, Kevin D-B 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A
On 12/24/18 10:03 AM, Kevin 'ldir' Darbyshire-Bryant wrote: > > >> On 23 Dec 2018, at 22:52, Hauke Mehrtens <hauke@hauke-m.de> wrote: >> >> Many MIPS CPUs have optional CPU features which are not activates for >> all CPU cores. Print the CPU options which are implemented in the core >> in /proc/cpuinfo. This makes it possible to see what features are >> supported and which are not supported. This should cover all standard >> MIPS extensions, before it only printed information about the main MIPS >> ASEs. >> >> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> >> --- > > Hi Hauke (& lists) > > Apologies if I speak out of turn and/or ignorance. > > The problem I have with this is that cpu_has_foo macros can (and often are in openwrt) overridden in by cpu-feature-overrides.h (e.g. arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h) and thus the info shown represents features that the kernel is capable of using and not features that the cpu core is actually capable. > > As you know we ended up printing cpu config registers to be sure of what the cpu was really (in theory) capable vs features that had been masked out due to overrides (and to cut a very long story short, found them to be the same in the end but they may not have been) Hi Kevin, Normally you should not deactivate any features in cpu-feature-overrides.h which are supported by the CPU, when you do not define any thing the kernel will use auto detection. I think we should use the cpu_has_foo features as these are the features which could be used by user space applications, if it is only accidentally deactivated by the kernel, which should not happen, it could be that this feature is not fully set up by the kernel and will not work. Hauke
> On 24 Dec 2018, at 13:42, Hauke Mehrtens <hauke@hauke-m.de> wrote: > <snip> > Hi Kevin, > > Normally you should not deactivate any features in cpu-feature-overrides.h which are supported by the CPU, when you do not define any thing the kernel will use auto detection. > > I think we should use the cpu_has_foo features as these are the features which could be used by user space applications, if it is only accidentally deactivated by the kernel, which should not happen, it could be that this feature is not fully set up by the kernel and will not work. > > Hauke Fair enough. Kevin
> On 24 Dec 2018, at 14:43, Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> wrote: > > > >> On 24 Dec 2018, at 13:42, Hauke Mehrtens <hauke@hauke-m.de> wrote: >> > <snip> >> Hi Kevin, >> >> Normally you should not deactivate any features in cpu-feature-overrides.h which are supported by the CPU, when you do not define any thing the kernel will use auto detection. >> >> I think we should use the cpu_has_foo features as these are the features which could be used by user space applications, if it is only accidentally deactivated by the kernel, which should not happen, it could be that this feature is not fully set up by the kernel and will not work. >> >> Hauke > > Fair enough. Tried your patch and discovered you need to wrap the cpu_has_mipsmt_pertccounters: +#ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS + if (cpu_has_mipsmt_pertccounters) + seq_printf(m, "%s", " mipsmt_pertccounters"); +#endif otherwise when building for archer c7 v2 (74kc) in openwrt this happens: arch/mips/kernel/proc.c: In function 'show_cpuinfo': arch/mips/kernel/proc.c:245:6: error: 'cpu_has_mipsmt_pertccounters' undeclared (first use in this function); did you mean 'can_use_mips_counter'? if (cpu_has_mipsmt_pertccounters) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ can_use_mips_counter Cheers, Kevin D-B 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A
On 12/25/18 10:35 PM, Kevin 'ldir' Darbyshire-Bryant wrote: > > >> On 24 Dec 2018, at 14:43, Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> wrote: >> >> >> >>> On 24 Dec 2018, at 13:42, Hauke Mehrtens <hauke@hauke-m.de> wrote: >>> >> <snip> >>> Hi Kevin, >>> >>> Normally you should not deactivate any features in cpu-feature-overrides.h which are supported by the CPU, when you do not define any thing the kernel will use auto detection. >>> >>> I think we should use the cpu_has_foo features as these are the features which could be used by user space applications, if it is only accidentally deactivated by the kernel, which should not happen, it could be that this feature is not fully set up by the kernel and will not work. >>> >>> Hauke >> >> Fair enough. > > Tried your patch and discovered you need to wrap the cpu_has_mipsmt_pertccounters: > > +#ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS > + if (cpu_has_mipsmt_pertccounters) > + seq_printf(m, "%s", " mipsmt_pertccounters"); > +#endif > > otherwise when building for archer c7 v2 (74kc) in openwrt this happens: > > arch/mips/kernel/proc.c: In function 'show_cpuinfo': > arch/mips/kernel/proc.c:245:6: error: 'cpu_has_mipsmt_pertccounters' undeclared (first use in this function); did you mean 'can_use_mips_counter'? > if (cpu_has_mipsmt_pertccounters) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > can_use_mips_counter > > > Cheers, > > Kevin D-B > > 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A > Hi Kevin, I do not see any condition based on CONFIG_MIPS_PERF_SHARED_TC_COUNTERS in arch/mips/include/asm/cpu-features.h, which kernel version did you use to test this patch? cpu_has_mipsmt_pertccounters was introduced between kernel 4.14 and 4.19, so it is not available in older kernel versions. Hauke
> On 27 Dec 2018, at 12:39, Hauke Mehrtens <hauke@hauke-m.de> wrote: > >> > Hi Kevin, > > I do not see any condition based on CONFIG_MIPS_PERF_SHARED_TC_COUNTERS in arch/mips/include/asm/cpu-features.h, which kernel version did you use to test this patch? cpu_has_mipsmt_pertccounters was introduced between kernel 4.14 and 4.19, so it is not available in older kernel versions. > > Hauke This is 4.14.90 on openwrt…and I don’t think there are any sneaky backports involved in this area. Take a look around line 131 of arch/mips/kernel/perf_event_mipsxx.c Cheers, Kevin D-B 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A
On 12/27/18 2:08 PM, Kevin 'ldir' Darbyshire-Bryant wrote: > > >> On 27 Dec 2018, at 12:39, Hauke Mehrtens <hauke@hauke-m.de> wrote: >> >>> >> Hi Kevin, >> >> I do not see any condition based on CONFIG_MIPS_PERF_SHARED_TC_COUNTERS in arch/mips/include/asm/cpu-features.h, which kernel version did you use to test this patch? cpu_has_mipsmt_pertccounters was introduced between kernel 4.14 and 4.19, so it is not available in older kernel versions. >> >> Hauke > > > This is 4.14.90 on openwrt…and I don’t think there are any sneaky backports involved in this area. > > Take a look around line 131 of arch/mips/kernel/perf_event_mipsxx.c Hi Kevin, I assume you are talking about this: https://elixir.bootlin.com/linux/v4.19.13/source/arch/mips/kernel/perf_event_mipsxx.c#L131 I still do not get why this is a problem. If code wants to check if a feature is supported it includes "asm/cpu-features.h", this file then includes "cpu-feature-overrides.h". For cpu-feature-overrides.h either the generic and empty version is provided or the SoC code has its own version with some SoC specific settings. The asm/cpu-features.h file checks if the SoC code provided a special settings and if not it will add the code which will detect this feature dynamically, see here: https://elixir.bootlin.com/linux/v4.19.13/source/arch/mips/include/asm/cpu-features.h#L577 This code should provide some settings independently of any Kconfig setting, for some Kconfig settings it is known that it is not active. Hauke
> On 3 Jan 2019, at 21:49, Hauke Mehrtens <hauke@hauke-m.de> wrote: > > On 12/27/18 2:08 PM, Kevin 'ldir' Darbyshire-Bryant wrote: >>> On 27 Dec 2018, at 12:39, Hauke Mehrtens <hauke@hauke-m.de> wrote: >>> >>>> >>> Hi Kevin, >>> >>> I do not see any condition based on CONFIG_MIPS_PERF_SHARED_TC_COUNTERS in arch/mips/include/asm/cpu-features.h, which kernel version did you use to test this patch? cpu_has_mipsmt_pertccounters was introduced between kernel 4.14 and 4.19, so it is not available in older kernel versions. >>> >>> Hauke >> This is 4.14.90 on openwrt…and I don’t think there are any sneaky backports involved in this area. >> Take a look around line 131 of arch/mips/kernel/perf_event_mipsxx.c > > Hi Kevin, > > I assume you are talking about this: > https://elixir.bootlin.com/linux/v4.19.13/source/arch/mips/kernel/perf_event_mipsxx.c#L131 If you look at 4.14.91 https://elixir.bootlin.com/linux/v4.14.91/source/arch/mips/kernel/perf_event_mipsxx.c#L131 > > I still do not get why this is a problem. Hopefully you’ll see why it’s a problem, ‘cos #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS static int cpu_has_mipsmt_pertccounters; So I suspect this is my fault/confusion for trying to backport a feature from 4.19 to 4.14 and trying to flag that case - I’m afraid am very time constrained at the moment and I think the best thing is to ignore me :-) Cheers, Kevin
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index b2de408a259e..f89d52aebe09 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c @@ -130,6 +130,122 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, "micromips kernel\t: %s\n", (read_c0_config3() & MIPS_CONF3_ISA_OE) ? "yes" : "no"); } + + seq_printf(m, "Options implemented\t:"); + if (cpu_has_tlb) + seq_printf(m, "%s", " tlb"); + if (cpu_has_ftlb) + seq_printf(m, "%s", " ftlb"); + if (cpu_has_tlbinv) + seq_printf(m, "%s", " tlbinv"); + if (cpu_has_segments) + seq_printf(m, "%s", " segments"); + if (cpu_has_rixiex) + seq_printf(m, "%s", " rixiex"); + if (cpu_has_ldpte) + seq_printf(m, "%s", " ldpte"); + if (cpu_has_maar) + seq_printf(m, "%s", " maar"); + if (cpu_has_rw_llb) + seq_printf(m, "%s", " rw_llb"); + if (cpu_has_4kex) + seq_printf(m, "%s", " 4kex"); + if (cpu_has_3k_cache) + seq_printf(m, "%s", " 3k_cache"); + if (cpu_has_4k_cache) + seq_printf(m, "%s", " 4k_cache"); + if (cpu_has_6k_cache) + seq_printf(m, "%s", " 6k_cache"); + if (cpu_has_8k_cache) + seq_printf(m, "%s", " 8k_cache"); + if (cpu_has_tx39_cache) + seq_printf(m, "%s", " tx39_cache"); + if (cpu_has_octeon_cache) + seq_printf(m, "%s", " octeon_cache"); + if (cpu_has_fpu) + seq_printf(m, "%s", " fpu"); + if (cpu_has_32fpr) + seq_printf(m, "%s", " 32fpr"); + if (cpu_has_cache_cdex_p) + seq_printf(m, "%s", " cache_cdex_p"); + if (cpu_has_cache_cdex_s) + seq_printf(m, "%s", " cache_cdex_s"); + if (cpu_has_prefetch) + seq_printf(m, "%s", " prefetch"); + if (cpu_has_mcheck) + seq_printf(m, "%s", " mcheck"); + if (cpu_has_ejtag) + seq_printf(m, "%s", " ejtag"); + if (cpu_has_llsc) + seq_printf(m, "%s", " llsc"); + if (cpu_has_bp_ghist) + seq_printf(m, "%s", " bp_ghist"); + if (cpu_has_guestctl0ext) + seq_printf(m, "%s", " guestctl0ext"); + if (cpu_has_guestctl1) + seq_printf(m, "%s", " guestctl1"); + if (cpu_has_guestctl2) + seq_printf(m, "%s", " guestctl2"); + if (cpu_has_guestid) + seq_printf(m, "%s", " guestid"); + if (cpu_has_drg) + seq_printf(m, "%s", " drg"); + if (cpu_has_rixi) + seq_printf(m, "%s", " rixi"); + if (cpu_has_lpa) + seq_printf(m, "%s", " lpa"); + if (cpu_has_mvh) + seq_printf(m, "%s", " mvh"); + if (cpu_has_vtag_icache) + seq_printf(m, "%s", " vtag_icache"); + if (cpu_has_dc_aliases) + seq_printf(m, "%s", " dc_aliases"); + if (cpu_has_ic_fills_f_dc) + seq_printf(m, "%s", " ic_fills_f_dc"); + if (cpu_has_pindexed_dcache) + seq_printf(m, "%s", " pindexed_dcache"); + if (cpu_has_userlocal) + seq_printf(m, "%s", " userlocal"); + if (cpu_has_nofpuex) + seq_printf(m, "%s", " nofpuex"); + if (cpu_has_vint) + seq_printf(m, "%s", " vint"); + if (cpu_has_veic) + seq_printf(m, "%s", " veic"); + if (cpu_has_inclusive_pcaches) + seq_printf(m, "%s", " inclusive_pcaches"); + if (cpu_has_perf_cntr_intr_bit) + seq_printf(m, "%s", " perf_cntr_intr_bit"); + if (cpu_has_ufr) + seq_printf(m, "%s", " ufr"); + if (cpu_has_fre) + seq_printf(m, "%s", " fre"); + if (cpu_has_cdmm) + seq_printf(m, "%s", " cdmm"); + if (cpu_has_small_pages) + seq_printf(m, "%s", " small_pages"); + if (cpu_has_nan_legacy) + seq_printf(m, "%s", " nan_legacy"); + if (cpu_has_nan_2008) + seq_printf(m, "%s", " nan_2008"); + if (cpu_has_ebase_wg) + seq_printf(m, "%s", " ebase_wg"); + if (cpu_has_badinstr) + seq_printf(m, "%s", " badinstr"); + if (cpu_has_badinstrp) + seq_printf(m, "%s", " badinstrp"); + if (cpu_has_contextconfig) + seq_printf(m, "%s", " contextconfig"); + if (cpu_has_perf) + seq_printf(m, "%s", " perf"); + if (cpu_has_shared_ftlb_ram) + seq_printf(m, "%s", " shared_ftlb_ram"); + if (cpu_has_shared_ftlb_entries) + seq_printf(m, "%s", " shared_ftlb_entries"); + if (cpu_has_mipsmt_pertccounters) + seq_printf(m, "%s", " mipsmt_pertccounters"); + seq_printf(m, "\n"); + seq_printf(m, "shadow register sets\t: %d\n", cpu_data[n].srsets); seq_printf(m, "kscratch registers\t: %d\n",
Many MIPS CPUs have optional CPU features which are not activates for all CPU cores. Print the CPU options which are implemented in the core in /proc/cpuinfo. This makes it possible to see what features are supported and which are not supported. This should cover all standard MIPS extensions, before it only printed information about the main MIPS ASEs. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- arch/mips/kernel/proc.c | 116 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)