[PATCH 2/4] kernel/kthread.c: Avoid CPU lockups
From: Bart Van Assche
Date: Thu Mar 24 2016 - 15:04:01 EST
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): [<ffffffff815992c7>] _raw_spin_unlock_irq+0x27/0x40
hardirqs last disabled at (16320042): [<ffff8803ffbe3cd8>] 0xffff8803ffbe3cd8
softirqs last enabled at (16319960): [<ffffffff8105bcdb>] __do_softirq+0x1cb/0x230
softirqs last disabled at (16319715): [<ffffffff8105bec8>] irq_exit+0xa8/0xb0
CPU: 1 PID: 23313 Comm: kdmwork-254:2
RIP: 0010:[<ffffffff815992cf>] [<ffffffff815992cf>] _raw_spin_unlock_irq+0x2f/0x40
Call Trace:
[<ffffffff813f702f>] scsi_request_fn+0x11f/0x630
[<ffffffff812977fe>] __blk_run_queue+0x2e/0x40
[<ffffffff81297065>] __elv_add_request+0x75/0x1f0
[<ffffffff8129ba91>] blk_insert_cloned_request+0x101/0x190
[<ffffffffa0189f1a>] map_request+0x16a/0x1b0 [dm_mod]
[<ffffffffa0189f7d>] map_tio_request+0x1d/0x40 [dm_mod]
[<ffffffff81077812>] kthread_worker_fn+0x82/0x1a0
[<ffffffff8107771a>] kthread+0xea/0x100
[<ffffffff81599b72>] ret_from_fork+0x22/0x40
Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
---
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
--------------050900080509050601030503
Content-Type: text/x-patch;
name="0003-block-Limit-work-processed-in-softirq-context.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0003-block-Limit-work-processed-in-softirq-context.patch"