From patchwork Thu Dec 1 18:33:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 28505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp425842wrr; Thu, 1 Dec 2022 10:43:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JpuFT2dkit8E/4sTyOk3GWyd8WGXgPFVcHP0zQ9F2FDRd/e3XVMsMdqrdIa+UobQm+Yek X-Received: by 2002:a17:907:9616:b0:7b2:9f1f:48cc with SMTP id gb22-20020a170907961600b007b29f1f48ccmr2117110ejc.164.1669920233526; Thu, 01 Dec 2022 10:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669920233; cv=none; d=google.com; s=arc-20160816; b=d2Mk2iFB9KaC+pPOD5JftbQBx8FjuEElyR+GdbGiWNZ5co5TRU8a9eITiHO8UquOpF nkMAg1z2oAXPlsDuuETZIQtxxqWV1UTqQd7n5AdWI/7lgnuzRjADzGg7fZi0JVvPrCwt uL1jaKe9AMgbB0JdKNhE/rT2yg2DnygtSbp7kjoVXGhQgqPBlBeR3sVrgktQSZ/gFin5 tPGbh35vv1uVxZH3UFatv74cm+QbspILiPPSSs64U/80jHp1pmJvA6ltBgneiXr6SYnO Bq8LbmsiGsyhgIh2T+2SW24bf9U2Ym+4b6zalaWF0e53O7MhJb4TFZL2TYq/vWRoY5la nzMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tLaoJS8DbcpBSG0jTXUq7CvFNgRKOAQiKKE1yH33QJw=; b=FVRA5IgF0jWRWnvsznDFaXX84ljaDCA+Sqj9Omjwn9tUbJeNQkVpzgPZ6Attm52PJb o6ANufC/K8f6Jy/k9B+oWO3XieolbErtQnv0Wlbek5p8clX3LVKhUQ0nm3BHU//im/lE WSLBj726LW4ijWTExR1BeIUaDBq4Q3LQb9G2VqUK1d4UQ8usxysQwxjrFDOXoy0dxfaH jKiQLSD+amC+yfWg7yVkK6WNGgKFP2D2HQVPUKEsIDg5IOBLOJNaNDCLPpL0kycALkHD iMjuRlHVFN3Sgd6KNUTkoQJtZE82M6gBLLEuyCHvOVbRyF767lbk7/4yWZt2/6gulcge 5XMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a056402524700b00463d1e263b1si5144336edd.364.2022.12.01.10.43.27; Thu, 01 Dec 2022 10:43:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiLASfD convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Dec 2022 13:35:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbiLASfA (ORCPT ); Thu, 1 Dec 2022 13:35:00 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E56893A66; Thu, 1 Dec 2022 10:34:58 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 763a39c981a2d502; Thu, 1 Dec 2022 19:34:57 +0100 Received: from kreacher.localnet (unknown [213.134.188.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 4D76527C0F8F; Thu, 1 Dec 2022 19:34:56 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Thomas =?iso-8859-1?q?Wei=DFschuh?= , Petr Mladek , Lukas Bulwahn , Joe Perches , Todd Brandt Subject: [PATCH v1 1/2] PM: sleep: Avoid using pr_cont() in the tasks freezing code Date: Thu, 01 Dec 2022 19:33:09 +0100 Message-ID: <4758119.GXAFRqVoOG@kreacher> In-Reply-To: <4441789.LvFx2qVVIh@kreacher> References: <4441789.LvFx2qVVIh@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.188.161 X-CLIENT-HOSTNAME: 213.134.188.161 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrtdehgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtqhertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnheptddvfeegledvfedvveevhedvteeffeehvdeuiedukeeiledttefgvdeihffgteetnecukfhppedvudefrddufeegrddukeekrdduiedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekkedrudeiuddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigseifvghishhsshgthhhuhhdrnhgvthdprhgtphhtthhopehpmhhlrgguvghksehsuhhsvgdrtghomhdprhgtphhtthhopehluhhkrghsrdgs uhhlfigrhhhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhhovgesphgvrhgthhgvshdrtghomhdprhgtphhtthhopehtohguugdrvgdrsghrrghnughtsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751038278935802971?= X-GMAIL-MSGID: =?utf-8?q?1751038278935802971?= From: Rafael J. Wysocki Using pr_cont() in the tasks freezing code related to system-wide suspend and hibernation is problematic, because the continuation messages printed there are susceptible to interspersing with other unrelated messages which results in output that is hard to understand. Address this issue by modifying try_to_freeze_tasks() to print messages that don't require continuations and adjusting its callers accordingly. Reported-by: Thomas Weißschuh Signed-off-by: Rafael J. Wysocki --- kernel/power/process.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) Index: linux-pm/kernel/power/process.c =================================================================== --- linux-pm.orig/kernel/power/process.c +++ linux-pm/kernel/power/process.c @@ -27,6 +27,8 @@ unsigned int __read_mostly freeze_timeou static int try_to_freeze_tasks(bool user_only) { + const char *what = user_only ? "user space processes" : + "remaining freezable tasks"; struct task_struct *g, *p; unsigned long end_time; unsigned int todo; @@ -36,6 +38,8 @@ static int try_to_freeze_tasks(bool user bool wakeup = false; int sleep_usecs = USEC_PER_MSEC; + pr_info("Freezing %s\n", what); + start = ktime_get_boottime(); end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs); @@ -82,7 +86,6 @@ static int try_to_freeze_tasks(bool user elapsed_msecs = ktime_to_ms(elapsed); if (todo) { - pr_cont("\n"); pr_err("Freezing of tasks %s after %d.%03d seconds " "(%d tasks refusing to freeze, wq_busy=%d):\n", wakeup ? "aborted" : "failed", @@ -101,8 +104,8 @@ static int try_to_freeze_tasks(bool user read_unlock(&tasklist_lock); } } else { - pr_cont("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000, - elapsed_msecs % 1000); + pr_info("Freezing %s completed (elapsed %d.%03d seconds)\n", + what, elapsed_msecs / 1000, elapsed_msecs % 1000); } return todo ? -EBUSY : 0; @@ -130,14 +133,11 @@ int freeze_processes(void) static_branch_inc(&freezer_active); pm_wakeup_clear(0); - pr_info("Freezing user space processes ... "); pm_freezing = true; error = try_to_freeze_tasks(true); - if (!error) { + if (!error) __usermodehelper_set_disable_depth(UMH_DISABLED); - pr_cont("done."); - } - pr_cont("\n"); + BUG_ON(in_atomic()); /* @@ -166,14 +166,9 @@ int freeze_kernel_threads(void) { int error; - pr_info("Freezing remaining freezable tasks ... "); - pm_nosig_freezing = true; error = try_to_freeze_tasks(false); - if (!error) - pr_cont("done."); - pr_cont("\n"); BUG_ON(in_atomic()); if (error) From patchwork Thu Dec 1 18:34:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 28504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp425578wrr; Thu, 1 Dec 2022 10:43:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4C2gVr9d1vQ1nMkXHyVNO1csGoJVYdmN2D8LNiovQz2cu1b4lzuCG5fETdflBo4O6fEcx3 X-Received: by 2002:a17:906:1686:b0:7ba:489e:8489 with SMTP id s6-20020a170906168600b007ba489e8489mr35400074ejd.669.1669920194699; Thu, 01 Dec 2022 10:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669920194; cv=none; d=google.com; s=arc-20160816; b=g+40aNIYidbo8T31DxBxGtPiiYEPv1YngsT+QePaGCpgq1cf8vL3FiZDNqjSKJy7Z9 f77aPOl7dP89xnIs1In8mEtM0rysX/ILBBDWx7+DlWIcopnR0TfOMYLxrLeU8b1nMBwA jge2SiBVf+w6vyXPqM4RIi+Md3S3qIRZAu3th2d58KeBRA0oCsFmMiUZJ93EZzw7Bnau Jy8EnyexedJYsqqIZIwynxXiWIWlspOJSpP2Q2O3YLJdlFBb7uZtI6VJJ5IrHvxc6p9w 1qtBu/c3vthV/CLmw9RRleXfJevrEvSL7oFAw7lOnMN/pjNpH+L3TEvCbq6SEOk28NZO xVUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Y4ZmUmTvORPZFgFR10qL3WeSpMshEQR+plqbzv0axNM=; b=odRg+Uw2XXeDemeL3XHEYQvczRQIbD1V3U87//AEuA4c0Xm5Hf6llJRh0KaToFR4d4 VmhGyMs1g/HLX+VCahzNi89ElhgSN7TBzoV/o5t2O8VfXtmdz3JlAQXm4MVK7O9QGEec JOq0jICmwUjtKHdeoggCJaJCRLgNftrsTiSARH9FxoASWnKRyK3OEW3/3D7In9evgjQz sAeHEj2DCy0j/pfnQ6eFEkYTFRhDDBpBabcycwH1b9gnBwLEm0VzGlW2ff1Fx2ZYM/nq +LlhhVWmbdkJ4jYetV3jTt1JLTpHvqYxdH6EEMJFw/yqmdKKGfVoO+UF+cxsp2O+seID 5l+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a50d745000000b00469058297afsi24672edj.92.2022.12.01.10.42.51; Thu, 01 Dec 2022 10:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiLASfA (ORCPT + 99 others); Thu, 1 Dec 2022 13:35:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiLASe6 (ORCPT ); Thu, 1 Dec 2022 13:34:58 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FEF8C690; Thu, 1 Dec 2022 10:34:57 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id b412ff0d46b34b5f; Thu, 1 Dec 2022 19:34:55 +0100 Received: from kreacher.localnet (unknown [213.134.188.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id BD88427C0F8F; Thu, 1 Dec 2022 19:34:54 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Thomas =?iso-8859-1?q?Wei=DFschuh?= , Petr Mladek , Lukas Bulwahn , Joe Perches , Todd Brandt Subject: [PATCH v1 2/2] PM: sleep: Refine error message in try_to_freeze_tasks() Date: Thu, 01 Dec 2022 19:34:44 +0100 Message-ID: <2122394.irdbgypaU6@kreacher> In-Reply-To: <4441789.LvFx2qVVIh@kreacher> References: <4441789.LvFx2qVVIh@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.188.161 X-CLIENT-HOSTNAME: 213.134.188.161 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrtdehgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrddukeekrdduiedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekkedrudeiuddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigseifvghishhsshgthhhuhhdrnhgvthdprhgtphhtthhopehpmhhlrgguvghksehsuhhsvgdrtghomhdprhgtphhtthhopehluhhkrghsrdgs uhhlfigrhhhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhhovgesphgvrhgthhgvshdrtghomhdprhgtphhtthhopehtohguugdrvgdrsghrrghnughtsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751038238253944618?= X-GMAIL-MSGID: =?utf-8?q?1751038238253944618?= From: Rafael J. Wysocki A previous change amended try_to_freeze_tasks() with the "what" variable pointing to a string describing the group of tasks subject to the freezing which may be used in the error message in there too, so make that happen. Accordingly, update sleepgraph.py to catch the modified error message as appropriate. Signed-off-by: Rafael J. Wysocki --- kernel/power/process.c | 4 ++-- tools/power/pm-graph/sleepgraph.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) Index: linux-pm/kernel/power/process.c =================================================================== --- linux-pm.orig/kernel/power/process.c +++ linux-pm/kernel/power/process.c @@ -86,8 +86,8 @@ static int try_to_freeze_tasks(bool user elapsed_msecs = ktime_to_ms(elapsed); if (todo) { - pr_err("Freezing of tasks %s after %d.%03d seconds " - "(%d tasks refusing to freeze, wq_busy=%d):\n", + pr_err("Freezing %s %s after %d.%03d seconds " + "(%d tasks refusing to freeze, wq_busy=%d):\n", what, wakeup ? "aborted" : "failed", elapsed_msecs / 1000, elapsed_msecs % 1000, todo - wq_busy, wq_busy); Index: linux-pm/tools/power/pm-graph/sleepgraph.py =================================================================== --- linux-pm.orig/tools/power/pm-graph/sleepgraph.py +++ linux-pm/tools/power/pm-graph/sleepgraph.py @@ -1462,7 +1462,7 @@ class Data: 'TIMEOUT' : r'(?i).*\bTIMEOUT\b.*', 'ABORT' : r'(?i).*\bABORT\b.*', 'IRQ' : r'.*\bgenirq: .*', - 'TASKFAIL': r'.*Freezing of tasks *.*', + 'TASKFAIL': r'.*Freezing .*after *.*', 'ACPI' : r'.*\bACPI *(?P[A-Za-z]*) *Error[: ].*', 'DISKFULL': r'.*\bNo space left on device.*', 'USBERR' : r'.*usb .*device .*, error [0-9-]*',