Re: Get number of CPU?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > I am writing a kernel module, and I want to get the number of CPU. If
> > the machine is UP, the value returned will be 1, but if the machine is
> > SMP, the value returned will be the number of CPU available.
> 
> I think NR_CPUS give the number of the cpu in the system. You can use it

NR_CPUS is the max number that kernel supports.
I think num_online_cpus() is what you want.
http://lxr.linux.no/source/include/linux/cpumask.h#L349

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux