Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2688229imj; Mon, 11 Feb 2019 07:03:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCG69Gmqz0Ay0fUg39bq8ocA8+pijKCQ8B5poYEUK2l0VukFt7/qotz7RZliNyn/SgxADQ X-Received: by 2002:a63:b70b:: with SMTP id t11mr28733166pgf.404.1549897408329; Mon, 11 Feb 2019 07:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897408; cv=none; d=google.com; s=arc-20160816; b=mWE3RW+ZayiBaIZ6E+i4TtDNXozpoJ+2LC0fwYqU9/2vluqf3QLg2FHBaupkx5TfRC o+8O+KpVjzayxD8L6TNE5v+E6jF876H3An1G+IoqhDeXKOir4gLZO+rR6EMOGErqFnIw 0QrOizOfQ2Ujc2Tgha/KNTy4y5AunIaxf1AsTO/+02EJJ54Uf5WeXLwMoOpZT7nIwNGk oTc6VaOvlfnVchdl5a/G8Q5V3HjIR06Okm1fJWSZ/3iq+vyXx089t+kLzHrMOcSJOFlJ jF+EkcSDIhDCLrnXS0VLGJfhx8GsJ36K19hbgBVGWqhErhTSDEoEr6XyAuMeY9QfbGci c3nQ== 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=dLfrjzX/SvSFlSZfo2Ffj8uXF2G4umd2AIhUxXb/GUE=; b=h+WWwD3U26zndNkxwjhyWs8GkD802I6vBUAk/0Q3CsogCWpRsmd3HN6kSwYVxxyuzC me297OH0CprUHew0C+TlRwfo+IPftXNm0QrwGfGON9JUTzwhzqOrBzl0/V+LSakZJcuO qaxfRViTrpIUe1qPXJ7Kxq5MC0OZuHg/MFa3mrb0R4lgp1m2hkX/1CEnanpZEGWjBHst SyPYfAMubNvj6d1ur5dAB5V9C4YBfP/21wv20e/l/BBijrbBcJpO7LetqGWEUL7lBwJq dYgm+hj3UaRv0i/M/aniqkAYJhkf2SyOTsygBYEhE+Rac+T6zUTscetraOUxUA80aTdT f80w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VZkL1iJI; 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 d22si7123117pgv.40.2019.02.11.07.02.51; Mon, 11 Feb 2019 07:03:28 -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=VZkL1iJI; 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 S2390271AbfBKPBu (ORCPT + 99 others); Mon, 11 Feb 2019 10:01:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:49890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389498AbfBKPBs (ORCPT ); Mon, 11 Feb 2019 10:01:48 -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 9FCBA222AB; Mon, 11 Feb 2019 15:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897307; bh=nkfNdReJHxBRHlbPPGv4KGnpaDGoWaMWv6wiqGQzxhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZkL1iJIsI0c8UCppddvP5jnL1qf73FKPcFR5+eiSDTL2pXk0XjTwtLwsiHIqHj46 sJ7M0VwM012J5hd5JPmZRzp9aoZReBg/gWWCz0dIWgHQYrw8WjCOM4uQBSRQjvIDob vcJwKEnn15VZkvaQEnGV0W0zWr9C3SDFnDz5q4rY= 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.14 159/205] kernel/hung_task.c: break RCU locks based on jiffies Date: Mon, 11 Feb 2019 15:19:17 +0100 Message-Id: <20190211141838.762111773@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 32b479468e4d..0cec1241e26f 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -33,7 +33,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: @@ -164,7 +164,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; /* @@ -179,10 +179,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