From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7455F39A7FF for ; Wed, 14 Jan 2026 13:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768396346; cv=none; b=G5GSdExoE5G2iVmtPHxhEruPulahI7zArvddm1yHSco+6heRLHyLMIy+ih/TB28G/sTh5a+WdvxHLfiSTPL6sg/xcTW8GcjuaUTzieJ3Gb+oCpUuvJPzSTELS1Twljn2vZBH1jbG3ijwT0KB5jv8WCKPM05Gs89OI+jS2opJKiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768396346; c=relaxed/simple; bh=qVQVDrDK8GQt0EFjDkN2BeDB9NxS3hqaAC/BXhJUBXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VDvtgNbCk1aqgyy6TtRqx0/ZqM+9lRAS6dANC/PK1+t9eFvvOQWdT1BoSZWb8n/BfiGp0CysOi8xcFzpLKq/Dwf7zrvHO9jO9wCgRtqIMAZho2NV1xIuI5/01Lze0TST1ohBEGeA+n6ENFXI8uOVPORfXQFyAYT6K6gdqr+9iQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=aWolcuWY; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="aWolcuWY" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47795f6f5c0so54528315e9.1 for ; Wed, 14 Jan 2026 05:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768396342; x=1769001142; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ucpTGToIn8N6Wm60fm7MZ05SRRlKYptl+ek5X25PfwQ=; b=aWolcuWYJf6Ct/NWQt6rExuRtGu3LFOudFYsGbsTnoG1JSvl2EkPbO/rwX483SQP4C pq+N1613z+QGsd3+cQmuZQY2dTA1+dNH+/pK6fKFvPht2v/0CSotYuEcy6K+Gleu2Lza tTMASq4xczVUrzU+yCJiYMdvOF5NjqYrekE+yjnbMK8aJTx5aa1Qr9V7uHjINZRmQ2Bk O0B3IT0MWJoBonuK7cH3MAH9v89poQixipOhPiMGt9As9H+5tMMdFoV5oUi2G0anJjR3 W4piGmZHO7uQ2l5p20BhJjuRHZkRlg/Oa7Wu0iPffIImEF+o2TBhf2OwkcCv07QdI3xY jDTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768396342; x=1769001142; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ucpTGToIn8N6Wm60fm7MZ05SRRlKYptl+ek5X25PfwQ=; b=dkIRHbSFM4D+9j3Z+4sK0pgNWh2906xilL8DHzX3Vuhh/T0bDMhM7hCZpSe+nf+bOI 6fgWh2m670zKE4dxtUujr9TTPN5Ey7tMCNVh1I5TRS52eEGVXUf5f+zBIaTsKI/Gent7 Bd7mxYoDPivX4DnC8duAy/uxijFLTS4eN5FuEw5eqD+9h5PVhoPAot/h04E8pMk8snnp ITFfx8KuOLxoqrCKuzAYHSsnVBjOFju3xnluR9v3yFcrZZJzsoXjFD3dK99cSmDO0IC3 clDGn6v/x+yzYN4ycd20DrIWYJlnqTKfSlQYPOoCllkL0s/CvRaPXM29wzUUdLhwPAOm 9mLw== X-Forwarded-Encrypted: i=1; AJvYcCWEgnF22Zdd4JW2AXYF+jY5gwJ6UrB50ceGbdXAdSuwdubHl8SwAJSRWesjourPxkwJcILRiZIpZPk31uk=@vger.kernel.org X-Gm-Message-State: AOJu0YxhvW+hfN3Fxr0KFvdNNFZhJxxa18LNodBU7fde89bNOrVCedjD Q9IuQ4EkgQw9PCgN8nYqk/+vIDzH9p3FZq6VwEMyFcA/VRlMeSnUQqZfAUNfmXccUeA= X-Gm-Gg: AY/fxX4hKH/xfTOZRovsTzQFkU7pqFBHJua7DpbDfYTIyPJKPgXGnX8WKoIzRG7D/w2 AcTTJwktsu6qEhbcH1tD3rrFDoAptOYwEdYc+RfWyYHTblHsCQG6+MI0PpMWth6CGeM+Ffh02nV cRyzkjp149Kqp5X7SEd0inTLbXNDgbZmHbP97MQK1T4bcNd4BztW2csksPjZL2BZ+Oq3VRaKMtj gK+vM91Ja3xN7DxXqhEZ9pTCZh20Ux32WcScb7/KBuaAdWM57B8Wn7DhYS1P0+KWJTJEbAawBVW xg2J4OyEhyoWOpmiEcGEaPUXl58uGyk0LlwKuuoRgJcaYCil/fbiEnhS3CwYs3KAAjRtyvjD8fz nUF/SuI5KQMY5Z26qEtztLIChCzpTBRvs+ZBfWVBZnQ6JRAUNYpqft6jC3zljft38DyWR7km/1A 51j6vmik49rXNAYWTyvGVHB0wH X-Received: by 2002:a05:600c:5490:b0:479:3876:22a8 with SMTP id 5b1f17b1804b1-47ee3356d5dmr36820375e9.16.1768396341643; Wed, 14 Jan 2026 05:12:21 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47ee54b8c9bsm27274065e9.3.2026.01.14.05.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 05:12:21 -0800 (PST) Date: Wed, 14 Jan 2026 14:12:18 +0100 From: Petr Mladek To: Marcos Paulo de Souza Cc: Richard Weinberger , Anton Ivanov , Johannes Berg , Greg Kroah-Hartman , Jason Wessel , Daniel Thompson , Douglas Anderson , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jiri Slaby , Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Andreas Larsson , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Jacky Huang , Shan-Chun Hung , Laurentiu Tudor , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, netdev@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 04/19] printk: Reintroduce consoles_suspended global state Message-ID: References: <20251227-printk-cleanup-part3-v1-0-21a291bcf197@suse.com> <20251227-printk-cleanup-part3-v1-4-21a291bcf197@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251227-printk-cleanup-part3-v1-4-21a291bcf197@suse.com> On Sat 2025-12-27 09:16:11, Marcos Paulo de Souza wrote: > This change partially reverts commit 9e70a5e109a4 > ("printk: Add per-console suspended state"). The intent of the original > commit was to move the management of the console suspended state to the > consoles themselves to be able to use SRCU instead of console lock. > > But having a global state is still useful when checking if the global > suspend was triggered by power management. This way, instead of setting > the state of each individual console, the code would only set/read from the > global state. > > Along with this change, two more fixes are necessary: change > console_{suspend,resume} to set/clear CON_SUSPEND instead of setting > CON_ENABLED and change show_cons_active to call __console_is_usable to > check console usefulness. I would invert the logic a bit. I think that the main motivation is to replace CON_ENABLE -> CON_SUSPEND. The flag CON_ENABLE is cleared when serial drivers get suspended. This "hack" has been added by the commit 33c0d1b0c3ebb6 ("[PATCH] Serial driver stuff") back in v2.5.28. Stop hijacking CON_ENABLE flag and use the CON_SUSPEND flag instead. Still allow to distinguish when: - the backing device is being suspended, see console_suspend(). - the power management wants to calm down all consoles using a big-hammer, see console_suspend_all(). And restore the global "consoles_suspended" flag which was removed by the commit 9e70a5e109a4 ("printk: Add per-console suspended state"). The difference is that accesses to the new global flag are synchronized the same way as to the CON_SUSPEND flag. It allows to read it under console_srcu_read_lock(). Finally, use __console_is_usable() in show_cons_active(). It is the last location where the CON_ENABLED flag was checked directly. The patch should not change the existing behavior because all users check the state of the console using console_is_usable(). > diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c > index e2d92cf70eb7..7d2bded75b75 100644 > --- a/drivers/tty/tty_io.c > +++ b/drivers/tty/tty_io.c > @@ -3552,9 +3552,9 @@ static ssize_t show_cons_active(struct device *dev, > for_each_console(c) { > if (!c->device) > continue; > - if (!(c->flags & CON_NBCON) && !c->write) > - continue; > - if ((c->flags & CON_ENABLED) == 0) > + if (!__console_is_usable(c, c->flags, > + consoles_suspended, > + NBCON_USE_ANY)) It would be better to move this into a separate patch. > continue; > cs[i++] = c; > if (i >= ARRAY_SIZE(cs)) Otherwise, it looks good. Best Regards, Petr