From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95A43C282CD for ; Mon, 28 Jan 2019 17:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61C4F2147A for ; Mon, 28 Jan 2019 17:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548696638; bh=Mis7PKJk3nunS+b0Tm/bwuLm0tJHxdGaY7hais+GdRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OpxYUyw63WJFHYUR/2R64qljAPHoFqCNAynD17qb9e+K1ottQKtJsiftdwwipkbm8 eY5kb89mUn/a+uLtap42tbX5eeF5wQLsu0cB8z3g53E9+hWBvIJqSrXTbf9nVeijHh Q9ifteB9OeB8YtARrnqz6L5rf6rnGS2RLPVIEZ0U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730088AbfA1P6w (ORCPT ); Mon, 28 Jan 2019 10:58:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:44242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfA1P6w (ORCPT ); Mon, 28 Jan 2019 10:58:52 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7486D2175B; Mon, 28 Jan 2019 15:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691131; bh=Mis7PKJk3nunS+b0Tm/bwuLm0tJHxdGaY7hais+GdRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WI5eThIfo/KTYy3XPW6p3vbOBpx6sXVI3AB4EhG9ZjvhW42yEtNQz/Ys6kNZd1Qcz 7xBhv/gusyaHzeT54F4V2PnkfvX4tsw8aJlDvAZlSVHye5C3sQceIMy2+JRHfWlba0 QNikThkwTL8VdLxStVBIHk3ffnCSFKkUVv1b17TM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tetsuo Handa , Petr Mladek , Sergey Senozhatsky , Dmitry Vyukov , "Rafael J. Wysocki" , Vitaly Kuznetsov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.20 297/304] kernel/hung_task.c: break RCU locks based on jiffies Date: Mon, 28 Jan 2019 10:43:34 -0500 Message-Id: <20190128154341.47195-297-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128154341.47195-1-sashal@kernel.org> References: <20190128154341.47195-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tetsuo Handa [ Upstream commit 304ae42739b108305f8d7b3eb3c1aec7c2b643a9 ] check_hung_uninterruptible_tasks() is currently calling rcu_lock_break() for every 1024 threads. But check_hung_task() is very slow if printk() was called, and is very fast otherwise. If many threads within some 1024 threads called printk(), the RCU grace period might be extended enough to trigger RCU stall warnings. Therefore, calling rcu_lock_break() for every some fixed jiffies will be safer. Link: http://lkml.kernel.org/r/1544800658-11423-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa Acked-by: Paul E. McKenney Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Dmitry Vyukov Cc: "Rafael J. Wysocki" Cc: Vitaly Kuznetsov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/hung_task.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index cb8e3e8ac7b9..444b8b5dd69f 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -34,7 +34,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT; * is disabled during the critical section. It also controls the size of * the RCU grace period. So it needs to be upper-bound. */ -#define HUNG_TASK_BATCHING 1024 +#define HUNG_TASK_LOCK_BREAK (HZ / 10) /* * Zero means infinite timeout - no checking done: @@ -173,7 +173,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t) static void check_hung_uninterruptible_tasks(unsigned long timeout) { int max_count = sysctl_hung_task_check_count; - int batch_count = HUNG_TASK_BATCHING; + unsigned long last_break = jiffies; struct task_struct *g, *t; /* @@ -188,10 +188,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) for_each_process_thread(g, t) { if (!max_count--) goto unlock; - if (!--batch_count) { - batch_count = HUNG_TASK_BATCHING; + if (time_after(jiffies, last_break + HUNG_TASK_LOCK_BREAK)) { if (!rcu_lock_break(g, t)) goto unlock; + last_break = jiffies; } /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */ if (t->state == TASK_UNINTERRUPTIBLE) -- 2.19.1