Re: [PATCH v1] arch/x86: port I/O tracing on x86

From: Dan Raymond
Date: Tue Sep 19 2023 - 20:33:20 EST


This feature can also be used with boot-time tracing by adding
"trace_event=portio" to the kernel command line. This will show,
for example, what port accesses were performed by the UART driver
when it loaded:

# dmesg | grep 16550
[ 0.395213] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.395487] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 0.395886] 00:04: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
# cat /sys/kernel/tracing/trace | grep 'port=0x02f'
init-1 [000] d..1. 0.399132: portio_read: port=0x02f9 value=0x00 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399138: portio_write: port=0x02f9 value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399143: portio_read: port=0x02f9 value=0x00 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399145: portio_write: port=0x02f9 value=0x0f io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399151: portio_read: port=0x02f9 value=0x0f io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399152: portio_write: port=0x02f9 value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399154: portio_read: port=0x02fc value=0x00 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399156: portio_read: port=0x02fb value=0x00 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399158: portio_write: port=0x02fb value=0xbf io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399160: portio_write: port=0x02fa value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399162: portio_write: port=0x02fb value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399163: portio_write: port=0x02fa value=0x01 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399165: portio_read: port=0x02fa value=0xc1 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399167: portio_write: port=0x02fb value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399169: portio_write: port=0x02fc value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399171: portio_write: port=0x02fa value=0x01 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399173: portio_write: port=0x02fa value=0x07 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399175: portio_write: port=0x02fa value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399176: portio_read: port=0x02f8 value=0x00 io_serial_in+0x0/0x80
init-1 [000] d..1. 0.399178: portio_write: port=0x02f9 value=0x00 io_serial_out+0x0/0x40
init-1 [000] d..1. 0.399203: portio_write: port=0x02fc value=0x00 io_serial_out+0x0/0x40