Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884515yba; Thu, 18 Apr 2019 11:10:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDqgxp2sKi2Ue+dsSfuevg93V31gXANS3+GUAX458Gh/cvY7Cu0xRLqAxBKeA0n7WhRl49 X-Received: by 2002:a65:4342:: with SMTP id k2mr10246773pgq.178.1555611041730; Thu, 18 Apr 2019 11:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611041; cv=none; d=google.com; s=arc-20160816; b=MxC16Vj5T/4G1WdW4/Lh+i5uZMrRTHl06d47z09rRIQ0xSMCdNjPp9wA60aCVO5TQh ylspsvLHahPsPFtVV8xWHjMo6uL4h9cFKNdz1I8m+iQI2gE4//Qn7eh8Heem1ra/Ij1I pM8RSCN4vEQJ2EfKzeCGyAZ8GvWAJdwWeUQem3UEr+i/wD7xugKI6b/5mLhZGWHDUYJ8 zab/OOEtL4o3ZVbA8wWJK6yLwaTFI7RWOUBEzdCvWY9FVsow0H2T9s/sJVV0OJDtMoap hOk8RX5pZjfQEAY4rJnWAazJX3P5Y81g8ykbzn0A/TD0Gx/gryxIFjgiG57jHgC9G+RV r61Q== 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=TIr25+jR948Ajkb5yWKfBcwB+glnPrhutiNgYkpsjMA=; b=Bm9OhT6EYOuzvnwY2wIYgi69Wa8CPLy7nITnGHic7rJllb1+d02o++SDThm2WN4r83 YRjCmPl7bRp2SEupLmDTDJFdwG7zTm4BC7M6NrVZRV/lSDCQ0zhMq4aNncoRyo8aEnar 8KuIN3N+GycLyKlUuUfIyPCRrLFLiLqQZT7PG/X0WzgLEJi/rheswIHWXdHudAsMAId3 gDnqWYKkAuaM2ZHeHZoAbQKZMqueLeSS2Guwll8gHDtpoxgoDVqiqWuRV0BD/k3iFVbQ 0RHPrkeq5Zex4ZxX/5NcFnUeHzOL1BeAzEWFO8aD8tBEE6DBRONg8BwOoFjjVWhpifvp q3TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VeRzqFMg; 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 be8si2687254plb.72.2019.04.18.11.10.26; Thu, 18 Apr 2019 11:10:41 -0700 (PDT) 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=VeRzqFMg; 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 S2403881AbfDRSIj (ORCPT + 99 others); Thu, 18 Apr 2019 14:08:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403857AbfDRSIb (ORCPT ); Thu, 18 Apr 2019 14:08:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 83AD2206B6; Thu, 18 Apr 2019 18:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610910; bh=lK47yttyLG6+w2KdGbKrVhyUGeKIMNxq4mQdK4WoHIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VeRzqFMggFqY0tbqr20IaTasEe0faJcyqncPQrQIRL7SNy9S3iW6DWXzuEXChdLp1 FdH3xWIwQdQN0OLPnySt/mXHY2nVMcBaYZldDYdfcgGCvlDpfS6DCur8mAaEcEoyaa 4LbKuOHHCEay1/CGj4qteCVlFtfttrlSCwDlDhg8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.9 38/50] kernel: hung_task.c: disable on suspend Date: Thu, 18 Apr 2019 19:57:49 +0200 Message-Id: <20190418160427.194945585@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit a1c6ca3c6de763459a6e93b644ec6518c890ba1c ] It is possible to observe hung_task complaints when system goes to suspend-to-idle state: # echo freeze > /sys/power/state PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.001 seconds) done. OOM killer disabled. Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done. sd 0:0:0:0: [sda] Synchronizing SCSI cache INFO: task bash:1569 blocked for more than 120 seconds. Not tainted 4.19.0-rc3_+ #687 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. bash D 0 1569 604 0x00000000 Call Trace: ? __schedule+0x1fe/0x7e0 schedule+0x28/0x80 suspend_devices_and_enter+0x4ac/0x750 pm_suspend+0x2c0/0x310 Register a PM notifier to disable the detector on suspend and re-enable back on wakeup. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- kernel/hung_task.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index fd781a468f32..fb00cf30abd1 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -221,6 +222,28 @@ void reset_hung_task_detector(void) } EXPORT_SYMBOL_GPL(reset_hung_task_detector); +static bool hung_detector_suspended; + +static int hungtask_pm_notify(struct notifier_block *self, + unsigned long action, void *hcpu) +{ + switch (action) { + case PM_SUSPEND_PREPARE: + case PM_HIBERNATION_PREPARE: + case PM_RESTORE_PREPARE: + hung_detector_suspended = true; + break; + case PM_POST_SUSPEND: + case PM_POST_HIBERNATION: + case PM_POST_RESTORE: + hung_detector_suspended = false; + break; + default: + break; + } + return NOTIFY_OK; +} + /* * kthread which checks for tasks stuck in D state */ @@ -235,7 +258,8 @@ static int watchdog(void *dummy) long t = hung_timeout_jiffies(hung_last_checked, timeout); if (t <= 0) { - if (!atomic_xchg(&reset_hung_task, 0)) + if (!atomic_xchg(&reset_hung_task, 0) && + !hung_detector_suspended) check_hung_uninterruptible_tasks(timeout); hung_last_checked = jiffies; continue; @@ -249,6 +273,10 @@ static int watchdog(void *dummy) static int __init hung_task_init(void) { atomic_notifier_chain_register(&panic_notifier_list, &panic_block); + + /* Disable hung task detector on suspend */ + pm_notifier(hungtask_pm_notify, 0); + watchdog_task = kthread_run(watchdog, NULL, "khungtaskd"); return 0; -- 2.19.1