dmesg 和 journalctl -k 之间的时间差异

dmesg 和 journalctl -k 之间的时间差异

编辑:我无法弄清楚为什么会发生这种奇怪的效果,但我发现实际问题(启动缓慢)的罪魁祸首与此处描述的相同:https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1763611

由于问题仍然存在,我将保持其开放态度。


我正在尝试分析一位朋友的笔记本电脑“突然”变慢的启动时间。

dmesg向我展示了这个:

[    2.348642] usb 1-8: New USB device found, idVendor=0bda, idProduct=0129
[    2.348644] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    2.348645] usb 1-8: Product: USB2.0-CRW
[    2.348646] usb 1-8: Manufacturer: Generic
[    2.348648] usb 1-8: SerialNumber: 20100201396000000
[    2.352517] usbcore: registered new interface driver rtsx_usb
[    2.844331] [drm] RC6 on
[   34.760930] EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
[   34.933397] ip_tables: (C) 2000-2006 Netfilter Core Team
[   35.006893] systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)

这也证实了手动测量和输出,systemd-analyze即笔记本电脑在内核中花费大约 35 秒进行启动,用户中剩余的 ~12 秒是由于某个单元等待 NetworkManager 上线 —— 但这些时间在这里并不重要。无论如何,使用 SSD 的笔记本电脑不应该花这么长时间进行启动,尤其是安装文件系统时。

我也跑journalctl -k应该给出相同的输出,但我得到:

Aug 30 21:13:45 laptop kernel: usb 1-8: New USB device found, idVendor=0bda, idProduct=0129
Aug 30 21:13:45 laptop kernel: usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 30 21:13:45 laptop kernel: usb 1-8: Product: USB2.0-CRW
Aug 30 21:13:45 laptop kernel: usb 1-8: Manufacturer: Generic
Aug 30 21:13:45 laptop kernel: usb 1-8: SerialNumber: 20100201396000000
Aug 30 21:13:45 laptop kernel: usbcore: registered new interface driver rtsx_usb
Aug 30 21:13:45 laptop kernel: [drm] RC6 on
Aug 30 21:13:45 laptop kernel: EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
Aug 30 21:13:45 laptop kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Aug 30 21:13:45 laptop systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)

journalctl...所以从s 角度来看不存在这样的时间差距。

我不知道这个时差是从何而来的。

答案1

要使用 journalctl 获取与 dmesg 相同的时间戳格式,请尝试

journalctl -o short-monotonic -b

journalctl 的示例输出

...
[    1.003458] marvin kernel: usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.003460] marvin kernel: usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.003461] marvin kernel: usb usb1: Product: xHCI Host Controller
[    1.003462] marvin kernel: usb usb1: Manufacturer: Linux 4.15.0-33-generic xhci-hcd
[    1.003463] marvin kernel: usb usb1: SerialNumber: 0000:00:14.0
[    1.003596] marvin kernel: hub 1-0:1.0: USB hub found
[    1.003611] marvin kernel: hub 1-0:1.0: 16 ports detected
[    1.004505] marvin kernel: xhci_hcd 0000:00:14.0: xHCI Host Controller
[    1.004507] marvin kernel: xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 2
[    1.004510] marvin kernel: xhci_hcd 0000:00:14.0: Host supports USB 3.0  SuperSpeed
[    1.004533] marvin kernel: usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[    1.004535] marvin kernel: usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.004536] marvin kernel: usb usb2: Product: xHCI Host Controller
[    1.004537] marvin kernel: usb usb2: Manufacturer: Linux 4.15.0-33-generic xhci-hcd
[    1.004538] marvin kernel: usb usb2: SerialNumber: 0000:00:14.0
...

与 dmesg 的相同输出相比

...
[    1.003458] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.003460] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.003461] usb usb1: Product: xHCI Host Controller
[    1.003462] usb usb1: Manufacturer: Linux 4.15.0-33-generic xhci-hcd
[    1.003463] usb usb1: SerialNumber: 0000:00:14.0
[    1.003596] hub 1-0:1.0: USB hub found
[    1.003611] hub 1-0:1.0: 16 ports detected
[    1.004505] xhci_hcd 0000:00:14.0: xHCI Host Controller
[    1.004507] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 2
[    1.004510] xhci_hcd 0000:00:14.0: Host supports USB 3.0  SuperSpeed
[    1.004533] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[    1.004535] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.004536] usb usb2: Product: xHCI Host Controller
[    1.004537] usb usb2: Manufacturer: Linux 4.15.0-33-generic xhci-hcd
[    1.004538] usb usb2: SerialNumber: 0000:00:14.0
...

相关内容