【问题标题】:printk timestamp resolution in Linux kernelLinux内核中的printk时间戳解析
【发布时间】:2013-09-09 06:33:29
【问题描述】:

如何在 linux 内核中启用具有纳秒分辨率的时间戳。 目前它以毫秒为单位显示如下。

我需要启用任何配置或宏吗??? ....

[    0.220000] omap_mux_init: Add partition: #1: core, flags: 4
[    0.220000] ti81xx_register_mcasp: platform not supported
[    0.230000] Debugfs: Only enabling/disabling deep sleep and wakeup timer is supported now
[    0.230000] bio: create slab <bio-0> at 0
[    0.230000] SCSI subsystem initialized
[    0.230000] usbcore: registered new interface driver usbfs
[    0.230000] usbcore: registered new interface driver hub
[    0.230000] usbcore: registered new device driver usb
[    0.230000] omap_i2c omap_i2c.1: bus 1 rev4.0 at 100 kHz
[    0.260000] omap_i2c omap_i2c.2: bus 2 rev4.0 at 100 kHz
[    0.280000] omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz
[    0.300000] omap_i2c omap_i2c.4: bus 4 rev4.0 at 100 kHz
[    0.300000] Switching to clocksource gp timer
[    0.310000] musb-hdrc: version 6.0, otg (peripheral+host), debug=0
[    0.310000] NET: Registered protocol family 2
[    0.310000] IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.310000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.310000] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
[    0.310000] TCP: Hash tables configured (established 16384 bind 16384)
[    0.310000] TCP reno registered
[    0.310000] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.310000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.310000] NET: Registered protocol family 1
[    0.310000] RPC: Registered udp transport module.
[    0.310000] RPC: Registered tcp transport module.
[    0.310000] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.310000] Trying to unpack rootfs image as initramfs...
[    0.310000] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.330000] Freeing initrd memory: 3660K
[    0.330000] NetWinder Floating Point Emulator V0.97 (double precision)

....

【问题讨论】:

    标签: linux debugging printk


    【解决方案1】:

    来自故障排除部分的这篇Printk Times 文章;

    • 时间分辨率很差。
      • Printk-time 使用内核中的例程 sched_clock()。在某些平台上,sched_clock() 的分辨率只有 1 jiffy(可能是 10 毫秒或更长)。这意味着您将只能看到此分辨率下的时间增量,从而为 printk-times 提供不精确的结果。要纠正这个问题,最好的解决方案是为您的平台实现一个好的 sched_clock() 例程。 Sched_clock() 返回一个 64 位值,该值是自某个事件以来的纳秒(通常是自机器上电以来,或自调用 time_init() 以来)。许多嵌入式处理器在片上系统上有一个时钟或计时器,它可以为 sched_clock() 提供良好的分辨率时钟源。时钟最好能提供优于 1 微秒的分辨率。请注意,这只需要运行在 1 MHz 的时钟即可实现此分辨率。

    听起来您的平台正在为 sched_clock() 使用分辨率为 1 毫秒的 jiffies。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-08
      • 1970-01-01
      • 1970-01-01
      • 2017-06-07
      • 1970-01-01
      • 2015-12-08
      • 2014-05-24
      • 1970-01-01
      相关资源
      最近更新 更多