1. printk打印的时间戳
[ 7236.595796] usb 2-1.1: new high-speed USB device number 15 using ehci-platform
static size_t print_time(u64 ts, char *buf) { unsigned long rem_nsec; if (!printk_time) return 0; rem_nsec = do_div(ts, 1000000000); /*ts=ts/1000000000, rem_nsec是余数,单位是ns*/ if (!buf) return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts); return sprintf(buf, "[%5lu.%06lu] ", (unsigned long)ts, rem_nsec / 1000); /*这里显示的是秒.微妙*/ }
2.
原文:https://www.cnblogs.com/hellokitty2/p/10385763.html