kernel space插入time stub函数来查看当前时间,也可以用于测量code执行的时间

xiaoxiao2021-02-28  94

在kernel中有时候需要code总插一些函数来看某段code执行的时间,可以参考下面的code #ifdef DEBUG_TIMING void debug_timestamp(char *msg) {     struct timespec64 t;     getnstimeofday64(&t);     pr_debug("**%s: %lld.%9.9ld\n", msg, (long long) t.tv_sec, t.tv_nsec); } #else #define debug_timestamp(x) #endif 具体用法        debug_timestamp("Start2"); 可以很方便的在kernel打印的log 中grep 关键字Start2 来找到自己关心内容执行的时间。如果在正式release 版本中只要关掉DEBUG_TIMING即可,不用修改原有的code逻辑。
转载请注明原文地址: https://www.6miu.com/read-69280.html

最新回复(0)