Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2749763imj; Mon, 11 Feb 2019 07:56:41 -0800 (PST) X-Google-Smtp-Source: AHgI3Iac/Hgjmr6S1jXQUdu/PNwoA8ELcL0Ph+MOFjf6FyKbJCjJj0oT3zXdYQLyJ7QNu6kh4dHI X-Received: by 2002:a63:61d8:: with SMTP id v207mr9426203pgb.308.1549900600941; Mon, 11 Feb 2019 07:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900600; cv=none; d=google.com; s=arc-20160816; b=jOe434nX2L5EdzX1xGnWrYtFaGCNhROqSwjhQV9On982qlt/EOLlyJxZUde+Lv+h6z VqD2mYKMoBpaFVDjLrI6NWTFosHMhUv8ZkD0IkBf4CP1+aLRNBLAMs1rNUge87TOM5Hi MaDhFgcE4tJFLAcbw5MM1dP9vaCAy3BhYN97hFDMz+BDQyGoL3eM0qCNhWJLfIPUxOHf 62FBMY38YqsHSp1pwWt/Vpz0X8cbQI4V9lBw61CudJEAIRAHu94uK5LFt3OWowatGBvi SgahDO3NT2e4qNgJdDAGDylnVLjSZtWMRJXoq0g7cMX934vT13yIMKVNTFfj3vXRn+Hn bkVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zMJsODWN14AOuhqKVQ94Opps4Q/2GXfTinocpigpEO0=; b=HW/t47ZEWzShk5KTXpglsVWn7CoNMrxfcVhIGHRlEfCa6yCO72S2B+JMEbI9vH8szE NUu3uDcE6YPxgHxSBI/1TesPRtZFwtLkEnt04qWocaPiyeGVpDHu/8r2bGskf3POZJi7 /Zo5zsBK3WT+BbKgWZ5ZTIElm/p6/Z++0z8SFk5F1FlPYejd7iQTMdwyiRmWKeY9N7aM 4yDBh61uDTk1qDtm1Oz3KwdY4YDlXXybfCosSlBSu9d4rRjsARGEVxweF0e/suLgZ7yx WJ/1aPPs80uxrPuGdDsnDweX2miKOg2ZWmXxVj5K/gFl0RPOQHPIs+zvy+rt+e+YJKk0 cdOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U6aNGEw9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si5279625pgd.361.2019.02.11.07.56.24; Mon, 11 Feb 2019 07:56:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U6aNGEw9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731126AbfBKOfx (ORCPT + 99 others); Mon, 11 Feb 2019 09:35:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:44616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731113AbfBKOfv (ORCPT ); Mon, 11 Feb 2019 09:35:51 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 68D982080F; Mon, 11 Feb 2019 14:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895749; bh=7zFXGWFKElY8btVisTcELi7OwZcrM7Jyo49hRhizidI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6aNGEw9JN9TmQmVV3Pc+twx5ZKjfkEg9peD2y52fiA6Xh4ZUlRD0fwQJ2ImOvTfD YUxZwAVFbRjHT9HpahB3v0fNLkqj92c/4/c2BpRFWwj/IwCqIoStKwNoRh4kuQl51B MBlAXTUxjwn6Ex3AEKAGyRfBoeInALhC/OjtZr1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , "Paul E. McKenney" , Petr Mladek , Sergey Senozhatsky , Dmitry Vyukov , "Rafael J. Wysocki" , Vitaly Kuznetsov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.20 283/352] kernel/hung_task.c: break RCU locks based on jiffies Date: Mon, 11 Feb 2019 15:18:30 +0100 Message-Id: <20190211141904.940859034@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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