内核模块中计算执行时间

u64 b, e,a;
b = get_cycles();
........
e = get_cycles();
a = e - b 

if (a >= 50000000 * 20)
    pr_info("free cost %llus\n", (e - b) / 50000000);

https://www.ibm.com/developerworks/cn/linux/1307_liuming_linuxtime1/index.html

获取cpu Id可以用函数

smp_processor_id()

 

posted @ 2018-11-29 14:11  行木辛  阅读(684)  评论(0编辑  收藏  举报