I want detect number of CPUs in linux kernel and write a sys_call that find it.
cpuinfo_x86 gives features of one CPU and cpu_detect fills it but how to find number of CPUs to detect?
I want detect number of CPUs in linux kernel and write a sys_call that find it.
cpuinfo_x86 gives features of one CPU and cpu_detect fills it but how to find number of CPUs to detect?
Using the MACRO NR_CPUS
we can find the number of CPU.
This Macro should not be used in early_init sequence Since mostly NR_CPUS will not be initialized as it is run time macro.
or you can use num_online_cpus()
function to get the number of cpus online.
you can find more options in include/linux/cpumask.h
header to find availability of CPUS in various kinds.
You can use nr_cpu_ids variable which is set by all architectures during kernel boot up and initialization.
Try:
$lscpu
This gives me information about CPUs, as well as architecture, etc...