On Fri, Nov 11, 2016 at 7:59 AM, Andreas Tobler <andreast-l...@fgznet.ch> wrote: > On 11.11.16 11:06, Richard Earnshaw wrote: >> >> On 11/11/16 02:56, Andrew Pinski wrote: >>> >>> As I mentioned in my other emails, parsing /proc/cpuinfo has one issue >>> is that the current parsing assumes many different things about the >>> format. So the best way to do this is to parse >>> /sys/devices/system/cpu/cpuN/regs/identification/midr_el1 files >>> instead. To get which cpu are present (though not necessarily online) >>> we parse "/sys/devices/system/cpu/present" file. We fall back to >>> parsing /proc/cpu if any parsing fails of these files including not >>> finding out which cpu we are on. The main reason why we fall back is >>> because only newer kernels support exporting this file. To get the >>> features I just look at the hwcap that the kernel passes to userspace >>> so I needed to add an extra argument to AARCH64_OPT_EXTENSION. I also >>> had to define some HWCAP_* macros in driver-aarch64.c since older >>> kernels headers don't have these values defined. >>> >>> It should also be possible to parse >>> /sys/devices/system/cpu/cpu%d/cache%d directory to get cache >>> information too but that is left for another patch and another time. >>> >>> Since I don't have access to a big.LITTLE system, someone should test >>> there with a new enough kernel; I was using stock 4.9.0-rc3. >>> >>> OK? Bootstrapped and tested on ThunderX on aarch64-linux-gnu with no >>> regressions and making sure /proc/cpuinfo is not read (by using >>> strace). >>> >>> Thanks, >>> Andrew Pinski >>> >>> ChangeLog: >>> * config/aarch64/aarch64-option-extensions.def: Document extra >>> argument to AARCH64_OPT_EXTENSION. Update for the extra argument for >>> all of the option extensions. >>> * config/aarch64/driver-aarch64.c: Include sys/auxv.h and asm/hwcap.h. >> >> >> GCC supports native builds on freebsd as well as linux. Isn't this >> going to break that? > > > It will.
I will try to find a machine to install freebsd on it to make sure I don't break it and redo this patch then .. Thanks, Andrew > Andreas > > >> R. >> >>> (HWCAP_CRC32): Define if needed. >>> (HWCAP_ATOMICS): Likewise. >>> (HWCAP_FPHP): Likewise. >>> (HWCAP_ASIMDHP): Likewise. >>> (aarch64_arch_extension): New field hwcap_mask. >>> (AARCH64_OPT_EXTENSION): Handle extra argument. >>> (AARCH64_BIG_LITTLE): Always put the larger core number first. >>> (valid_bL_core_p): Don't check AARCH64_BIG_LITTLE for the opposite >>> order as it already handles the order. >>> (implementor_from_midr): New function. >>> (part_no_from_midr): New function. >>> (sysfsformat): New define. >>> (host_detect_local_cpu_sys): New function. >>> (host_detect_local_cpu): Call host_detect_local_cpu_sys if opening >>> "/sys/devices/system/cpu/present" file worked. >>> * common/config/aarch64/aarch64-common.c (AARCH64_OPT_EXTENSION): >>> Handle extra argument. >>> >> >> >