Re: [PATCH v3] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk

From: Jason Yan
Date: Tue Apr 03 2018 - 05:12:16 EST



On 2018/4/3 14:04, Wen Yang wrote:
There would be so many same lines printed by frequent printk if one
disk went wrong, like,
[ 546.185242] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185258] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185280] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185307] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185334] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185364] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185390] sd 0:1:0:0: rejecting I/O to offline device
[ 546.185410] sd 0:1:0:0: rejecting I/O to offline device
For slow serial console, the frequent printk may be blocked for a
long time, and if any spin_lock has been acquired before the printk
like in scsi_request_fn, watchdog could be triggered.

Related disscussion can be found here,
https://bugzilla.kernel.org/show_bug.cgi?id=199003
And Petr brought the idea to throttle the frequent printk, it's
useless to print the same lines frequently after all.

v2: fix some typos
v3: limit the print only for the same device

Suggested-by: Petr Mladek<pmladek@xxxxxxxx>
Suggested-by: Sergey Senozhatsky<sergey.senozhatsky.work@xxxxxxxxx>
Signed-off-by: Wen Yang<wen.yang99@xxxxxxxxxx>
Signed-off-by: Jiang Biao<jiang.biao2@xxxxxxxxxx>
Signed-off-by: Tan Hu<tan.hu@xxxxxxxxxx>
Reviewed-by: Bart Van Assche<bart.vanassche@xxxxxxx>
CC: BartVanAssche<Bart.VanAssche@xxxxxxx>
CC: Petr Mladek<pmladek@xxxxxxxx>
CC: Sergey Senozhatsky<sergey.senozhatsky.work@xxxxxxxxx>
CC: Martin K. Petersen<martin.petersen@xxxxxxxxxx>
CC: "James E.J. Bottomley"<jejb@xxxxxxxxxxxxxxxxxx>
CC: Tejun Heo<tj@xxxxxxxxxx>
CC: JasonYan<yanaijie@xxxxxxxxxx>

In my machine it works fine.

Tested-by: Jason Yan <yanaijie@xxxxxxxxxx>