From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A6B438735B for ; Thu, 8 Jan 2026 09:43:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767865415; cv=none; b=GQaMOFtuaRhRDhNAnEMMol2uOpHdwx/YKpNe1VLOZXYLQu7N9TWplWfqJ1M+ldqRvzWwHaG+M/bjXThpyU+DMlp9G3VNoeKUnrqg1ZRkyph1cyjIQodQ9iv5VZ8dxrBTLQFNmzScxk9m55JQMs+0Blqg0K6nZ5SrnA//FCbvyjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767865415; c=relaxed/simple; bh=S5Ip/hKrLUDKZMP8b+KsHiFlCutXErTAUvs6KhZoaWA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=gu+aLXj6q/1dOd05eiUvLaRLG0rOYHGOKZjs/YvV6cDS5OHbIM+hV0jxTgCEO6KGJRSMqPyeZRLxyBQNogDcEsHkhGXV7wFL1GTo2CPqch8GzO30XhM1uMC1trNBes6oltyVQXtA22EG1t5oQbHACivaMHvve8KsQJB2BJhYRdc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gmxl5fYQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a0LQ2+cd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gmxl5fYQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a0LQ2+cd" From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1767865405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KuLzvOS95d+IHymx2TGRG4sJ0YGM0b9HGHcOUgEkdB4=; b=gmxl5fYQJa3gHRpwuWRc/MzclG06tfFJLgutEeOhds7AS6zhs1pcm7HRie30cvHVUWdtIO hw2rQLNMWALRqsYYXFg7I864kp0SPVcfJj7s8cZurFcvlle4sSz/FapzUIRu2zbY6jQdSi QBDp3RrebUqwDZ6kU3RxidNtyxk0xa/Inwr373ocdas2F173ccO1ltOTH8AFnxfoWYrwSe SOuzSaDMC0+3OgbFpS6j4H5NdfTZW8mYTWAUXP3xdwlFlWo4DqQ+qlUNVIYicsvDw4k8Pl /rMXomr7LiURHfbN+drRWen8zX7RtHba6Lxpti33Sfm1AyVJv8jhq/exuETD3w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1767865405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KuLzvOS95d+IHymx2TGRG4sJ0YGM0b9HGHcOUgEkdB4=; b=a0LQ2+cdhul5W53KKdPpbpdu8W5gxuaQIUQdDPA6XyaPG3pYR92zeSOn/69aq+hVMunOKe cyjjpDIX41Wf6EDA== To: pv , ysard_git@gmx.fr Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, senozhatsky@chromium.org Subject: Re: Regression: system freeze on resume from suspend introduced by printk per-console suspended state In-Reply-To: References: <87tsxhbtxo.fsf@jogness.linutronix.de> Date: Thu, 08 Jan 2026 10:49:24 +0106 Message-ID: <877bts1ltv.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain On 2026-01-08, pv wrote: > The code in 6.18.2 has changed enough that I don't dare change it as I did in 6.7. > After compiling and installing 6.19-rc1 (8f0b4cce4481fb22653697cced8d0d04027cb1e8), > I can confirm that the freeze is still present. Thanks for confirmation. Would you be willing to try a debugging patch? I have attached a patch (based on 6.19-rc4). It should restore the old console_lock behavior during suspend/resume. Assuming this works for you, it also adds some debugging information so that we can figure out who is locking the console. Please compile with CONFIG_PRINTK_CALLER=y. After suspend/resume, locate the debug lines with: # dmesg | grep printk It will probably look something like this: # dmesg | grep printk [ 12.085727][ T843] printk: Suspending console(s) (use no_console_suspend to debug) [ 12.236199][ T843] printk: console_suspend [ 17.581734][ T67] printk: console_lock [ 17.583711][ T67] printk: console_unlock [ 17.644819][ T843] printk: console_lock [ 17.644823][ T843] printk: console_unlock [ 17.644827][ T843] printk: console_resume If you have CONFIG_PRINTK_CALLER enabled (as I do here), it will show the tasks locking the console. In my case it is PID 67 and 843. It would be nice to know who these are. For me it is: # cat /proc/67/comm kworker/2:1-mm_percpu_wq # cat /proc/843/comm sh So in summary, I would like to know: 1. Does suspend/resume work on 6.19-rc4 with this patch applied? 2. Output of "dmesg | grep printk" (after suspend/resume) 3. Which tasks were locking the console between console_suspend and console_resume? Your help in debugging this is greatly appreciated. John Ogness --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-printk-Debug-new-vs.-old-suspend-resume-behavior.patch >From f3bb7d49b59b61a30f2fefc2b241d3f535b2afd2 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Thu, 8 Jan 2026 09:31:51 +0000 Subject: [PATCH] printk: Debug new vs. old suspend/resume behavior This is just for debugging. It should restore the old console_lock behavior for suspend/resume and also adds some debugging information. Please compile with CONFIG_PRINTK_CALLER=y so that we can see which tasks are locking/unlocking the console during suspend/resume. --- kernel/printk/printk.c | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 1d765ad242b8..fd69cab4368e 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -356,6 +356,22 @@ static void __up_console_sem(unsigned long ip) */ static int console_locked; +static int console_suspended; + +int vprintk_store(int facility, int level, + const struct dev_printk_info *dev_info, + const char *fmt, va_list args); + +/* Helper function to store-only. */ +static void printk_store(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vprintk_store(0, LOGLEVEL_DEFAULT, NULL, fmt, args); + va_end(args); +} + /* * Array of consoles built from command line options (console=) */ @@ -2841,6 +2857,15 @@ void console_lock(void) msleep(1000); down_console_sem(); + if (console_suspended) { + printk_store(KERN_INFO "printk: %s\n", __func__); + /* + * Keep console locked, but do not touch + * @console_locked or @console_may_schedule. + * (Although they will both be 1 here anyway.) + */ + return; + } console_locked = 1; console_may_schedule = 1; } @@ -2861,6 +2886,15 @@ int console_trylock(void) return 0; if (down_trylock_console_sem()) return 0; + if (console_suspended) { + printk_store(KERN_INFO "printk: %s\n", __func__); + /* + * The lock was acquired, but unlock directly and report + * failure. Here console_locked=1 and console_may_schedule=1. + */ + up_console_sem(); + return 0; + } console_locked = 1; console_may_schedule = 0; return 1; @@ -3354,6 +3388,16 @@ void console_unlock(void) { struct console_flush_type ft; + if (console_suspended) { + printk_store(KERN_INFO "printk: %s\n", __func__); + /* + * Simply unlock directly. + * Here console_locked=1 and console_may_schedule=1. + */ + up_console_sem(); + return; + } + printk_get_console_flush_type(&ft); if (ft.legacy_direct) __console_flush_and_unlock(); @@ -3559,6 +3603,7 @@ struct tty_driver *console_device(int *index) void console_suspend(struct console *console) { __pr_flush(console, 1000, true); + console_list_lock(); console_srcu_write_flags(console, console->flags & ~CON_ENABLED); console_list_unlock(); @@ -3570,6 +3615,12 @@ void console_suspend(struct console *console) * using the port. */ synchronize_srcu(&console_srcu); + + console_lock(); + console_suspended = 1; + printk_store(KERN_INFO "printk: %s\n", __func__); + /* Unlock directly (i.e. without clearing @console_locked). */ + up_console_sem(); } EXPORT_SYMBOL(console_suspend); @@ -3597,6 +3648,16 @@ void console_resume(struct console *console) defer_console_output(); __pr_flush(console, 1000, true); + + down_console_sem(); + printk_store(KERN_INFO "printk: %s\n", __func__); + console_suspended = 0; + /* + * Perform a regular unlock. + * Here console_locked=1 and console_may_schedule=1. + * @console_unlocked will be cleared. + */ + console_unlock(); } EXPORT_SYMBOL(console_resume); -- 2.30.2 --=-=-=--