>From a73fdf710b98922fa02d464af96b499ea2740832 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 23 Mar 2016 14:38:13 -0700 Subject: [PATCH 4/4] Avoid that I/O completion processing triggers lockup complaints Avoid that I/O completion processing triggers the following complaints if kernel debug options that slow down the kernel significantly are enabled: NMI watchdog: BUG: soft lockup - CPU#3 stuck for 22s! [kdmwork-254:2:358] irq event stamp: 15233868 hardirqs last enabled at (15233867): [] _raw_spin_unlock_irq+0x27/0x40 hardirqs last disabled at (15233868): [] apic_timer_interrupt+0x84/0x90 softirqs last enabled at (15233850): [] __do_softirq+0x1cb/0x230 softirqs last disabled at (15233743): [] irq_exit+0xa8/0xb0 CPU: 3 PID: 358 Comm: kdmwork-254:2 RIP: 0010:[] [] _raw_spin_unlock_irq+0x2f/0x40 Call Trace: [] scsi_request_fn+0x118/0x600 [] __blk_run_queue+0x2e/0x40 [] __elv_add_request+0x75/0x1f0 [] blk_insert_cloned_request+0x101/0x190 [] map_request+0x18e/0x210 [dm_mod] [] map_tio_request+0x1d/0x40 [dm_mod] [] kthread_worker_fn+0x7d/0x1a0 [] kthread+0xea/0x100 [] ret_from_fork+0x3f/0x70 INFO: rcu_sched self-detected stall on CPU 3-...: (6497 ticks this GP) idle=fb9/140000000000002/0 softirq=2044956/2045037 fqs=5414 (t=6500 jiffies g=219289 c=219288 q=7233211) Task dump for CPU 3: kdmwork-254:2 R running task 0 358 2 0x00000008 Call Trace: [] sched_show_task+0xbf/0x150 [] dump_cpu_task+0x32/0x40 [] rcu_dump_cpu_stacks+0x89/0xe0 [] rcu_check_callbacks+0x439/0x730 [] update_process_times+0x34/0x60 [] tick_sched_handle.isra.18+0x20/0x50 [] tick_sched_timer+0x38/0x70 [] __hrtimer_run_queues+0xa5/0x1c0 [] hrtimer_interrupt+0xa6/0x1b0 [] smp_trace_apic_timer_interrupt+0x63/0x90 [] smp_apic_timer_interrupt+0x9/0x10 [] apic_timer_interrupt+0x89/0x90 [] __slab_free+0xc6/0x270 [] kmem_cache_free+0x159/0x160 [] kiocb_free+0x32/0x40 [] aio_complete+0x1e5/0x3c0 [] dio_complete+0x75/0x1d0 [] dio_bio_end_aio+0x7a/0x130 [] bio_endio+0x3a/0x60 [] blk_update_request+0x7c/0x2a0 [] end_clone_bio+0x41/0x70 [dm_mod] [] bio_endio+0x3a/0x60 [] blk_update_request+0x7c/0x2a0 [] scsi_end_request+0x2e/0x1d0 [] scsi_io_completion+0xb4/0x610 [] scsi_finish_command+0xca/0x120 [] scsi_softirq_done+0x120/0x140 [] blk_done_softirq+0x72/0x90 [] __do_softirq+0x10f/0x230 [] irq_exit+0xa8/0xb0 [] do_IRQ+0x65/0x110 [] common_interrupt+0x89/0x89 [] __multipath_map.isra.16+0x145/0x260 [dm_multipath] [] multipath_map+0x12/0x20 [dm_multipath] [] map_request+0x43/0x210 [dm_mod] [] map_tio_request+0x1d/0x40 [dm_mod] [] kthread_worker_fn+0x7d/0x1a0 [] kthread+0xea/0x100 [] ret_from_fork+0x3f/0x70 Signed-off-by: Bart Van Assche Cc: Paul E. McKenney --- drivers/scsi/scsi_lib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8106515..8f264a0 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1770,13 +1770,14 @@ static void scsi_request_fn(struct request_queue *q) struct Scsi_Host *shost; struct scsi_cmnd *cmd; struct request *req; + int i; /* - * To start with, we keep looping until the queue is empty, or until - * the host is no longer able to accept any more requests. + * Loop until the queue is empty, until the host is no longer able to + * accept any more requests or until 64 requests have been processed. */ shost = sdev->host; - for (;;) { + for (i = 64; i > 0; i--) { int rtn; /* * get next queueable request. We do this early to make sure @@ -1861,6 +1862,9 @@ static void scsi_request_fn(struct request_queue *q) spin_lock_irq(q->queue_lock); } + if (unlikely(i == 0)) + blk_delay_queue(q, 0); + return; host_not_ready: -- 2.7.3