From patchwork Mon Nov 7 14:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 16431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2077514wru; Mon, 7 Nov 2022 06:19:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM41q7StJPjsXYQbL1dqjBKyLFzPCmfOjiBta8yIlRjaqd4HUhuBX4G51/xRYj7U7XtToOfC X-Received: by 2002:a05:6402:1cca:b0:460:7d72:8f2 with SMTP id ds10-20020a0564021cca00b004607d7208f2mr51152761edb.205.1667830744258; Mon, 07 Nov 2022 06:19:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830744; cv=none; d=google.com; s=arc-20160816; b=hBzMIgjmqdt1SBHfBkxI4p4Nxun9pWyYks2xw0OOKX6O3SjU7EiVIVmLq6QxklAlsl 4svAJfiX7Hv/B48fJXl38x6dEIyYdsmPnM/V4U8lO3qDARU9HqfjrZnvcs6hfkjxzX75 zm3JaRHk8eEa7gXwAXD2JiEMqLbDE2gY753Hl9V4aiErcQjos9y2nEitdhHDbu4gy3Az jsLh8rdhrFH04K1hyYjIR/lbGNhQ+Rn7IeiGWbZ+wAIyT8YmyfQ4bulNgdH1GOca7EMV QntbpDP6912+eOhEUaUa4IScciT3mNlZWN+u9+06hP5c6OXldA3L6KXTw8vuoCCwRlAZ KAzg== 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; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a170906165300b00711da52c6e4si6816401ejd.309.2022.11.07.06.18.34; Mon, 07 Nov 2022 06:19:04 -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; 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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748847290288021114?= X-GMAIL-MSGID: =?utf-8?q?1748847290288021114?= 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;