From nobody Fri Dec 19 21:47:25 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4685FE92FF8 for ; Fri, 6 Oct 2023 08:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbjJFIW0 (ORCPT ); Fri, 6 Oct 2023 04:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbjJFIWU (ORCPT ); Fri, 6 Oct 2023 04:22:20 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17CA8E9 for ; Fri, 6 Oct 2023 01:22:19 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BDF481F45F; Fri, 6 Oct 2023 08:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1696580537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u6SBGQGzlYESoIH6xOm7vdZvHrnG75JguFK7bNCgoCE=; b=KdQ4PKYaOyDahDV/SMQI7xizMeFE7j1Wku2izmCQSu9FjD7VG6TcP3EvnN4oXvtBYxb//s FdCA3LXgujZ43Mt/5/Tv4RFlu9DypqY+Sorgq2cc9B8X8O1DEhDz5Cy1I7uQLsHZhTODbw xkx9hEfyCzLi3XBNB5ABfjvKx55e4Is= Received: from alley.nue2.suse.org (pmladek.udp.ovpn1.nue.suse.de [10.163.31.190]) by relay2.suse.de (Postfix) with ESMTP id 6993D2C142; Fri, 6 Oct 2023 08:22:17 +0000 (UTC) From: Petr Mladek To: John Ogness , Sergey Senozhatsky , Steven Rostedt Cc: Thomas Gleixner , Todd Brandt , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH v2 1/2] printk: flush consoles before checking progress Date: Fri, 6 Oct 2023 10:21:50 +0200 Message-Id: <20231006082151.6969-2-pmladek@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231006082151.6969-1-pmladek@suse.com> References: <20231006082151.6969-1-pmladek@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: John Ogness Commit 9e70a5e109a4 ("printk: Add per-console suspended state") removed console lock usage during resume and replaced it with the clearly defined console_list_lock and srcu mechanisms. However, the console lock usage had an important side-effect of flushing the consoles. After its removal, consoles were no longer flushed before checking their progress. Add the console_lock/console_unlock dance to the beginning of __pr_flush() to actually flush the consoles before checking their progress. Also add comments to clarify this additional usage of the console lock. Note that console_unlock() does not guarantee flushing all messages since the commit dbdda842fe96f89 ("printk: Add console owner and waiter logic to load balance console writes"). Reported-by: Todd Brandt Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D217955 Fixes: 9e70a5e109a4 ("printk: Add per-console suspended state") Co-developed-by: Petr Mladek Signed-off-by: Petr Mladek Signed-off-by: John Ogness --- kernel/printk/printk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7e0b4dd02398..0b3af1529778 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3740,12 +3740,18 @@ static bool __pr_flush(struct console *con, int tim= eout_ms, bool reset_on_progre =20 seq =3D prb_next_seq(prb); =20 + /* Flush the consoles so that records up to @seq are printed. */ + console_lock(); + console_unlock(); + for (;;) { diff =3D 0; =20 /* * Hold the console_lock to guarantee safe access to - * console->seq. + * console->seq. Releasing console_lock flushes more + * records in case @seq is still not printed on all + * usable consoles. */ console_lock(); =20 --=20 2.35.3