From nobody Mon Apr 13 16:58:10 2026 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 E0741C4332F for ; Mon, 14 Nov 2022 16:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237671AbiKNQag (ORCPT ); Mon, 14 Nov 2022 11:30:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237427AbiKNQ3q (ORCPT ); Mon, 14 Nov 2022 11:29:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A1B1D329 for ; Mon, 14 Nov 2022 08:29:42 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443381; h=from:from:reply-to:subject:subject: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=15kv2lfD0mZOWcVuclsvK9b1h/ynFw4leTYyP0YL6rw=; b=okh6A5QlkjpXnF9pvfDJcTztMcEqPE2ZSnWcrrxa3D8kuKAc8UTMRdT0c1hkuitjBXNNDM jhHlWRLXkX8q9iegblR2CQvjQgraDlaLGzqYlVGZUtAz/peO9lIHwhcH7h1SfDRDWjE0Jo pADbPTE4O44NqmyRyRKpjdsMVrW2yKAmXFF9mR03SnaMxDiX6ShaX066yswHAj21BHuVaf nvUjYGkkyBujbFZc+zxYh+0ZoO2NgyKwLLgfFWY11jLxO5ZPI50GRVptsLOOlyWfGYmQZu ex+5XtJByUT6RcllQbiHE3xIW2f2CcmN4+kl12Xb5IVcrAfkXFDOIC8rtAp0yg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443381; h=from:from:reply-to:subject:subject: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=15kv2lfD0mZOWcVuclsvK9b1h/ynFw4leTYyP0YL6rw=; b=OQIMQpLs1oTaVmqPcyzpUCH3snN/rsTE4GnEQR/mf0gHB+XdIdbvEWEUX7kbVh7tAr4HIb PFUVAyeQcHj6mwBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 16/39] printk: console_is_usable: use console_srcu_read_flags Date: Mon, 14 Nov 2022 17:35:09 +0106 Message-Id: <20221114162932.141883-17-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-1-john.ogness@linutronix.de> 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" All users of console_is_usable() are SRCU iterators. Use the appropriate wrapper function to locklessly read the flags. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3d9e5bb1a50b..bc563972e468 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2708,11 +2708,13 @@ static bool abandon_console_lock_in_panic(void) * Check if the given console is currently capable and allowed to print * records. * - * Requires the console_lock. + * Requires the console_srcu_read_lock. */ static inline bool console_is_usable(struct console *con) { - if (!(con->flags & CON_ENABLED)) + short flags =3D console_srcu_read_flags(con); + + if (!(flags & CON_ENABLED)) return false; =20 if (!con->write) @@ -2723,8 +2725,7 @@ static inline bool console_is_usable(struct console *= con) * allocated. So unless they're explicitly marked as being able to * cope (CON_ANYTIME) don't call them until this CPU is officially up. */ - if (!cpu_online(raw_smp_processor_id()) && - !(con->flags & CON_ANYTIME)) + if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME)) return false; =20 return true; --=20 2.30.2