Re: [PATCH v2 2/5] usb: serial: removing redundant __func__

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 15, 2016 at 10:45:36AM +0200, Oliver Neukum wrote:
> On Fri, 2016-07-15 at 08:14 +0900, Greg KH wrote:
> > Doh, nevermind, that's what I get for writing emails early in the
> > morning while jet-lagged.
> > 
> > Sorry for the noise, you are correct.
> 
> No problem. Do you want me to resubmit?

No need.

I know a func-prefix is technically redundant, but the two alternatives
are not equivalent in my opinion.

I find the dev_dbg way of slapping the function name at the start of
every debug message makes for unnecessarily hard-to-parse logs.

Here's an example:


[   50.500823] tty ttyUSB0: serial_open
[   50.505401] ftdi_sio ttyUSB0: Setting CS8
[   50.513275] ftdi_sio ttyUSB0: get_ftdi_divisor - tty_get_baud_rate reports speed 9600
[   50.521728] ftdi_sio ttyUSB0: get_ftdi_divisor - Baud rate set to 9600 (divisor 0x4138) on chip FT232RL
[   50.532989] ftdi_sio ttyUSB0: ftdi_set_termios Turning off hardware flow control
[   50.543029] ftdi_sio ttyUSB0: update_mctrl - DTR HIGH, RTS HIGH
[   50.549926] tty ttyUSB0: serial_write_room
[   50.555328] ftdi_sio ttyUSB0: usb_serial_generic_write_room - returns 4096
[   50.563354] tty ttyUSB0: serial_write - 3 byte(s)
[   50.569091] tty ttyUSB0: serial_write_room
[   50.574127] ftdi_sio ttyUSB0: usb_serial_generic_write_room - returns 4096
[   50.582000] tty ttyUSB0: serial_write - 2 byte(s)
[   50.587799] tty ttyUSB0: serial_close
[   50.592468] tty ttyUSB0: serial_chars_in_buffer
[   50.597930] ftdi_sio ttyUSB0: usb_serial_generic_chars_in_buffer - returns 0
[   50.605987] tty ttyUSB0: serial_wait_until_sent
[   50.611419] ftdi_sio ttyUSB0: usb_serial_generic_wait_until_sent - timeout = 30000 ms, period = 1 ms
[   50.622314] ftdi_sio ttyUSB0: ftdi_get_modem_status - 0x0160
[   50.630096] ftdi_sio ttyUSB0: update_mctrl - DTR LOW, RTS LOW
[   50.640777] tty ttyUSB0: serial_cleanup


Now with dev_dbg we instead get (with the %s and __func__ dropped):


[  116.419036] serial_open: tty ttyUSB0: serial_open
[  116.426849] ftdi_set_termios: ftdi_sio ttyUSB0: Setting CS8
[  116.434295] get_ftdi_divisor: ftdi_sio ttyUSB0: tty_get_baud_rate reports speed 9600
[  116.445037] get_ftdi_divisor: ftdi_sio ttyUSB0: Baud rate set to 9600 (divisor 0x4138) on chip FT232RL
[  116.457641] ftdi_set_termios: ftdi_sio ttyUSB0: Turning off hardware flow control
[  116.468780] update_mctrl: ftdi_sio ttyUSB0: DTR HIGH, RTS HIGH
[  116.476898] serial_write_room: tty ttyUSB0:
[  116.484039] usb_serial_generic_write_room: ftdi_sio ttyUSB0: returns 4096
[  116.494812] serial_write: tty ttyUSB0: 3 byte(s)
[  116.501800] serial_write_room: tty ttyUSB0:
[  116.508697] usb_serial_generic_write_room: ftdi_sio ttyUSB0: returns 4096
[  116.519470] serial_write: tty ttyUSB0: 2 byte(s)
[  116.526702] serial_close: tty ttyUSB0:
[  116.532257] serial_chars_in_buffer: tty ttyUSB0:
[  116.540039] usb_serial_generic_chars_in_buffer: ftdi_sio ttyUSB0: returns 0
[  116.551452] serial_wait_until_sent: tty ttyUSB0:
[  116.559051] usb_serial_generic_wait_until_sent: ftdi_sio ttyUSB0: timeout = 30000 ms, period = 1 ms
[  116.573303] ftdi_get_modem_status: ftdi_sio ttyUSB0: 0x0160
[  116.583282] update_mctrl: ftdi_sio ttyUSB0: DTR LOW, RTS LOW
[  116.595245] serial_cleanup: tty ttyUSB0:


which I find much harder to parse. We don't always enforce a common
prefix for function names, making grouping related functions even
harder.

Usually, what is printed in a debug message only makes sense in
combination with the function name (e.g. serial_write: 2 bytes), but now
that connection is also less clear.

Also consider what the above log would look like if you have more than
one device active. Trying to keep the independent traces separate by
simply looking at the logs becomes almost impossible. For that reason I
also very much prefer having the device name at the start of the
message.

Another reason is that the device names are of fixed length (for a
device and usually class of devices), whereas functions names vary
greatly and renders a more jagged "left column", after which device
names and message follow.

I should probably try to argue for the function-name to be moved in
dev_dbg, but until that's at least been discussed further, I prefer to
keep the (redundant) __func__s as they are.

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux