Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1854601rwb; Mon, 7 Nov 2022 06:35:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM6HnU0cf5MdjFx3QMMEn7/6VEkvQvN/VIlpEKPXN2ZJwYbZDJSg17o+toBL1BAHXMwIMvKX X-Received: by 2002:a05:6402:26cc:b0:462:2426:4953 with SMTP id x12-20020a05640226cc00b0046224264953mr51021123edd.13.1667831708223; Mon, 07 Nov 2022 06:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667831708; cv=none; d=google.com; s=arc-20160816; b=RAc4XGuPC3gZK8qpG/JV7Vys9PTl4tD8xi9Si1+J66f4Q15VvuTMRtlPpscBxDxKr5 7UeLR2OADLC0mafwh4rTyaAhFVgW4ps0Zt2HE3jv6yfHgDbT1QOXKt+1krYhfzS2Scvv UYmeFxXdGvGYMOo6qEZfY4ikOTCHXscWRDg9dit66mvJA+rRtpNvwFt2+smJzrqT6Lx5 bohFXbYyj9mZnp5SeKT/TOZWdAWeT6AB+F9yE0774txxgEssDsa32bUxr0rchpLrdLfz aIb6pqEYTwSA4MoE6TZGAuMmDaOk3UTKlqbZXCF293D367f/33Ijbvzvha6asCqDdezK /i9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=OOJ5rVozh2o4kPFAPBIzU10/hQr/WmijEHoN/lMfTbg=; b=E4QouAHtpRt0M7zhBCAIpX06zwzNA1ARof0uMSXgckPILmczqAefrn2ft8dgkU03x3 Em2NmwvNuOFb/0jBPyvALiG1GphIp9dKgZt8Nz1MbOhvqegMJ7dHEfzwkfmHQ5y+rvYB 0rcG4fnbQLXybKhHijebmQqT9EtltueGacMnuRO66hbwk1yjxly9ZpG8xEJoAEUMCQ8U Of/F9ltWNGGuf94wt/bnC3cM6caVLiG3wmZye3o7wikphjxMMBeqwkrNLrH1UkcxxeF/ +iw0cZ0e1nS91+wk/3an/ho1XMS2UqAi2zV78Dw/xllLwMef1NZUNi3cJ8F7ZqfTHFre PFwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HeyA6jwD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=g1QtfHWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt18-20020a170907729200b0073d710fec77si9901354ejc.251.2022.11.07.06.34.45; Mon, 07 Nov 2022 06:35:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HeyA6jwD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=g1QtfHWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232249AbiKGORV (ORCPT + 94 others); Mon, 7 Nov 2022 09:17:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbiKGOQq (ORCPT ); Mon, 7 Nov 2022 09:16:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C4B1D0DE for ; Mon, 7 Nov 2022 06:16:45 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830604; 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=OOJ5rVozh2o4kPFAPBIzU10/hQr/WmijEHoN/lMfTbg=; b=HeyA6jwDJkk3W2Q7mXT/ixKWhsA8ouQ5x3YmRFUo4cMH60xQZGJzZX4chawitd1iPMWjj5 e1xuQCVukVX/IsrCbyMingnYZs/NrFrV3g2vB9puzYxGOsFAttamfXWa2/AEzrwJLKJRcQ h/dTUY/sLCOQ3ALJOzLIKgc8o2cLApgCDYNxlsd1HDZTKaiK36/f73EdhXvxpB1sEQNFX4 eYvXjSX7BxLoMcYxICFQ40UmRRi6kb1tMPBwFVEy3dZUZg3OQvwWIsaDHdfaEX8N++xjka 4Cvw+xRujtByhc+iJy5WmkPysbqKCqQZ3Yo4U/3G0aDl6A+SZoOd5KpBwm5OTA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830604; 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=OOJ5rVozh2o4kPFAPBIzU10/hQr/WmijEHoN/lMfTbg=; b=g1QtfHWB/sN4/tDQrxu15t2rQx2DDWU9losLN3bT+0thLU62fNQqOH+iBtBaUXZTVGdnUB Hhw8EHn92GjSS5AQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v3 08/40] printk: use console_is_enabled() Date: Mon, 7 Nov 2022 15:22:06 +0106 Message-Id: <20221107141638.3790965-9-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace (console->flags & CON_ENABLED) usage with console_is_enabled() if it involves a data race. Otherwise add comments mentioning why the wrapper is not used. Note that this is a preparatory change for when console_lock no longer provides synchronization for console->flags. Signed-off-by: John Ogness --- kernel/printk/printk.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 79811984da34..f243bb56a3ba 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2660,7 +2660,7 @@ static bool abandon_console_lock_in_panic(void) */ static inline bool console_is_usable(struct console *con) { - if (!(con->flags & CON_ENABLED)) + if (!console_is_enabled(con)) return false; if (!con->write) @@ -2946,7 +2946,7 @@ void console_unblank(void) console_locked = 1; console_may_schedule = 0; for_each_console(c) - if ((c->flags & CON_ENABLED) && c->unblank) + if (console_is_enabled(c) && c->unblank) c->unblank(); console_unlock(); @@ -3104,8 +3104,11 @@ static int try_enable_preferred_console(struct console *newcon, * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept the pre-enabled consoles only when match() * and setup() had a chance to be called. + * + * Note that reading @flags is race-free because the console is not + * yet added to the console list. */ - if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) + if ((newcon->flags & CON_ENABLED) && (c->user_specified == user_specified)) return 0; return -ENOENT; -- 2.30.2