How to find physical and logical core number in a kernel module?

后端 未结 1 1503
迷失自我
迷失自我 2021-01-17 22:49

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

相关标签:
1条回答
  • 2021-01-17 23:19

    Have a look at the end of include/linux/smp.h: smp_processor_id() gives you the number of the current executing CPU. get_cpu() will do the same and will also disable preemption so that you will stay on that CPU until put_cpu() is called.

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

    0 讨论(0)
提交回复
热议问题