printk timestamp resolution in Linux kernel

1.8k views Asked by At

How to enable timestamp with nanoseconds resolution in linux kernel. Currently it shows in miliseconds resolution as below.

Is there any config or macro that i need to enable??? ....

[    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)

....

1

There are 1 answers

0
benf On

From this Printk Times article in the troubleshooting section;

  • Resolution of timings is very bad.
    • Printk-time uses the routine sched_clock() in the kernel. On some platforms, sched_clock() only has a resolution of 1 jiffy (which may be 10 milliseconds or longer). This means that you will only see the time increment at this resolution, giving imprecise results for printk-times. To correct this problem, the best solution is to implement a good sched_clock() routine for your platform. Sched_clock() returns a 64-bit value which is nanoseconds since some event (usually either since machine power-on, or since time_init() was called.) Many embedded processors have a clock or timer on the System-On-Chip which can provide a good resolution clock source for sched_clock(). It is best if the clock can provide resolution better than 1 microsecond. Note that this only requires a clock running at 1 MHz to achieve this resolution.

It sounds like your platform is using jiffies at 1 ms resolution for sched_clock().