How to find the physical and logical kernel number in the kernel module?

Are there kernel functions on Linux that return the number of the physical kernel and the logical kernel (in the case of Hyperthreading) on โ€‹โ€‹which the kernel module is running?

+8
linux-kernel hyperthreading kernel-module
source share
1 answer

Look at the end of include/linux/smp.h : smp_processor_id() gives you the number of the current executable CPU. get_cpu() will do the same, and also turn off prevention so that you stay that the processor until put_cpu() is called.

From user space, you can use sched_getcpu() or getcpu() to get the same information.

+9
source share

All Articles