>From 5fd6aedadc04d102cd261507ff61071071455fb6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 12:04:01 -0700 Subject: [PATCH 2/4] kernel/kthread.c: Avoid CPU lockups Avoid that complaints similar to the one below are reported against a debug kernel: NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [kdmwork-25 4:2:23313] irq event stamp: 16320042 hardirqs last enabled at (16320041): [] _raw_spin_unlock_irq+0x27/0x40 hardirqs last disabled at (16320042): [] 0xffff8803ffbe3cd8 softirqs last enabled at (16319960): [] __do_softirq+0x1cb/0x230 softirqs last disabled at (16319715): [] irq_exit+0xa8/0xb0 CPU: 1 PID: 23313 Comm: kdmwork-254:2 RIP: 0010:[] [] _raw_spin_unlock_irq+0x2f/0x40 Call Trace: [] scsi_request_fn+0x11f/0x630 [] __blk_run_queue+0x2e/0x40 [] __elv_add_request+0x75/0x1f0 [] blk_insert_cloned_request+0x101/0x190 [] map_request+0x16a/0x1b0 [dm_mod] [] map_tio_request+0x1d/0x40 [dm_mod] [] kthread_worker_fn+0x82/0x1a0 [] kthread+0xea/0x100 [] ret_from_fork+0x22/0x40 Signed-off-by: Bart Van Assche --- kernel/kthread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/kthread.c b/kernel/kthread.c index 9ff173d..516ca6b 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -593,6 +593,7 @@ repeat: if (work) { __set_current_state(TASK_RUNNING); work->func(work); + cond_resched_rcu_qs(); } else if (!freezing(current)) schedule(); -- 2.7.3