Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758755AbdHYVow (ORCPT ); Fri, 25 Aug 2017 17:44:52 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:38233 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756702AbdHYVov (ORCPT ); Fri, 25 Aug 2017 17:44:51 -0400 Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: CC: , Smtp-Origin-Cluster: prn2c22 Subject: [PATCH] kthread_worker: don't hog the cpu Date: Fri, 25 Aug 2017 14:44:50 -0700 Message-ID: <5de0a179b3184e1a2183fc503448b0269f24d75b.1503697127.git.shli@fb.com> X-Mailer: git-send-email 2.9.5 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-25_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 569 Lines: 23 If the worker thread continues getting work, it will hog the cpu and rcu stall complains. Make it a good citizen. This is triggered in a loop block device test. Signed-off-by: Shaohua Li --- kernel/kthread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/kthread.c b/kernel/kthread.c index 26db528..1c19edf 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -637,6 +637,7 @@ int kthread_worker_fn(void *worker_ptr) schedule(); try_to_freeze(); + cond_resched(); goto repeat; } EXPORT_SYMBOL_GPL(kthread_worker_fn); -- 2.9.5