Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3693459imu; Mon, 28 Jan 2019 09:09:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6nUKvkk3PIc4tNB86ByjTzQ8r3qytkFiFxSu0Xf1pFy+0MXAq3pEP7NVYta/h9m/G4CPT+ X-Received: by 2002:a17:902:a40f:: with SMTP id p15mr23097940plq.286.1548695382839; Mon, 28 Jan 2019 09:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695382; cv=none; d=google.com; s=arc-20160816; b=Xxq72T/oMwvaMPFJAFGzzl5RrOQHvp3cJ889GG3KfDh8WTPqoQoq2SZkQBQdc0WgIo 8dS4Bq3qAAnnxvhuy73HhD9ZMrrKO0K7cTeAqdTYuEupwANx6hu5bNrcU/ewd26tfwr2 tRVc0Kn8KPrRpzE/LHGSuEd4YVG6lXxuVDYXKqN5gGN6l4SZCHHY+homh1OAsYpPmoE1 X/enXmSKLzQHNqp5YjMogHqjht6xBRCklvHC0a/FU9va2WieURsoSqZG1n+RFaOuMAR8 hGzDV0DrPleSbdWEJnoS1Y7RnUFRBZFel3wp8P7gtTgdCeSU2r7H0AGGfTlXIuEMzRwZ MAtQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dwxf543XdyQTCOKSp5p4JEi6ElC9WHh6yOJICdbHuYI=; b=dYspKCv9VqfC44epLQkmsBo+n8q1jKEOzyTtYBZm2FWqr+WWuv5ZpwLZwjHSQfu7XY Y1jrxwKOp5kv2i1V+wPD4C8YFXWg7jFWIH87wY73m2tpJF3sHNjRra+hWn0bO/nP7Akv aFD3522dJGmxcv3vE/i+uGCZLwCSdQboqFiOpGDtg3w6DrIRBUE/K/bSQf/PF4BoCnP1 HqpjrQqsKZM/yOElwUB41KYwrZBFys4yjtQAAonEnss9VYhH/GxuaxLi92qsPfLRt6t1 +7kltSNv2TqQswAps65QSI4SL4gp8/fQkWYjA83FtVprqmTqgPbw9nmEmYPdVWtpveo6 ChCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cueulevL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si33342458pfw.66.2019.01.28.09.09.26; Mon, 28 Jan 2019 09:09:42 -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=cueulevL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732971AbfA1QLn (ORCPT + 99 others); Mon, 28 Jan 2019 11:11:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:38880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732335AbfA1QLk (ORCPT ); Mon, 28 Jan 2019 11:11:40 -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 D2DC92147A; Mon, 28 Jan 2019 16:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691899; bh=V23sorOwjJMd78DaL5x5MsSDtjWrXGnimaY2rgHj0r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cueulevLUJF56gNRZHJMhBs25G676lCG2SuozYxWpJZGXvHW9XpF80bmOEOcBVHyW XO8A3n4dCqSqLg8Iu+15LTcorzxIeIt1ybZREgn+Xjdo8ICHrISR2hq2baDOLYXALD WtT1QIEBMTt7l5RzHwR60hKMXNVLNdCxc12jAr2E= 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.19 252/258] kernel/hung_task.c: break RCU locks based on jiffies Date: Mon, 28 Jan 2019 10:59:18 -0500 Message-Id: <20190128155924.51521-252-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 b9132d1269ef..aa3c51f300aa 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: @@ -172,7 +172,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; /* @@ -187,10 +187,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