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

故事扮演 提交于 2020-01-11 08:16:28

问题


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:


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.



来源:https://stackoverflow.com/questions/7315907/how-to-find-physical-and-logical-core-number-in-a-kernel-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!