From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 0058A37E2F2 for ; Wed, 14 Jan 2026 08:44:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768380267; cv=none; b=HD3o+1EaotoW+2ZvkBoivvxuRjf/CJsbNIg4MAOvNmbypO36oH6ocOv4dES5EMsXUhnNKjEacM4Fym3dm8ZAdKdmW4qkN14SEExXrkWcf1B0wCCdfIXaGzoNv69hryWj1lE9mA/w4oACMkNUwNdEKF6EdY1/sUiGXkGIX44hUXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768380267; c=relaxed/simple; bh=ysd4WYTvCh9+HsQ1AtbOfW5FzL4/iKQHwd6lm5bPF7A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mMKl21FZ2PlsvMC51eq5MIUxVMwqseTwS2IkzSc0uHty13CVtvuprx5vf+OXCIgMwiWXWGDteW9IgqYjdQ0c67/66vZdxk760n5jxt+mr5IunsSVK8x2VZZWtj5ofjPbb3KcmKiAzRbXCnHSzdPSoXOH41/Y7erjk10C/hFrbpA= 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=UJDpRkoJ; arc=none smtp.client-ip=209.85.221.48 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="UJDpRkoJ" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-432d256c2e6so4679595f8f.3 for ; Wed, 14 Jan 2026 00:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768380255; x=1768985055; 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=/Nn9M/VPDoeuifL+P7no8o5FApQZk7zNKYvSR+p2CRU=; b=UJDpRkoJ07RgspaR1NhfCpR626ZyVYHDm/91x63cM8gsy5+B8MAqHavRm979cqv826 adfCBmE4P0x6kfOJf6QVKQ+F73K8lwHrXn3rzPWHcqFa3N4E1nvvheWr+fvWlsfjnG3d q5I4aa3r8n+1bnVHkuJKjH4VnxEE0Ax/OlO+0AlsTNmjx9JmMpIQmGfXyFrUV7bjE4AG b+aIpJVdS5yOciq4wFCdKoOH2ygYDkIIMtINtTrq5bEwn2hZxdIsOnH1Mevl7p3aXRkT mmHrpfvAEIKMqwJsI6Dxxcv5mSGvyKeQIfwtfaMbksOr61rqb70D/17uospsX2LrpTOB fjgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768380255; x=1768985055; 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=/Nn9M/VPDoeuifL+P7no8o5FApQZk7zNKYvSR+p2CRU=; b=RXeu9IKaUMr3hw6liwcLlIfVY8cmDTqzmfU9Mjk3QW+gD7CwRmUSjCaqYm2JZSV06N +FsQ7taA+ogu0pqlVTGKch7PVmr6y7uJKbRiUU8lYEejpUuMnAf9ZitdAkNtJlhSp67X yZyD8yGBqZGlsdbJ0I28QchAG85WA/z1nOp/olE8gydM0hDG8dJKKol5PbOSv+25kx29 /lm/wjLHglYuUzJ4ykiFJi4YbrQnEq7c0KVWI/Td61gvKZpYjEFxSsL08Z+e+4a47vx6 w/7b74UTNAjR4KJ34qc5H2iBXOk7UyuHCElUTlEpVGNV4/WxD4N2EXVrzczIFJRv0sUp 57Ww== X-Forwarded-Encrypted: i=1; AJvYcCUA5LwTbZhV4xGZaq01ejPupjrhPcWFbM5W4ar1yVjhFjPPXTpw0bLWoCmNMgO4N115uogERIYlDCIUrqQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx5HKira4Tdnfybs0sw7IRkruwnbQx65MsNP1mHqgYzskDxTtL +lxswoSA8R5qyLAvQ2/c8loP4RbSV4URuy2OtvNY1yAw7aWRYdaa6+VPT8VNAqKUwow= X-Gm-Gg: AY/fxX5eh+TlZys7z56DaYEOLZhOhucR6y+UnIxf7t1N9OwEHGlpHDtH4MKdYEitF76 gnxp4VhbGLnZf8NbiExX8KHY5cFACPUB2CC2xzBG691/jYRtk0yCzHwkkHkVMLXdIWdQQDRJDzi lKYQMQHh1ADiP6DnIXlvg8V5eb73RvIv2Pk2xj8vDBo+vk52Icg2rAADq9jltI81hThVvP8fDpI vwnfaUYz7i4wyFOU3gGqcu+AWzpjIwx6tRiy1TYMe7ORfv9tvHBQk44tpClL/3UDo+kmoAPKER0 upu4LI7cmbD6QEFkb0r8Q+BUyvSCes4oYN78+nYW43bWKZOkyGV2YSHt0FY46re+6BEFhy3iNSa aSXYGOZYQBwQKBptRVnafoqyXthSVBUwzU8VenZkO06ut09Dv/dWCTpMn+BoZznBM//9IDPGuSj ZtWGYmiWpFgdmpeA== X-Received: by 2002:a05:6000:61e:b0:431:a38:c2f7 with SMTP id ffacd0b85a97d-4342c574bedmr1500621f8f.59.1768380254886; Wed, 14 Jan 2026 00:44:14 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ee5e3sm48685590f8f.35.2026.01.14.00.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 00:44:14 -0800 (PST) Date: Wed, 14 Jan 2026 09:44:11 +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 03/19] printk: Drop flags argument from console_is_usable Message-ID: References: <20251227-printk-cleanup-part3-v1-0-21a291bcf197@suse.com> <20251227-printk-cleanup-part3-v1-3-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-3-21a291bcf197@suse.com> On Sat 2025-12-27 09:16:10, Marcos Paulo de Souza wrote: > The flags argument was also used to check if CON_NBCON was set, but their > usage was fixed in the last commit. All current users are reading the > variable just to call console_is_usable. > > By calling console_srcu_read_flags inside console_is_usable makes the > code cleaner and removes one argument from the function. > > Along with it, create a variant called __console_is_usable that can be > used under console_list_lock(), like unregister_console_locked. > > --- a/include/linux/console.h > +++ b/include/linux/console.h > @@ -656,13 +656,8 @@ extern bool nbcon_kdb_try_acquire(struct console *con, > struct nbcon_write_context *wctxt); > extern void nbcon_kdb_release(struct nbcon_write_context *wctxt); > > -/* > - * Check if the given console is currently capable and allowed to print > - * records. Note that this function does not consider the current context, > - * which can also play a role in deciding if @con can be used to print > - * records. > - */ > -static inline bool console_is_usable(struct console *con, short flags, > +/* Variant of console_is_usable() when the console_list_lock is held. */ Nit: The comment is a bit misleading because this function is called also from console_is_usable() under console_srcu_read_lock(). I would say something like: /* * The caller must ensure that @con can't disappear either by taking * console_list_lock() or console_srcu_read_lock(). See also * console_is_usable(). */ > +static inline bool __console_is_usable(struct console *con, short flags, > enum nbcon_write_cb nwc) > { > if (!(flags & CON_ENABLED)) > @@ -707,6 +702,18 @@ static inline bool console_is_usable(struct console *con, short flags, > return true; > } > > +/* > + * Check if the given console is currently capable and allowed to print > + * records. Note that this function does not consider the current context, > + * which can also play a role in deciding if @con can be used to print > + * records. And I would add here something like: * * Context: Must be called under console_srcu_read_lock(). > + */ > +static inline bool console_is_usable(struct console *con, > + enum nbcon_write_cb nwc) > +{ > + return __console_is_usable(con, console_srcu_read_flags(con), nwc); > +} > + > #else > static inline void nbcon_cpu_emergency_enter(void) { } > static inline void nbcon_cpu_emergency_exit(void) { } Otherwise, it looks good. It is a nice clean up. Best Regards, Petr