Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2083802ybb; Fri, 29 Mar 2019 18:38:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4kmf5s/0dXTG0Z084G6K6Zq9u8l8xbKKcllZ+PjL3Qhw6+tdpnB6gYg0xF47kg7yVfZC5 X-Received: by 2002:a17:902:e5:: with SMTP id a92mr51366209pla.326.1553909883594; Fri, 29 Mar 2019 18:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909883; cv=none; d=google.com; s=arc-20160816; b=dR0wjpitHYcuuIW1dyk1I/WsHaMDv31U+IMymuXs1jyyaxLyPjmTC2FHfwcdAqTPUq 1GF2eOrP+6wyMuJ1mpcVeBt6t4KfTBWBk/mYcXa/LIiq/lWPWNiUbLXzZvOSH8+v/ZMr eEj783Zb1tPpc29ls69xtKbS8FWXPIPRlzxvLpUsJzue34qzw/n6/b6rGRE81sKTD4OP a6XMwlZeaxS9XwjO11+1bmy/qguafQAr3Up85WjclnHPRPsdWS/oVySgWLQy79YacZce c/4gqkjzg7TfCyxOMY5EWQs/DURkxccZNsAl4737UChxqKQMOJHbortC3b8Asl/G1ewq WslA== 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=0WxygioheVJ1Oe4u1sXTlnxHJFwg8P2rutEjTK8OV90=; b=VJHmqtxE+MhRTTHrH9G6Iwv5wQeGXR38FhyNlMa0kMZakaeiFeTA1NOLAguNKFuBAd gAtiaBUvUq/kDW/ohG/nQfYXaUWdXLVirv0oEjPw8MXThZEOIay4Rs8ljxBvfnkNCux0 N9qUoqU82CAfTewk7aDX23JH8Rn84JAgS6RXuWnSs/sQ1GI0G5qgPjdI5ZTROCV2ngd2 +naYEpJjT+RRbOpvy4kMUP013PpBMZaq8XZSf9AKqusGSTK4cIdV7WPm6Ef0GwNgd6l7 YeidksZljxDWyolJD+u1jrNJBStdjlHbU4nDTlXNmCvB5BPD1gNV38wKunPQJAD5f/j9 bAUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cAnkbpYB; 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 s26si3019683pfm.143.2019.03.29.18.37.48; Fri, 29 Mar 2019 18:38:03 -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=cAnkbpYB; 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 S1732127AbfC3BhF (ORCPT + 99 others); Fri, 29 Mar 2019 21:37:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:38276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731798AbfC3Ba7 (ORCPT ); Fri, 29 Mar 2019 21:30:59 -0400 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 223AF218D8; Sat, 30 Mar 2019 01:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909458; bh=oQK+PqcDmsh8f+MRbwJf1u0jn/nzMt3sN1hTQ8NT2ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAnkbpYBrqCQScNHXHyCBq9iRsHNVxNKjRzeX3ov+YRF8zQKhg7xBu0xzupFV9sX0 8AzUJZa48RTjRrPZ+v+XlMrv1dm4JxcFDuuRuKtcjfPA4Be3a0JdsyQSlzeXnC8e1t Jv7JaIdv0KzbjyCfrKN0wK/RKsGBfKyd9OLaqlGA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vitaly Kuznetsov , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL 4.14 17/37] kernel: hung_task.c: disable on suspend Date: Fri, 29 Mar 2019 21:30:00 -0400 Message-Id: <20190330013020.379-17-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330013020.379-1-sashal@kernel.org> References: <20190330013020.379-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review 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: Vitaly Kuznetsov [ 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 f9aaf4994062..2e4869fa66c9 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -232,6 +233,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 */ @@ -246,7 +269,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; @@ -260,6 +284,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