dmesg命令是Linux系统下一个非常常用的命令。其用于输出Linux系统启动时的内核环境信息,主要用于问题诊断和系统调试。
使用dmesg命令可以查看各个系统组件启动时所输出的信息,例如CPU、内存、设备驱动、网络、文件系统等等。通过dmesg命令可以获取(system log)系统日志记录的所有信息,但只有内核数据,可以帮助诊断系统故障、调试应用程序、排除内核相关的问题和监控系统运行状态等等。
dmesg 命令是一个非常强大且广泛使用的命令,在 Linux 命令行中经常会用到。
当我们在终端中执行dmesg命令时,将会输出大量的系统启动时的内核信息。下面是一些示例:
1. 显示内核启动信息
执行dmesg命令,可以看到系统启动时内核输出的大量信息,包括内存、CPU、硬件设备等信息。
dmesg
输出示例:
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.15.0-55-generic (buildd@lgw01-amd64-033) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 (Ubuntu 4.15.0-55.60-generic 4.15.18)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-55-generic root=UUID=ec7f0036-5f4d-4fd6-88cb-ecc9f513ff65 ro quiet splash vt.handoff=1
......
2. 查看设备驱动信息
执行dmesg命令,可以查看设备驱动的信息,例如USB设备的插拔信息。
dmesg | grep usb
输出示例:
[ 145.913981] usb 1-1.3.4: new high-speed USB device number 6 using ehci-pci
[ 146.001009] usb 1-1.3.4: New USB device found, idVendor=0781, idProduct=5591
[ 146.001011] usb 1-1.3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 146.001012] usb 1-1.3.4: Product: Cruzer Fit
[ 146.001014] usb 1-1.3.4: Manufacturer: SanDisk
[ 146.001014] usb 1-1.3.4: SerialNumber: 4C530001111122217540
3. 查看内存信息
执行dmesg命令,可以查看系统内存的信息。
dmesg | grep Memory
输出示例:
[ 0.000000] Memory: 4039492K/4159480K available (12300K kernel code, 2475K rwdata, 4220K rodata, 2404K init, 2412K bss, 119988K reserved, 0K cma-reserved)
[ 0.000000] Memory: 3113948K/3196284K available (11891K kernel code, 2475K rwdata, 4028K rodata, 2380K init, 2412K bss, 82336K reserved, 0K cma-reserved)
4. 查看系统时间戳信息
执行dmesg命令,可以查看系统时间戳的信息,包括每个消息的时间戳和系统启动的时间戳。
dmesg | grep timestamp
输出示例:
[ 0.000000] tsc: Detected 2992.820 MHz processor
[ 0.361835] rtc_cmos 00:01: RTC can wake from S4
[ 0.363143] rtc_cmos 00:01: rtc core: registered rtc_cmos as rtc0
[ 1.059927] ata2.00: ATA-9: ST500LT012-9WS142, SDM1, max UDMA/133
[ 1.059932] ata2.00: 976773168 sectors, multi 16: LBA48 NCQ (depth 31/32), AA
[ 5725.515031] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
这些示例只是dmesg命令输出信息的一小部分,更多的信息可以通过在终端中执行dmesg命令自行查看。
[9900486.863068] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Size:0x0
[9900486.863070] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Type:9
[9900486.863071] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Used:1
[9900486.863076] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Allocating Memory Bank: HOST[0]
[9900486.863077] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: base_addr:0x2000000000, total size:0x400000000
[9900486.863079] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Found a new memory region
[9900486.863138] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: drm_mm_init called for the available memory range
[9900486.863141] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: ret 0
[9900486.863165] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[0] start
[9900486.863173] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[1] start
[9900486.863180] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[2] start
[9900486.863187] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[3] start
[9900486.863195] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[4] start
[9900486.863203] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[5] start
[9900486.863210] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[6] start
[9900486.863218] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[7] start
[9900486.863226] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[8] start
[9900486.863234] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[9] start
[9900486.863242] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_read_axlf_helper: Loaded xclbin 92f649c5-596b-d717-8bda-3ebafad74703
[9900486.863242] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[10] start
[9900487.024150] xocl 0000:b3:00.1: icap.u.22020096 ffff9a63d0ad3c10 icap_lock_bitstream: bitstream 92f649c5-596b-d717-8bda-3ebafad74703 locked, ref=1
[9900487.024156] xocl 0000:b3:00.1: ffff9a63debb7098 kds_add_context: Client pid(56773) add context Domain(0) CU(0x6) shared(true)
[9900487.024199] xocl 0000:b3:00.1: ffff9a63debb7098 kds_add_context: Client pid(56773) add context Domain(0) CU(0x9) shared(true)
[9900487.024218] xocl 0000:b3:00.1: ffff9a63debb7098 kds_add_context: Client pid(56773) add context Domain(0) CU(0x2) shared(true)
这段dmesg输出结果是来自xocl模块的信息。xocl是一种为FPGA提供OpenCL接口的内核模块。下面逐行解释每个输出:
[9900486.863068] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Size:0x0
: 显示xocl模块初始化内存时的信息,Size为0x0,表示内存大小为0。[9900486.863070] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Type:9
: 显示内存类型为9,常用内存类型有0(DDR)、1(HBM)等。[9900486.863071] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Used:1
: 显示已使用的内存为1,表示某些内存已经被分配。[9900486.863076] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Allocating Memory Bank: HOST[0]
: 显示正在分配Memory Bank,该内存为HOST[0]。[9900486.863077] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: base_addr:0x2000000000, total size:0x400000000
: 显示分配的内存地址和总大小。[9900486.863079] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: Found a new memory region
: 显示发现了新的内存区域。[9900486.863138] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: drm_mm_init called for the available memory range
: 显示调用drm_mm_init来初始化可用内存范围。[9900486.863141] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_init_mem: ret 0
: 显示在初始化内存时返回值为0,表示初始化成功。[9900486.863165] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[0] start
: 显示xrt_cu_intr_thread线程开始执行。[9900486.863173] xocl 0000:b3:00.1: ffff9a63debb7098 xrt_cu_intr_thread: CU[1] start
: 类似第9行,显示不同的CU的线程开始执行。[9900486.863242] xocl 0000:b3:00.1: ffff9a63debb7098 xocl_read_axlf_helper: Loaded xclbin 92f649c5-596b-d717-8bda-3ebafad74703
: 显示xclbin文件被加载到FPGA上。[9900487.024150] xocl 0000:b3:00.1: icap.u.22020096 ffff9a63d0ad3c10 icap_lock_bitstream: bitstream 92f649c5-596b-d717-8bda-3ebafad74703 locked, ref=1
: 显示已经锁定了xclbin文件,ref=1表示被一个客户端使用。[9900487.024156] xocl 0000:b3:00.1: ffff9a63debb7098 kds_add_context: Client pid(56773) add context Domain(0) CU(0x6) shared(true)
: 显示xocl为pid为56773的客户端添加了一个上下文,该上下文适用于Domain 0,CU为0x6,shared为true。- 类似于第13行,显示为不同的客户端添加了不同的上下文。
总的来说,这段输出是xocl模块初始化过程中的信息,包括FPGA内存分配,xclbin文件加载等。通过dmesg命令查看这些信息,可以帮助我们分析和诊断FPGA相关的问题。