From patchwork Wed Oct 19 14:55:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377671wrs; Wed, 19 Oct 2022 08:07:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GSMAb1vnoeQIDVOj2gZAZFY+8R0FPC06ftR1HrupvQ/itN+BMuTlrt+QamFYMAkJs5maA X-Received: by 2002:a17:906:da85:b0:741:40a7:d08d with SMTP id xh5-20020a170906da8500b0074140a7d08dmr7541141ejb.263.1666192060099; Wed, 19 Oct 2022 08:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192060; cv=none; d=google.com; s=arc-20160816; b=DE3P3iaYMNas2qVxaQUvE/bcqGY5UDBs/iYJI36ETe474eX3mhJ8+HHAcgb0ETsBUt 1bGPrRQt/r/De5YEF1ISVQaCNS/xQdb4VMBSPDS2RfIQ8GFofJznAJ0d64Mlup/knFgH 4BmKtSGS/1vUz9QYSAv1ITlLtO2ncdziFpzSKvoS+korBxhIQqe9GzDsDsDxVhX1rfYr PMof9RF6vpmqAU2qeFgYKZ5Wn7h0FMDCvpv7tNO0JJR5zzE3J+wrJXwtDn9UUG1+z4a6 lmKqSELoX3FSdjSKg5GpUtVo8gLSX7Un3zRunUqPLqtYFHI7/pLGPnxX6hrm/mmFJOsS Hb7A== 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=NEhmZhH2pnDE6WuTxQwMCcvi/RbMP+L4l7DVKXhScfQ=; b=01d6tYg9jyyt70RnWgtDOyUlG7bBg7q/FYigf1rxtTQbeFTu+4aNAOKYwc0dvvxK1/ ZMuPAlJ1pipT9vC5N4U3uuEufBnBtlI4bWtl6Cx547OTg1kM/ZfdrTXViiP3u92silSE C4SUWICwEB7H0pFAuSr6DDxq83MJf48lR46WXay3wvgogtGZxEk40gWQMuSGDw6Ah7C9 4HLhi+EjshwsvV0u1hb6IhbSTeDCg+YE8CL+dGGrxoAJl4PEB3S7LJEnxV3Qx16wqviI RpUEzOs4pfBLdB7sFP7QaB254tAdtc6osZhqlTwTWR61Fv/e6wiLSOiv3NlG5b6nTiBi CttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WkJA4pqm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aDl1Im9Q; 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 q12-20020a170906770c00b0077f4362c957si12361546ejm.702.2022.10.19.08.07.04; Wed, 19 Oct 2022 08:07:40 -0700 (PDT) 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=WkJA4pqm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aDl1Im9Q; 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 S231824AbiJSPDA (ORCPT + 99 others); Wed, 19 Oct 2022 11:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231282AbiJSPCq (ORCPT ); Wed, 19 Oct 2022 11:02:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A777C15D0A5; Wed, 19 Oct 2022 07:57:25 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191363; 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=NEhmZhH2pnDE6WuTxQwMCcvi/RbMP+L4l7DVKXhScfQ=; b=WkJA4pqmnV5juPN/ttgFR+jALEcs6JiTFkAuj55fv1Kc9Cx9UAm1N2rezLQc4WaDTdI/Ez m/HFdf7pZqHhdxeVSxmJ/wOoDKSjiMkAqJ8syecbdqYLzx9aZNdxjA9PJjkX7XcCeN9bSn bNe0JNx3plnLRTHu6/TZEDVzHEPTgZuc1wDuCH0zd719J7sckLPTqVJ2fAeNX8P7melcni 0q6XH6+z5F33XWbnvc5mJtt5eRYubPRu1pN8zAtwSWT7NlR9AjihtUMfpyxtPV4FPukpwg awmFOtjaGtFa430Q5t3JRNOLPoKJdpHRQeR0xyjB/xzpitnezB7/EUhmrWpzGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191363; 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=NEhmZhH2pnDE6WuTxQwMCcvi/RbMP+L4l7DVKXhScfQ=; b=aDl1Im9QlC7jXBpafB/JPa5shMExjhVLO58+NwKbR8EV60/QUyHkbiIXWH+jwcsUkqMUn9 dwjFqk2pmsScIoAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 01/38] serial: kgdboc: Lock console list in probe function Date: Wed, 19 Oct 2022 17:01:23 +0206 Message-Id: <20221019145600.1282823-2-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129005698716802?= X-GMAIL-MSGID: =?utf-8?q?1747129005698716802?= From: Thomas Gleixner Unprotected list walks are not necessarily safe. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Petr Mladek Reviewed-by: Greg Kroah-Hartman Reviewed-by: Sergey Senozhatsky Reviewed-by: Douglas Anderson --- drivers/tty/serial/kgdboc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 7aa37be3216a..e76f0186c335 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -193,6 +193,7 @@ static int configure_kgdboc(void) if (!p) goto noconfig; + console_lock(); for_each_console(cons) { int idx; if (cons->device && cons->device(cons, &idx) == p && @@ -201,6 +202,7 @@ static int configure_kgdboc(void) break; } } + console_unlock(); kgdb_tty_driver = p; kgdb_tty_line = tty_line; From patchwork Wed Oct 19 14:55:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377698wrs; Wed, 19 Oct 2022 08:07:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VlED1UsHEaZUu3Tt6hFj7Lbtrf/QRKErN7W3l5AcFk4b7GeETH/o2feWWfFCbSVfeyshB X-Received: by 2002:a17:907:2708:b0:78d:d22b:c8a9 with SMTP id w8-20020a170907270800b0078dd22bc8a9mr7220140ejk.640.1666192063436; Wed, 19 Oct 2022 08:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192063; cv=none; d=google.com; s=arc-20160816; b=XWYo+AGzq7IOAAzWhmdi7w30cHbD8sLplnHaLmL2tSSsilW7QE1tmy6UXzK1r1M7Fs 3GgIQ+8HzTaosDdAjN8bvV6DhQd4c+DNXIutJo1xN5EOuTsm0xwWVmaFUOF0fJoIteHs vS1IQUPJLZvUyltBgy4qSF/RXfVRTsO/6kcLKOiYPOFxwgYreooTww3rsswjm9WUznyO pYNcHXvWBTRJ9NG1cZ/8VfSUaACr2D5tqqj6o5Zw0TO6zSUmgRI3aTSNqeXSVzy2Dgei 48wdrHJFRejqLz3zGkEbW1W9dUMEhaZ+OvAdblAlUfgh2uzn8WTaPCqQLdhMp4Pp+YVV l1rQ== 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=ecwQGTiJHvr9yJfbRjmW+23+PW75dBYvC1lV+461LH0=; b=vpvYVSB7vmotKudsV18h1SGwkeVffzfp1u713YPGkprMmsgoin7lo80WFzTOKo/STT HmyFIbalbxVC2ZzwYRzpRS5sXxXeXGfEokYUb/sj5+i5U5V0i/dZ2zTUdQopTVOWKtcM DIYrPhqnitmG/hJ3UGEpFJeel8OEEJFm3kQRj8mBkeUDL7+9aDhX4FEPPxfam79rBtXm BbpEGlVhtiWAbAgc9gzqUEW8snEKyEhWRj7uZtWykVIz9vWYNL76XUROeGhJyGMNmKvT 0bD7GYm8OG5D1ck2JAfb1AHSsTSaqUDNDbHl+j0qTSxMW97rHtH5hQM+m9KTgzzm9jFI bH/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vumeh2cg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=URfApYAA; 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 b12-20020a056402278c00b00447a7af56b2si16176820ede.326.2022.10.19.08.07.05; Wed, 19 Oct 2022 08:07:43 -0700 (PDT) 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=vumeh2cg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=URfApYAA; 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 S230426AbiJSPDF (ORCPT + 99 others); Wed, 19 Oct 2022 11:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbiJSPCq (ORCPT ); Wed, 19 Oct 2022 11:02:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070DA199883; Wed, 19 Oct 2022 07:57:34 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191363; 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=ecwQGTiJHvr9yJfbRjmW+23+PW75dBYvC1lV+461LH0=; b=vumeh2cgLikwlvoyBG+8fjnw+7SiUoMjC1NiLuiD19CCNH+EyD9tuMgF7PjFHly5GZ+q0f zDYqcW7g1xjb3q9bHanG8DV/TsI3RGYqiWMm6tsIYCqLtRjwwnrSLCFRJ67AaaD14EIRvN +nXQb+ldGv1kFpDBnhzve1+pPmgXHJpzjBixNIKiJXGpcS8QMZfCPWLnlKGwaXTTMEQRuc DCuEnIJ7rizwPrmJFyV3m38XDb/+BmQ/PQSh9UgMh4VNH+QLuQiqycKdLLegRn86SvYSEe 1W5eLrqXvIYtxS/X7Qv595y4F8uCBWXcCOaPtnGDlD7tLiPdn3SZIoPD1Uqryg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191363; 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=ecwQGTiJHvr9yJfbRjmW+23+PW75dBYvC1lV+461LH0=; b=URfApYAAyZelmd2vmKjK2/tJ2Jg749/DVzo3680V6WWRpxslbjxBM2ChT9YF7UEyCVAKpu BUYPSY/QW6WhmpDw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org Subject: [PATCH printk v2 02/38] printk: Convert console_drivers list to hlist Date: Wed, 19 Oct 2022 17:01:24 +0206 Message-Id: <20221019145600.1282823-3-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129009105245488?= X-GMAIL-MSGID: =?utf-8?q?1747129009105245488?= Replace the open coded single linked list with a hlist so a conversion to SRCU protected list walks can reuse the existing primitives. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek Reviewed-by: Sergey Senozhatsky --- fs/proc/consoles.c | 3 +- include/linux/console.h | 8 ++-- kernel/printk/printk.c | 99 +++++++++++++++++++++++------------------ 3 files changed, 63 insertions(+), 47 deletions(-) diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c index dfe6ce3505ce..cf2e0788f9c7 100644 --- a/fs/proc/consoles.c +++ b/fs/proc/consoles.c @@ -74,8 +74,9 @@ static void *c_start(struct seq_file *m, loff_t *pos) static void *c_next(struct seq_file *m, void *v, loff_t *pos) { struct console *con = v; + ++*pos; - return con->next; + return hlist_entry_safe(con->node.next, struct console, node); } static void c_stop(struct seq_file *m, void *v) diff --git a/include/linux/console.h b/include/linux/console.h index 8c1686e2c233..7b5f21f9e469 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -15,6 +15,7 @@ #define _LINUX_CONSOLE_H_ 1 #include +#include #include struct vc_data; @@ -154,14 +155,16 @@ struct console { u64 seq; unsigned long dropped; void *data; - struct console *next; + struct hlist_node node; }; +extern struct hlist_head console_list; + /* * for_each_console() allows you to iterate on each console */ #define for_each_console(con) \ - for (con = console_drivers; con != NULL; con = con->next) + hlist_for_each_entry(con, &console_list, node) extern int console_set_on_cmdline; extern struct console *early_console; @@ -174,7 +177,6 @@ enum con_flush_mode { extern int add_preferred_console(char *name, int idx, char *options); extern void register_console(struct console *); extern int unregister_console(struct console *); -extern struct console *console_drivers; extern void console_lock(void); extern int console_trylock(void); extern void console_unlock(void); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e4f1e7478b52..867becc40021 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -79,13 +79,12 @@ int oops_in_progress; EXPORT_SYMBOL(oops_in_progress); /* - * console_sem protects the console_drivers list, and also - * provides serialisation for access to the entire console - * driver system. + * console_sem protects console_list and console->flags updates, and also + * provides serialization for access to the entire console driver system. */ static DEFINE_SEMAPHORE(console_sem); -struct console *console_drivers; -EXPORT_SYMBOL_GPL(console_drivers); +HLIST_HEAD(console_list); +EXPORT_SYMBOL_GPL(console_list); /* * System may need to suppress printk message under certain @@ -2556,7 +2555,7 @@ static int console_cpu_notify(unsigned int cpu) * console_lock - lock the console system for exclusive use. * * Acquires a lock which guarantees that the caller has - * exclusive access to the console system and the console_drivers list. + * exclusive access to the console system and console_list. * * Can sleep, returns nothing. */ @@ -2576,7 +2575,7 @@ EXPORT_SYMBOL(console_lock); * console_trylock - try to lock the console system for exclusive use. * * Try to acquire a lock which guarantees that the caller has exclusive - * access to the console system and the console_drivers list. + * access to the console system and console_list. * * returns 1 on success, and 0 on failure to acquire the lock. */ @@ -2940,11 +2939,20 @@ void console_flush_on_panic(enum con_flush_mode mode) console_may_schedule = 0; if (mode == CONSOLE_REPLAY_ALL) { + struct hlist_node *tmp; struct console *c; u64 seq; seq = prb_first_valid_seq(prb); - for_each_console(c) + /* + * This cannot use for_each_console() because it's not established + * that the current context has console locked and neither there is + * a guarantee that there is no concurrency in that case. + * + * Open code it for documentation purposes and pretend that + * it works. + */ + hlist_for_each_entry_safe(c, tmp, &console_list, node) c->seq = seq; } console_unlock(); @@ -3081,6 +3089,9 @@ static void try_enable_default_console(struct console *newcon) (con->flags & CON_BOOT) ? "boot" : "", \ con->name, con->index, ##__VA_ARGS__) +#define console_first() \ + hlist_entry(console_list.first, struct console, node) + /* * The console driver calls this routine during kernel initialization * to register the console printing procedure with printk() and to @@ -3140,8 +3151,8 @@ void register_console(struct console *newcon) * flag set and will be first in the list. */ if (preferred_console < 0) { - if (!console_drivers || !console_drivers->device || - console_drivers->flags & CON_BOOT) { + if (hlist_empty(&console_list) || !console_first()->device || + console_first()->flags & CON_BOOT) { try_enable_default_console(newcon); } } @@ -3169,20 +3180,22 @@ void register_console(struct console *newcon) } /* - * Put this console in the list - keep the - * preferred driver at the head of the list. + * Put this console in the list - keep the + * preferred driver at the head of the list. */ console_lock(); - if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) { - newcon->next = console_drivers; - console_drivers = newcon; - if (newcon->next) - newcon->next->flags &= ~CON_CONSDEV; - /* Ensure this flag is always set for the head of the list */ + if (hlist_empty(&console_list)) { + /* Ensure CON_CONSDEV is always set for the head. */ newcon->flags |= CON_CONSDEV; + hlist_add_head(&newcon->node, &console_list); + + } else if (newcon->flags & CON_CONSDEV) { + /* Only the new head can have CON_CONSDEV set. */ + console_first()->flags &= ~CON_CONSDEV; + hlist_add_head(&newcon->node, &console_list); + } else { - newcon->next = console_drivers->next; - console_drivers->next = newcon; + hlist_add_behind(&newcon->node, console_list.first); } newcon->dropped = 0; @@ -3209,16 +3222,18 @@ void register_console(struct console *newcon) if (bootcon_enabled && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) && !keep_bootcon) { - for_each_console(con) + struct hlist_node *tmp; + + hlist_for_each_entry_safe(con, tmp, &console_list, node) { if (con->flags & CON_BOOT) unregister_console(con); + } } } EXPORT_SYMBOL(register_console); int unregister_console(struct console *console) { - struct console *con; int res; con_printk(KERN_INFO, console, "disabled\n"); @@ -3229,32 +3244,30 @@ int unregister_console(struct console *console) if (res > 0) return 0; - res = -ENODEV; console_lock(); - if (console_drivers == console) { - console_drivers=console->next; - res = 0; - } else { - for_each_console(con) { - if (con->next == console) { - con->next = console->next; - res = 0; - break; - } - } + + /* Disable it unconditionally */ + console->flags &= ~CON_ENABLED; + + if (hlist_unhashed(&console->node)) { + res = -ENODEV; + goto out_unlock; } - if (res) - goto out_disable_unlock; + hlist_del_init(&console->node); /* + * * If this isn't the last console and it has CON_CONSDEV set, we * need to set it on the next preferred console. + * + * + * The above makes no sense as there is no guarantee that the next + * console has any device attached. Oh well.... */ - if (console_drivers != NULL && console->flags & CON_CONSDEV) - console_drivers->flags |= CON_CONSDEV; + if (!hlist_empty(&console_list) && console->flags & CON_CONSDEV) + console_first()->flags |= CON_CONSDEV; - console->flags &= ~CON_ENABLED; console_unlock(); console_sysfs_notify(); @@ -3263,10 +3276,8 @@ int unregister_console(struct console *console) return res; -out_disable_unlock: - console->flags &= ~CON_ENABLED; +out_unlock: console_unlock(); - return res; } EXPORT_SYMBOL(unregister_console); @@ -3317,10 +3328,11 @@ void __init console_init(void) */ static int __init printk_late_init(void) { + struct hlist_node *tmp; struct console *con; int ret; - for_each_console(con) { + hlist_for_each_entry_safe(con, tmp, &console_list, node) { if (!(con->flags & CON_BOOT)) continue; @@ -3340,6 +3352,7 @@ static int __init printk_late_init(void) unregister_console(con); } } + ret = cpuhp_setup_state_nocalls(CPUHP_PRINTK_DEAD, "printk:dead", NULL, console_cpu_notify); WARN_ON(ret < 0); From patchwork Wed Oct 19 14:55:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379182wrs; Wed, 19 Oct 2022 08:10:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43wzvH3QoRExRskXT7Nl9Je776xwSOTNEZLhqm42w9zVrnbTdLXqxREcyd/9XrhsPAFCRw X-Received: by 2002:a17:907:3f89:b0:78d:4cca:3643 with SMTP id hr9-20020a1709073f8900b0078d4cca3643mr7085349ejc.353.1666192227554; Wed, 19 Oct 2022 08:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192227; cv=none; d=google.com; s=arc-20160816; b=WbmKtyd7yERSLak/3ifxaNFxk2XYFDJhf266rAFRQY4hKrOzQWeS/kGFk3ipp3jNbI UBAE2T3wqAfZ3wNEir2iNlIsSBxKsLJQFxxI2hB0HHUj1kIZKg+YYn516ynE4ZXagxIr W4+U9Z6UTQXQxsdbBFizIswbF+xs9ESAaL6jrRh17Cz1aWiROi5fYjfvSnBan3gupQ7S AXcX4emEZDm6YWLLVuU7VsGMzaH5z6kK3uAP6WAS0gdrkGOZi0y3eN9xpFIqeD3W9wNF 2HaXqSo6N++qjFtfUmqOO0mDWhjNHNp7sdKRMeX3wwaYPNOg2dC8GIDvkP9LdktxwgQ9 mTRg== 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=c6Lc6N8r4GU5ofoIRm/xI96rlQR9N7h7xiEY7U0rrdo=; b=uDC0copv4Pzl6srelMoPlEUn4ZGTZ2/7JloAgAjtdkGyuFnBRicyFMtf2JpgqFBoTr Lh3uPE2EBbHL6EucvDjoCuv/9FSOnpzra1AWCXFDL+nWPTUWGhmUw0gn6eq054msiwxV NCKIlSLwE/AbLE/UqEx/C1NQjLbB42sJszvuDMUG1nKsqjyVLPgft5/z/mUs9zigsmTV 59RKwQXHVHnWGUq6DUb6FnM8E9h6qj6Hs/STRlu7eBCg67zpM+le5D31MKunBsPTLUak 9yUINWIdCCtPR2pnznd0W9V0AX8OH1/53By+YOnxE7YgffpQY2R+4vfq3VVzmcpLmBtV dmcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WcKxAuyJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1uEhuY8u; 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 z22-20020a05640235d600b00458d43beac7si17756411edc.41.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:27 -0700 (PDT) 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=WcKxAuyJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1uEhuY8u; 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 S230127AbiJSPDN (ORCPT + 99 others); Wed, 19 Oct 2022 11:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbiJSPCr (ORCPT ); Wed, 19 Oct 2022 11:02:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776EB161FFD for ; Wed, 19 Oct 2022 07:57:27 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191364; 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=c6Lc6N8r4GU5ofoIRm/xI96rlQR9N7h7xiEY7U0rrdo=; b=WcKxAuyJq3DhMytoZZKyfHvx3LUKiASxL0GbPcB1wiS/AN+FmRlf+Y30OSXWRsOlc3wVaq /SWkceKhUAinGtpHYuLE42d1xDizmjhjEIPqbNpXYHfKx9eqLDMDDxK3z2rZn9bPe12Wjg f6gN8yvnfKVrJP55j5feRIueav0JUWVpMkWvXrcpC/cyzetAvy9bjoXWLy1KvwWICGcfBF mN1zr8EeamOVmxzKEDR+Uxrf+ws2dse3cutZnK3IDTinucc0LRHOa4BfCtQmVxO3DMG80z YMl9KMskdAhYkhopMbjExWNpcqwr2+BspZELNDSDJrIfzAOlvm83EsTwjHNC0A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191364; 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=c6Lc6N8r4GU5ofoIRm/xI96rlQR9N7h7xiEY7U0rrdo=; b=1uEhuY8uFfwvbP4a9XQV3e1TWLBlz1xafI012vsQdF6svzD14yCfuelM5LkCwRU3pmoAVa WFoGoc7AIHW8TGDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Miguel Ojeda , "Paul E. McKenney" , Greg Kroah-Hartman Subject: [PATCH printk v2 03/38] printk: Prepare for SRCU console list protection Date: Wed, 19 Oct 2022 17:01:25 +0206 Message-Id: <20221019145600.1282823-4-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129181265398856?= X-GMAIL-MSGID: =?utf-8?q?1747129181265398856?= Provide an NMI-safe SRCU protected variant to walk the console list. Note that all console fields are now set before adding the console to the list to avoid the console becoming visible by SCRU readers before being fully initialized. This is a preparatory change for a new console infrastructure which operates independent of the console BKL. Signed-off-by: John Ogness Acked-by: Miguel Ojeda Reviewed-by: Paul E. McKenney --- .clang-format | 1 + include/linux/console.h | 28 +++++++++++++++- kernel/printk/printk.c | 72 ++++++++++++++++++++++++++++++++--------- 3 files changed, 85 insertions(+), 16 deletions(-) diff --git a/.clang-format b/.clang-format index 1247d54f9e49..04a675b56b57 100644 --- a/.clang-format +++ b/.clang-format @@ -222,6 +222,7 @@ ForEachMacros: - 'for_each_component_dais' - 'for_each_component_dais_safe' - 'for_each_console' + - 'for_each_console_srcu' - 'for_each_cpu' - 'for_each_cpu_and' - 'for_each_cpu_not' diff --git a/include/linux/console.h b/include/linux/console.h index 7b5f21f9e469..cff86cc615f8 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -15,7 +15,7 @@ #define _LINUX_CONSOLE_H_ 1 #include -#include +#include #include struct vc_data; @@ -158,8 +158,34 @@ struct console { struct hlist_node node; }; +#ifdef CONFIG_LOCKDEP +extern bool console_srcu_read_lock_is_held(void); +#else +static inline bool console_srcu_read_lock_is_held(void) +{ + return 1; +} +#endif + +extern int console_srcu_read_lock(void); +extern void console_srcu_read_unlock(int cookie); + extern struct hlist_head console_list; +/** + * for_each_console_srcu() - Iterator over registered consoles + * @con: struct console pointer used as loop cursor + * + * Although SRCU guarantees the console list will be consistent, the + * struct console fields may be updated by other CPUs while iterating. + * + * Requires console_srcu_read_lock to be held. Can be invoked from + * any context. + */ +#define for_each_console_srcu(con) \ + hlist_for_each_entry_srcu(con, &console_list, node, \ + console_srcu_read_lock_is_held()) + /* * for_each_console() allows you to iterate on each console */ diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 867becc40021..e8a56056cd50 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -85,6 +85,7 @@ EXPORT_SYMBOL(oops_in_progress); static DEFINE_SEMAPHORE(console_sem); HLIST_HEAD(console_list); EXPORT_SYMBOL_GPL(console_list); +DEFINE_STATIC_SRCU(console_srcu); /* * System may need to suppress printk message under certain @@ -102,6 +103,11 @@ static int __read_mostly suppress_panic_printk; static struct lockdep_map console_lock_dep_map = { .name = "console_lock" }; + +bool console_srcu_read_lock_is_held(void) +{ + return srcu_read_lock_held(&console_srcu); +} #endif enum devkmsg_log_bits { @@ -219,6 +225,32 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, } #endif /* CONFIG_PRINTK && CONFIG_SYSCTL */ +/** + * console_srcu_read_lock - Register a new reader for the + * SRCU-protected console list + * + * Use for_each_console_srcu() to iterate the console list + * + * Context: Any context. + */ +int console_srcu_read_lock(void) +{ + return srcu_read_lock_nmisafe(&console_srcu); +} +EXPORT_SYMBOL(console_srcu_read_lock); + +/** + * console_srcu_read_unlock - Unregister an old reader from + * the SRCU-protected console list + * + * Counterpart to console_srcu_read_lock() + */ +void console_srcu_read_unlock(int cookie) +{ + srcu_read_unlock_nmisafe(&console_srcu, cookie); +} +EXPORT_SYMBOL(console_srcu_read_unlock); + /* * Helper macros to handle lockdep when locking/unlocking console_sem. We use * macros instead of functions so that _RET_IP_ contains useful information. @@ -2989,6 +3021,9 @@ void console_stop(struct console *console) console_lock(); console->flags &= ~CON_ENABLED; console_unlock(); + + /* Ensure that all SRCU list walks have completed */ + synchronize_srcu(&console_srcu); } EXPORT_SYMBOL(console_stop); @@ -3179,6 +3214,17 @@ void register_console(struct console *newcon) newcon->flags &= ~CON_PRINTBUFFER; } + newcon->dropped = 0; + if (newcon->flags & CON_PRINTBUFFER) { + /* Get a consistent copy of @syslog_seq. */ + mutex_lock(&syslog_lock); + newcon->seq = syslog_seq; + mutex_unlock(&syslog_lock); + } else { + /* Begin with next message. */ + newcon->seq = prb_next_seq(prb); + } + /* * Put this console in the list - keep the * preferred driver at the head of the list. @@ -3187,28 +3233,20 @@ void register_console(struct console *newcon) if (hlist_empty(&console_list)) { /* Ensure CON_CONSDEV is always set for the head. */ newcon->flags |= CON_CONSDEV; - hlist_add_head(&newcon->node, &console_list); + hlist_add_head_rcu(&newcon->node, &console_list); } else if (newcon->flags & CON_CONSDEV) { /* Only the new head can have CON_CONSDEV set. */ console_first()->flags &= ~CON_CONSDEV; - hlist_add_head(&newcon->node, &console_list); + hlist_add_head_rcu(&newcon->node, &console_list); } else { - hlist_add_behind(&newcon->node, console_list.first); - } - - newcon->dropped = 0; - if (newcon->flags & CON_PRINTBUFFER) { - /* Get a consistent copy of @syslog_seq. */ - mutex_lock(&syslog_lock); - newcon->seq = syslog_seq; - mutex_unlock(&syslog_lock); - } else { - /* Begin with next message. */ - newcon->seq = prb_next_seq(prb); + hlist_add_behind_rcu(&newcon->node, console_list.first); } console_unlock(); + + /* No need to synchronize SRCU here! */ + console_sysfs_notify(); /* @@ -3254,7 +3292,7 @@ int unregister_console(struct console *console) goto out_unlock; } - hlist_del_init(&console->node); + hlist_del_init_rcu(&console->node); /* * @@ -3269,6 +3307,10 @@ int unregister_console(struct console *console) console_first()->flags |= CON_CONSDEV; console_unlock(); + + /* Ensure that all SRCU list walks have completed */ + synchronize_srcu(&console_srcu); + console_sysfs_notify(); if (console->exit) From patchwork Wed Oct 19 14:55:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377656wrs; Wed, 19 Oct 2022 08:07:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5tNd9pHIRciA4LXiDKF6WYRywo8Mmz9R9IfOReg3BB4psGnzLnaa/ic0BEb5+27qfptiof X-Received: by 2002:a17:906:2681:b0:783:6a92:4c38 with SMTP id t1-20020a170906268100b007836a924c38mr7238997ejc.75.1666192058804; Wed, 19 Oct 2022 08:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192058; cv=none; d=google.com; s=arc-20160816; b=ouPACtQ+d5wObc8keTmSHFxuEZelTdmYO3rBIMMalAXhFT+1SrYR/VaSbtEhg9Kzfg sr8g/r8NWyNgDTQUjrS6bD9gmeM3E6gfMbEDwjMvMbZ2+S294zga2n/DyZaFeeQJDMWK oMJJNB8v8ZmAc4XMRP7SrL5YiwLHuuC0Sfsk695Py+L5FoF7sNd48SmbeHo31fFjJOyF f/Lq5L4ImLKdzPB9lJREIDb2su7VoKR09HT2xNqJpbqUs1zwgmxUh++TcDOgCNQ256oO jMgD01e95KeQ4D1CdVt5eq2NYBGGm8a0iVxiC2Eh6GJqBa8JmWQEosiAxEZLn/akVkza Zt6g== 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=hllJr9Cenmg6tA9bg55xooViBdr/MaRQODlzmP0LypQ=; b=K1fXp3hF+w2Cfa82JRuFWScSuzP4wkh4R6j6VKkxIcDPSP6fsgQHIj6dcrkq5T0hwg Xeu2HdhGCrW4pZEGJhsOUrfoGGMvl4XyyIG++Mg49OkdgJnPnFCk6nDWzyzgXPSnDVGx FbMekW4zSgH3tL6y/CXWPrNni1P1ggdQBkDSiveqNzGLGE46RNNeXZNmOObTV6MfxEZ7 6zOj2Ya8Auy7RKFdo7Ty37+FWQz+1r1kaqcQxCdzp1DAk+YHSOdBIuYaMY6SySIYVvpZ Rd7uLYUmHcKxZOcGXS09+TMTusNO3p8POZCV0ENmt2A4Nadd67+hYr0aZly+cn89RCqZ HRww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mMoqhcUJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=anaafIfR; 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 gn22-20020a1709070d1600b007429f0c69ccsi17545763ejc.579.2022.10.19.08.07.06; Wed, 19 Oct 2022 08:07:38 -0700 (PDT) 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=mMoqhcUJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=anaafIfR; 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 S231629AbiJSPDm (ORCPT + 99 others); Wed, 19 Oct 2022 11:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiJSPCt (ORCPT ); Wed, 19 Oct 2022 11:02:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E251D17A964 for ; Wed, 19 Oct 2022 07:57:33 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191364; 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=hllJr9Cenmg6tA9bg55xooViBdr/MaRQODlzmP0LypQ=; b=mMoqhcUJaer0GASfzyAekKN+pSE8kqodiNK415JtDTtl/yYfijstiMQVyIVGVhbYJ7jiZy cKhgwp014bcWywD++czA8VHdfLmMfNHfT9xWvGVzDl1BSXzuTXhemseXYlrav5AHS4+h3b iXhswrgzZMfsRkUXSMPESUzJ+rSu3M7/YNj7ejdSKY5Yxhtm11uOmEXTnfiTuvJDajS8Dt gDw+WexxNI1DOGL9NoyYoTDrKUOZT02uu7KgiIO9lSmuToUrf/p0DUJZYwHx1FxGqlsn5D beK0nlWDHvmI58Iw3MyOaR7HUyvDEIWWDiLi+pCNT0K6BiV6dSSjn9hd4gaF8A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191364; 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=hllJr9Cenmg6tA9bg55xooViBdr/MaRQODlzmP0LypQ=; b=anaafIfR//UTCpo9Mk4ATxTaSPAW/cLDpNejXqfvkq1eS4iO6NOae6e9TO/xryKwhc8urc BQG9YbEHS5/MnBBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 04/38] printk: introduce console_is_enabled() wrapper Date: Wed, 19 Oct 2022 17:01:26 +0206 Message-Id: <20221019145600.1282823-5-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129004075272593?= X-GMAIL-MSGID: =?utf-8?q?1747129004075272593?= After switching to SRCU for console list iteration, some readers will begin accessing console->flags as a data race. This is safe because there is at most one CPU modifying console->flags and using rmw operations. The primary reason for readers to access console->flags is to check if the console is enabled. Introduce console_is_enabled() to mark such access as a data race. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman --- include/linux/console.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index cff86cc615f8..60195cd086dc 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -172,6 +172,26 @@ extern void console_srcu_read_unlock(int cookie); extern struct hlist_head console_list; +/** + * console_is_enabled - Check if the console is enabled + * @con: struct console pointer of console to check + * + * This should be used instead of manually testing for the CON_ENABLED + * bit in the console->flags. + * + * Context: Any context. + */ +static inline bool console_is_enabled(const struct console *con) +{ + /* + * If SRCU is used, reading of console->flags can be a data + * race. However, this is safe because there is at most one + * CPU modifying console->flags and it is using only + * read-modify-write operations to do so. + */ + return (data_race(READ_ONCE(con->flags)) & CON_ENABLED); +} + /** * for_each_console_srcu() - Iterator over registered consoles * @con: struct console pointer used as loop cursor From patchwork Wed Oct 19 14:55:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377950wrs; Wed, 19 Oct 2022 08:08:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74tuHhIf9I63vyGIhy8e2rIE2l3C98QGp92cXESP67fYYo71Xhzm4i9feHVrGfsp64wlbV X-Received: by 2002:a05:6402:40d0:b0:45c:d00a:82bd with SMTP id z16-20020a05640240d000b0045cd00a82bdmr7819459edb.288.1666192089047; Wed, 19 Oct 2022 08:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192089; cv=none; d=google.com; s=arc-20160816; b=FTWlSjk0+RB0edg79bCSSM+vIXmc+SvE2K3GipnqiM1plwxiTFnsCtDJWadZG4hmW9 Bq9/f3RkF+F2FpgGLnnX4w6HcVbz+rOoRz1+6ZJSeoJVMKSTl0a9BC7xiZDLH4uPg3on /RLQXFNl/Tl2KPsFTFubREm8RADImLjJI85wISJh3fgWxPCE+6Q4Jt9vYVmmU+oBPGQ4 U++5RC6SVV2MuLEnmMvNujxDkzkphGdG8a9KA0/tD4adNmGKDCp1lNrD1AMr0GvYdGIC fTtxCbZuC7Gu0hnsS3DV5KubEYfbZUye5tCWEw/up8uP5YsaRWW+J62AfBhWUhNco08v 9CAg== 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=MP5rgFSdehBCliWVe71JQUPCb1f669tU8saiCWaIDO0=; b=r1yO8H6Io6OPmq/VoahRY0BG7DQBGtUI5i47fTugfsjGc61KbLYvQeUUG3XtYxgD9e lzyl6g64KfSYAQh7aNNYhN4kGnP63FKygrl4rRyQzKMqJe2E3JFjgQUfzjE8JNYSWfLm 0Ii20KjIbJ5JQc5C+0h/4uHBE8FLBph+o4QF6HlQ3frZUvUcrzhjYDcjUeIKKLxrZVk9 5g5Hx3t1KNV1GOy5TAa+/xMl2Wtp1TogvCN+0W7eNU/2gJqqSqMaXp3vyNfv6Jw0yTDH UqVxfHyh9Y4Qsn7pIDrKPeJ8uLBM9uFoGgJNzYVxirH7VOIvk4KGV9H+OPnFKzd8+/la taQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SLqa5Phc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ozZhE1jN; 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 n29-20020a50935d000000b0045725a5b76csi13332411eda.294.2022.10.19.08.07.18; Wed, 19 Oct 2022 08:08:09 -0700 (PDT) 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=SLqa5Phc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ozZhE1jN; 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 S230010AbiJSPE2 (ORCPT + 99 others); Wed, 19 Oct 2022 11:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232059AbiJSPEC (ORCPT ); Wed, 19 Oct 2022 11:04:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B6A1911C2 for ; Wed, 19 Oct 2022 07:58:33 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191365; 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=MP5rgFSdehBCliWVe71JQUPCb1f669tU8saiCWaIDO0=; b=SLqa5PhcnifAXBxPjzPq8RQ5wWHDsFsKLOjJ5Bmh9ZGDeMItqEb2c5andZCY9TcUyGDIR/ dkOOQxmdmn7/PnLwAAjrGDp8lt9Uz8mAMEoOd7urbGXYVldEk8zYCa8/iAY1dVNRfX1p+J Ha+qK8DetElb0MoGktri3Xu4lx9C3kUh6AtB+1DIReSvn7JRz1gWJTFDzw08nHyTiCmChQ XP4mRnKpUirH0pvAQWYC+E4LgSbE3mXbcssJIvwElnPgdqtXfCvaf4dvjVy2e7JmBlnloB h/m+zkpsEomfdmsy9Cb/TNtCQcjleQpQn0jWgpkY1m6W6keiAq6wL/v4NRO/PQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191365; 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=MP5rgFSdehBCliWVe71JQUPCb1f669tU8saiCWaIDO0=; b=ozZhE1jNVxKFfb0xYXFWRlrgrguzkQU0rcQ9xxPUoqXcDFSb1uLSsqks/WR9QsIUMSaQe8 g5NlOPi7VRafb3CA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 05/38] printk: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:27 +0206 Message-Id: <20221019145600.1282823-6-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129035844624683?= X-GMAIL-MSGID: =?utf-8?q?1747129035844624683?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness --- kernel/printk/printk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e8a56056cd50..7ff2fc75fc3b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2658,7 +2658,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) @@ -2944,7 +2944,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(); @@ -3098,7 +3098,7 @@ static int try_enable_preferred_console(struct console *newcon, * without matching. Accept the pre-enabled consoles only when match() * and setup() had a chance to be called. */ - if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) + if (console_is_enabled(newcon) && (c->user_specified == user_specified)) return 0; return -ENOENT; From patchwork Wed Oct 19 14:55:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378232wrs; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62jwPtOmZx2X7BNDfzGT9IampFoFIToMj37QAQEvxywSzIM9TzXfPeW+I+7gZcVbCSThQl X-Received: by 2002:a17:907:2cd9:b0:78d:9e76:be26 with SMTP id hg25-20020a1709072cd900b0078d9e76be26mr7025052ejc.315.1666192125743; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192125; cv=none; d=google.com; s=arc-20160816; b=Eh+ukBGmhTvBo8N3bwqln+Kd6Yls1HMiklZ8m3bjhroyBogiJxpPt/zHY0/b3SuEJL Hx5gKwkCQxrye8gdsNiy9sMLV7Va3qkXJn9NZ4A/cGgJsuADr9GM784QKdeBrufqINsg BwxdoLgElxSBt6VNJfmn9qva+bfipjMaHUlah1DWNnFhvYhMOTNajaguiD6nvs//VsVj gUNYWzTYCD8SeFirvpdFr6Da6SM4VuP9HHIVJBFRIKPAp5ChMDvB0grxgy+MHgIyrp6/ 038DC4hGTOksiHbanN4U12WaBP3tSLVm23vj8hnvg8BtUVJP1cx5a+/mlf6WyjUxIebE HTlw== 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=PDDOEE0Yq4WGusvcJlDqYVYU7EUqEKlNqh9IITj1s38fJzqypEvdGVMOvz5RRAPkfH fkrDKgO4iEaJppmmQiOHSjaAuBqV8oxt5/nXoRyKyE3UWrR/64jtgIKNyd5sbcAtW+zZ voJQ5CEvAvyayB6ZXqeRANEQzewxIF/fRhhijaQ9HioSD5kcimzpJCrh0e0lyF2EGiZL DbTBDZ4+ZCkLeAVAC+zdDN3Y6BErlvP7n/gra95zJ7WBF0pf2QA9+X/4MGVElHtEDc6J Jsp1K8WbW30StW9MMq9E7RLs52N8OC+TEzfEGGWuKGzrW3S13xS8tyKg5N7quz6OumyT ReMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lhmCsfzj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 bh11-20020a170906a0cb00b0078d1dc1b64csi11743726ejb.170.2022.10.19.08.08.18; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) 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=lhmCsfzj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231481AbiJSPEd (ORCPT + 99 others); Wed, 19 Oct 2022 11:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbiJSPEB (ORCPT ); Wed, 19 Oct 2022 11:04:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B1B18F0DC for ; Wed, 19 Oct 2022 07:58:30 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191365; 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=lhmCsfzj24k5pXS6vMkayCOEXN89OO2hYrf+P3pHZY5Uc8awoFzbR1WNxWz89ah1Wl1RJN UtRafmMxB4eq47PUYX0qE2iORN8YW29s5ZnDfrP5jUKQPiiyl4BNEdt9VvwdqdaVebgWrb bjZCQqAwv1M/BpWVepcDcISB+HPBPTj0gP6x8ICe9SgTAdYYirF4m5oN4aE32nHj/+shau ApH8MIYM3AoxDo4z+waCfLB1Q2K4qJzeHe88mx4a6J5z85iJKei38O6MWBubQO7AXt30+1 D7HS2H/ONTFe2WaUqzkK+DuLx4bmh5Ovx8UXvnjyCaGMkNqsEVxcRb6DwDCd/Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191365; 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=l2g6FH6uxwNCpKlJ/oJ3Rl3UvT/3LcZFXUfEnwTA1nqbmIeYdpPfA8BOJpqZVkKkmgCGoD RO2dZOsG0h0CK+AA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org Subject: [PATCH printk v2 06/38] tty: nfcon: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:28 +0206 Message-Id: <20221019145600.1282823-7-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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=unavailable 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?1747129074280360967?= X-GMAIL-MSGID: =?utf-8?q?1747129074280360967?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- arch/m68k/emu/nfcon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 557d60867f98..c542fc2b121f 100644 --- a/arch/m68k/emu/nfcon.c +++ b/arch/m68k/emu/nfcon.c @@ -49,7 +49,7 @@ static void nfcon_write(struct console *con, const char *str, static struct tty_driver *nfcon_device(struct console *con, int *index) { *index = 0; - return (con->flags & CON_ENABLED) ? nfcon_tty_driver : NULL; + return console_is_enabled(con) ? nfcon_tty_driver : NULL; } static struct console nf_console = { @@ -151,7 +151,7 @@ static int __init nfcon_init(void) nfcon_tty_driver = driver; - if (!(nf_console.flags & CON_ENABLED)) + if (!console_is_enabled(&nf_console)) register_console(&nf_console); return 0; From patchwork Wed Oct 19 14:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377970wrs; Wed, 19 Oct 2022 08:08:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4icaD0q/jYeAJ1y8pRDUNoaWVN8tel3AvFFgFj/j4d9OoO6NuHSx9jff7DtZMcpx0txtx5 X-Received: by 2002:a17:907:1623:b0:78d:9e8b:171d with SMTP id hb35-20020a170907162300b0078d9e8b171dmr7104094ejc.309.1666192081751; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192081; cv=none; d=google.com; s=arc-20160816; b=jcCjEbaaf14BACEwM0kMb6vDGojfqYO+O2IFdG1gSyR337PFSbgrZoc9PS0RZAhQN+ dNJ7RJfHnfG1pZdyCntUF3d9h4DiJ25r6ghOOkf6RZyP5Mx/nDFJvwO6qoS5UCWjNP/p KCh/C6G28hdGJNvQNqknJkJgzf715ojrzP63pqjq2+1ekHXLw2TBKg73sLQUP6q84//f aL0O3P3MGbflp7WYny5KRfi7ppjzspY9hqMaT/uKCxMI1yUPloC/GQwpaQlH/a2SQCjP +FD1W1XHkc1Rnxz/ks//52uFrLpCP+2vLgFLHwUR9upJ2R1YHMu13v+wM3hdlZSSB/Qo +p6g== 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=zWMphmFfDq8OlVxrrPCchY88v/O4bwRw57cpKirymSQ=; b=rYpCDlDGDUfKWa864oN0Mlj59TOvvR5WbgiCnu+hRHhvbifg+heF3DowuLJ/0inYfL ocsKcdxYjpnWqSKJonK0wgnGcUcQbPMOK1DhsxTtwnhDhPvThN11yQzqrMntOojgn4g9 46GP08WrOu3AM4+edtffcCqCPZ3PaPk3hUV0pOJkvUjmSTo60ZJ2/HsEGL+grE3arYMK /21jWpuf2Id0dns7UTiINGflj/5aNON9LUSd//2wKEpE4X0gU7n+Znu8JDHc+peTiJ8I aSe8SN8ls5Ot4QQKsDWnphYQ6hzhpp3YEuDEqCMncv691f6VPmK9LAqZPVXIwo1xTIxC UYrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v9YrdXBB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 ne11-20020a1709077b8b00b00715867834e3si15735589ejc.506.2022.10.19.08.07.25; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) 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=v9YrdXBB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231528AbiJSPEh (ORCPT + 99 others); Wed, 19 Oct 2022 11:04:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232039AbiJSPEB (ORCPT ); Wed, 19 Oct 2022 11:04:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0088332AB8 for ; Wed, 19 Oct 2022 07:58:34 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191366; 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=zWMphmFfDq8OlVxrrPCchY88v/O4bwRw57cpKirymSQ=; b=v9YrdXBBO/q6meOVsORl10DT9g8/uzZ23xImHaforLllPZJe1CnX//gDt3Ecm5guuqQ/so MACoct9zfApolTJ+v1FVD1h0RLDBoFkoLZNYKGiJ0DsuUqHcw+0rDpb9ZIPgagNu7Zgs+O gkRSYUFmeL4JqdZ1XKjm0OXKoaL+fnuYiiqcJ5sO4+rKUKDp2WLocmXDuVBuX2NTl2a3rl siY+No+tFyVN4CEiREVMo2jTwrxQd9bAZzkxg/EMqT9C3vVARDmTRLPn53t0VEHW9z18bu LhmZykhol1iWGLRrhrVr7+PEuWsHDTLrcyEQ2JthQ9gAU5biH4l812fGFSJhAg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191366; 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=zWMphmFfDq8OlVxrrPCchY88v/O4bwRw57cpKirymSQ=; b=Gq8pSMFow1Bxe2k6NvWVnYMVnjoP0hDNZGICKaqxJBt6kO5QnCEPHVFaH8KueqPAfoWClB v8NwqRojtfnaGHCQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org Subject: [PATCH printk v2 07/38] um: kmsg_dump: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:29 +0206 Message-Id: <20221019145600.1282823-8-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129028019889672?= X-GMAIL-MSGID: =?utf-8?q?1747129028019889672?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- arch/um/kernel/kmsg_dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 0224fcb36e22..3a3bbbb22090 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -22,8 +22,8 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, return; for_each_console(con) { - if(strcmp(con->name, "tty") == 0 && - (con->flags & (CON_ENABLED | CON_CONSDEV)) != 0) { + if (strcmp(con->name, "tty") == 0 && + (console_is_enabled(con) || (con->flags & CON_CONSDEV))) { break; } } From patchwork Wed Oct 19 14:55:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378002wrs; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5oZwnY/rGZIAWOKrEyN2mKOTjLrxQbzFfLQTd5kGyB17PMykOyTfAJVEAA1ZhCwRSsuzLX X-Received: by 2002:a17:907:2712:b0:78d:a223:729b with SMTP id w18-20020a170907271200b0078da223729bmr7162687ejk.443.1666192095505; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192095; cv=none; d=google.com; s=arc-20160816; b=BDG1RmPbaYDkGzYO84hbVZaFyc7jhRG+atnMA+anSGjgUS69vFu28fuWkrsTPn2UW2 2YQo8P4cmCqAzie5Ne+Bba50m3bHEK4VxLaE3urvFGaO97fAwO7jHo+bSua0sL+siVYv YoyCtZ7AEJLu23bAPab5jvU6V1bNeUnH1T4PeTEe8kS+r+aXdO2n6VA5itmTtQkSJ8m2 wtWkqnvx+BXALw4ueRPgczBn3Ni0UcePkWmV6RnHyt5Ns6nTA3Xef0QEsR93TDzJUu89 xUuAXCPreT5hDmIYCzOgb1sGcNEfjYLG0CZ3f9aHdYNWskBjTHVtnRF0zjL/DksTtkcn Z8lg== 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=ANsy39dTo+95E1TXTBS5kbs28UVGSNMF6vh3Au875fs=; b=qsn1Xw1p0Zps7XduZd7MxDx3qnPcp8RqLKyS3L63qOTF0gDTFrOttfjAdf9zB1iVPy qBwJF3ofMd49PaBDHxoDeJa/1BH1zipHKBlntzXXrB22N6Vv6su9H0LMW+8wkc1mo9+k 2d+lqRrfNBYY1yz+NKhMOWB3bkB4PquttFJz0Oe4csDniTkOBWEDi15pNWdbuiEhBTfo Wqi3/ego/D0FgjtYl5sVMgA/oFbepruPK5/yLwaF2GUm3XUCM0LxIbvICsGCobUM3DPa 3NVGREl/zAY8RoiamZz+ICN5+H2M/QcL6eMDIfNkh8CqT3dgg/+Z65dWHz9lwxv4i4nd HbFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wBedELtU; 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 cy16-20020a0564021c9000b0045c645405bdsi14244431edb.240.2022.10.19.08.07.44; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) 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=wBedELtU; 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 S231671AbiJSPFQ (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbiJSPEF (ORCPT ); Wed, 19 Oct 2022 11:04:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACCBACF55; Wed, 19 Oct 2022 07:58:34 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191366; 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=ANsy39dTo+95E1TXTBS5kbs28UVGSNMF6vh3Au875fs=; b=wBedELtUaj0zJeFDpwmo+Eyrsj3vhnslVQMMnOkfh/q28nnuprj+u3It6GYfDmuHkyH1Z0 jNvgvw0kZdalO6FFSXJu2mqO47j5IZHrSszNINkfYz08dHv/g24BIipbzVvvkCUtwUEd6c /G5ZUEi7k1R4vBBcPi0q5lAPBZi73IxF0DRlGFYb+7B7MuBL8SZrA8ne0tSMtqkeo+Yjiz U1qZfnDQPMOveo2W5xC7mJmp6jwh2VhohUHK7OWYalPnB+MT+EKUDwMWLhHz3pybmY9YEy vCFG/SnEVbJb9yxV5uYCeNZTI0ekEncYcgbhvVRO+iKofY2lSZVNpoCyiHCTQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191366; 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=ANsy39dTo+95E1TXTBS5kbs28UVGSNMF6vh3Au875fs=; b=H1yntJDtD/aMwcZTAmUYG8IvP4HBmdfAyCl/OBYwZYBB8EKsYSv3K4Ea8bOP1qKbt6ZJ1i mxTyv7pllOslw7AQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Ard Biesheuvel , linux-efi@vger.kernel.org Subject: [PATCH printk v2 08/38] efi: earlycon: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:30 +0206 Message-Id: <20221019145600.1282823-9-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129042593441761?= X-GMAIL-MSGID: =?utf-8?q?1747129042593441761?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Acked-by: Ard BIesheuvel Reviewed-by: Petr Mladek --- drivers/firmware/efi/earlycon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c index a52236e11e5f..8c27eb941d8e 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -30,7 +30,7 @@ static void *efi_fb; static int __init efi_earlycon_remap_fb(void) { /* bail if there is no bootconsole or it has been disabled already */ - if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED)) + if (!earlycon_console || !console_is_enabled(earlycon_console)) return 0; efi_fb = memremap(fb_base, screen_info.lfb_size, @@ -43,7 +43,7 @@ early_initcall(efi_earlycon_remap_fb); static int __init efi_earlycon_unmap_fb(void) { /* unmap the bootconsole fb unless keep_bootcon has left it enabled */ - if (efi_fb && !(earlycon_console->flags & CON_ENABLED)) + if (efi_fb && !console_is_enabled(earlycon_console)) memunmap(efi_fb); return 0; } From patchwork Wed Oct 19 14:55:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377871wrs; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5K9FZSkIQqjWJVAbHW4oGsVCahu93Cd3ZNvCN8rPDa+GXOa9doBl5c2c2PDBoBqMugjrBb X-Received: by 2002:a17:906:ef8c:b0:78d:96b9:a0ad with SMTP id ze12-20020a170906ef8c00b0078d96b9a0admr7282737ejb.529.1666192081747; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192081; cv=none; d=google.com; s=arc-20160816; b=j4Wiu2iWX01Xyzppw+HGiYcgPCiKkfvqTcwTa/gaGiHCQBSDXh4Aj4iA+oP3YwK5ux BK53iZK5xf8klGNJ+OyAeqwiVgiHa5BvCbpRuXNBBeL5Uth+rVJZpb9FzQfKc3SxKIWC f4MGPXb5XfXiQcrpFRRSVocU0KzdobIbK6gl0sJS8YT7HBmeatPURHkTgfBYvmHoTRAb Vp1TjgHlaUtAtNwav67uPPQXMobwZTSNACRWeh8MaFFxlhIbRH044xAYmHKn3ZG7y42L DFMubHkpLNM3RauEP1Za9z51exy7gKk2RO0kQLAJ+LPsWOCltZYrRpl1yP1sTiFTtRuf GovQ== 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=ZvwCpncD8XzBcL9H4b1h7ZEl//Cg5TuvHjEkIfVfM1RC9NYHYN1clqYg3T8G4wco+2 uDmc/HW0yN0tsNqZuzZcTCFfXcSqPCd8bpkqgjbP/K3mfbzcfNIygUEm3rrYVCUH4+Cu GCiCwAVgiDpggqcdW/0kdmZbg4P/jXQLP2CdFKzyFtyFr3Cn4x3OT0S34RQ9ZGmFGL5M fEwJDz/dar0yXoiXr/HRNdtXJmHLxzrAarf1HG1y0THB8PmT/rfWpK2/pVMQWIdlQcBD gl6H5rU1ZuiDXVIU0mfWZaiHzNTQGniSfBCQgBK7+RANSx4Y9SxvV/7Ionk2EqeeAu7S q/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CapeSp4l; 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 gs19-20020a1709072d1300b00783d5a93880si14237860ejc.503.2022.10.19.08.07.27; Wed, 19 Oct 2022 08:08:01 -0700 (PDT) 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=CapeSp4l; 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 S231566AbiJSPEl (ORCPT + 99 others); Wed, 19 Oct 2022 11:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbiJSPEA (ORCPT ); Wed, 19 Oct 2022 11:04:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A1AF189C3E; Wed, 19 Oct 2022 07:58:32 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191366; 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=CapeSp4lIuUCMT3A2F+Nh1MiAgJLkP2QvT6kPUMQDmJJFQsukbmY9zgoaeE4Mq6UuBqXXb FrZc++ZOPgsuLs9l7PcPyG4j8PgQByAcFR2QTb5ZOiIdmXyyFYqlRtydfmDmoK5yA3OP78 U0XmnXaelSW/V/NwDwJUqlWqX2IcrI2b9QoB5wTOni/8eC59uwoJspmELM/0AK/+2z5J0G bd1oHF0zuZVLDhAFAcJJT5y3CPqV4fXZIaKcBDHjVUzgpVkWqsTRUcD5J9GUYo05fhBIDg fYj1DxyE3Wu0F0Ede8aUNYGFTPayP73PEUKd+FQ5qnHfrV5Nu/mSQTYm2wS3RQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191366; 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=6uEJOM0caPrcvNJcHiErtW6cO4rX4lvkgAL5ZPoAngE=; b=ZQecdyT7PQky3Pel/Hzc+4qBo3aS7NXlfHW9v7oMg/iE63aGG0BcneUC9VkDNd/cxE1gob fBX8kx6iiefyiNCg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH printk v2 09/38] netconsole: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:31 +0206 Message-Id: <20221019145600.1282823-10-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129028390875320?= X-GMAIL-MSGID: =?utf-8?q?1747129028390875320?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- drivers/net/netconsole.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index bdff9ac5056d..073e59a06f21 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -332,7 +332,7 @@ static ssize_t enabled_store(struct config_item *item, } if (enabled) { /* true */ - if (nt->extended && !(netconsole_ext.flags & CON_ENABLED)) { + if (nt->extended && !console_is_enabled(&netconsole_ext)) { netconsole_ext.flags |= CON_ENABLED; register_console(&netconsole_ext); } @@ -915,7 +915,7 @@ static int __init init_netconsole(void) if (err) goto undonotifier; - if (netconsole_ext.flags & CON_ENABLED) + if (console_is_enabled(&netconsole_ext)) register_console(&netconsole_ext); register_console(&netconsole); pr_info("network logging started\n"); From patchwork Wed Oct 19 14:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377978wrs; Wed, 19 Oct 2022 08:08:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM617Usdo/i124zTEzVVAcKah6gEqBiLgaJbdqv57YWyE6ycihECNsP0OeUto4RUmOHq1oMf X-Received: by 2002:a17:907:6e87:b0:78f:a596:5cf6 with SMTP id sh7-20020a1709076e8700b0078fa5965cf6mr7094961ejc.398.1666192092846; Wed, 19 Oct 2022 08:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192092; cv=none; d=google.com; s=arc-20160816; b=cU+j1xgyrIVElNUvTaKRG9RRWNsp9Y5n0FpqnhTScJUH5WBe9vO178AhhYtcDXz9Ur YY0inPIXLuwWLyX9SbdThc8DrdNaVFSJPsOmv517bKbs7x9Xy1Wa6XiMSfz1cq6PoFf+ cQwrrMUB1bWidCjgq3sgt+rvjyxPvyc40+XaUb+ODnQxfP5C9yt6OTyF9R48ybCCvxYY YiwpE19tJWfwDD2y3ySujc9qU5vFDc4fVwXXYrIgNFOZIkd5jMj6ZCZPpSXrv9gZyH4T +kWltkl2iGNr4aNfjan0rMJbDaW173ZFDiQLGsoVlaOEL+4GZoPMbkmbN81Oov5A/6To cyag== 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=q43bR7EIdzwEejtqYY/+0pBZ/1DlBf/ms3Th4977RU4=; b=CcEu39BR0wwqx8zXdoU5a+0JEB2aAMZYTU3q0yjeCbKMuW4+BPsmBgtU0v4Hvk4y/a y7nISK+21RZJ0dpapEkcqHuX3aCznQN9S6c2RHZCWd9wYmzP9IBktw6+CvuXMIiRgE14 uJjMaXelTEvDFroAod2avGZveNQki7VBdnF/JJO72P9qpFmM++x14yWfsQjHTgra/FSi 7IcBXwq1gKsYk/Fggu3TrM/eo6ZpCmuV2xMJcqxKGNj/hh6sXC4Z31+3gcJ+N5AD3+St YK0Cec4Q00XudqLG6bg1xRwUPF3RTua8PDbXKoEto5/ZnRXG5/gfMdyBV9xsxd5ha9WK Nf0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CJ0wkcfD; dkim=neutral (no key) header.i=@linutronix.de header.b="4/3XcDP9"; 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 k20-20020a170906159400b0077bab1f707esi12032996ejd.159.2022.10.19.08.07.42; Wed, 19 Oct 2022 08:08:12 -0700 (PDT) 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=CJ0wkcfD; dkim=neutral (no key) header.i=@linutronix.de header.b="4/3XcDP9"; 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 S231634AbiJSPFK (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiJSPEE (ORCPT ); Wed, 19 Oct 2022 11:04:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196331929A9 for ; Wed, 19 Oct 2022 07:58:38 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191367; 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=q43bR7EIdzwEejtqYY/+0pBZ/1DlBf/ms3Th4977RU4=; b=CJ0wkcfDAIYxYlfRDwtWDHTwKRBKnIGO7mDk96DEhEfPYYF1oPQuNnmaWMjNVFx82t2g2p vzwkF94n0h7nEyhv0U93cY/SDg0gFrPMaHBWZPIoWnM4PkhT8ENrt1zwlq56m266UfO6ok E2Pf4W9zbKKXLfOeDb67zW0A+t3HCRbpaPaonrDqlLifvlY/UNRbzMHnKW0rU52czq11LU 2QA4703MQAMlTBiSbe41rKt7kIT0G7svma7Brz2sKaxLCd0oZwJQ/auRydmpv7zgddgQ7Z KT6cqgK7jbmb4Yo+LE3H9hyyE9UAia6OLCMO0LrI4vSPeblK36wIq1qdR3Gn5A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191367; 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=q43bR7EIdzwEejtqYY/+0pBZ/1DlBf/ms3Th4977RU4=; b=4/3XcDP9JpywLbtVPvYMt3perm+LULFBKeOfwGqUTnu4+/A8q5xycmiCMFah2+WEFeLmuc PyYB51N0P1g/zmCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Shile Zhang , Xianting Tian , linuxppc-dev@lists.ozlabs.org Subject: [PATCH printk v2 10/38] tty: hvc: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:32 +0206 Message-Id: <20221019145600.1282823-11-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129040196485000?= X-GMAIL-MSGID: =?utf-8?q?1747129040196485000?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/hvc/hvc_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 4802cfaa107f..6d1d7b72488c 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -265,7 +265,7 @@ static void hvc_port_destruct(struct tty_port *port) static void hvc_check_console(int index) { /* Already enabled, bail out */ - if (hvc_console.flags & CON_ENABLED) + if (console_is_enabled(&hvc_console)) return; /* If this index is what the user requested, then register From patchwork Wed Oct 19 14:55:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379353wrs; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70rvs3v/MuJQNH1EuASYqrqpai7K9KfvRczY3FU7N3h++/x7hGsOoE6mfNHLfgDhtL8V2F X-Received: by 2002:a17:907:9713:b0:78d:8e23:892c with SMTP id jg19-20020a170907971300b0078d8e23892cmr7020408ejc.449.1666192243004; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192242; cv=none; d=google.com; s=arc-20160816; b=WRnFCbVtUvsHmSpcJgHWm1m4TcT1OYvsl0roCTxSIIHvk/es5qw+peWqdgCFvpOi2E C7+JxhLa/uIUj+iqc1QFXczjJp9I25AlF3Ib3ZJM+F0yDsXgx8td9nzWug4AxqmZGqe/ jtuLWpUxu3gOkRRgv0+KpIcbSScEjNp0g224IJz39Nc4eKplgfeIoQTVedc67aJ56azp wnUMRK+xO+dgJmdk1V3JjX9EazRACkWIKJj5TZIc2vnyYPD4IzvbjTFnzQTaNeWg2J4D D6FpdsajWP4XK7NE6wAGPOhwnwO76OHBvjufWHKNmXZJwwfAuQ3OVevBYeaXNf6lMl9G eHeA== 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=cANA2HumoCM7OV3714mDIj5DFLk1sHCXsW4mcU0VIIA=; b=dNS094MMuClohqgRjGfeujOZYGaUest4DRbYIvQ9AFf2YzXy2qnDSh45MtGsdWnDoW zdcbx+B5hetGi4sT7OlI+lOaTGjh1xBIACc5tNrT7vZ3xIW3vNkRnvoa0bO4O6RMnuQM NZHM7DRy9Ra1XPinWxVsbnF7bIduzoHcij+QQUh5ZNgU3G6G3b4e9SRNEAB6ZI67ccD5 xubc2Wzvjkg456t+JAiZJMK0HobkMO4e5ye7HWackn77mGIteTjDYWSlbyfBmPYVgPS5 5NEb/VnCAIh3/EL5u2+TNzomDxF/ERVb1GA89cDvolG59bvF+hG1sHtzJrPVtxeNzIZB 3AJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="UH0/62gi"; 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 k13-20020a1709065fcd00b00740110c599bsi12577765ejv.146.2022.10.19.08.10.15; Wed, 19 Oct 2022 08:10:42 -0700 (PDT) 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="UH0/62gi"; 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 S231806AbiJSPF2 (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbiJSPEG (ORCPT ); Wed, 19 Oct 2022 11:04:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 935CB17A01B; Wed, 19 Oct 2022 07:58:35 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191368; 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=cANA2HumoCM7OV3714mDIj5DFLk1sHCXsW4mcU0VIIA=; b=UH0/62giDRacTgc6LWjPHq8aCEv5jkdDEzI/MA8Jup622emiuKoX7BLt8gRNRy9hdeFVnl EfYBYT1slOvZDZRzEYjnihQ/kb/pSC0sh+4hDZTe//uS3JVcMaASNn8iGoYSm1SazG2vWu rfA1AG3yElx0WcfZJJG2/V97uLL7zKyUS5JShA2ytxO5Fh7YQzi8/7WTxInUnWi5M73WCI j6zCLeQepuBdR7m/KMJa5r18w82h1KE96DJxw5pUNwJwUMgjkxcZ9XzvU07IH3AtxI4al8 qGXhSz0aOTdStNeIxhst5X4QNC5Ip1L8vaF0n5xzmGMrOsDxYBuv3gLeRDfPdA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191368; 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=cANA2HumoCM7OV3714mDIj5DFLk1sHCXsW4mcU0VIIA=; b=KQbMsoI8kPiCKg4t2VNCGQ7wjHS2dtIutEdNfXg4Ksb0sa7p4/aiaOHQFSJrrFe8FAeRCI P7dHuNzNimUGeVCQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH printk v2 11/38] tty: serial: earlycon: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:33 +0206 Message-Id: <20221019145600.1282823-12-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129197298350277?= X-GMAIL-MSGID: =?utf-8?q?1747129197298350277?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/earlycon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index a5f380584cda..bdfb60da97bd 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -181,7 +181,7 @@ int __init setup_earlycon(char *buf) if (!buf || !buf[0]) return -EINVAL; - if (early_con.flags & CON_ENABLED) + if (console_is_enabled(&early_con)) return -EALREADY; again: @@ -253,7 +253,7 @@ int __init of_setup_earlycon(const struct earlycon_id *match, bool big_endian; u64 addr; - if (early_con.flags & CON_ENABLED) + if (console_is_enabled(&early_con)) return -EALREADY; spin_lock_init(&port->lock); From patchwork Wed Oct 19 14:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377938wrs; Wed, 19 Oct 2022 08:08:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/SKf4SHjvjouhOGxMJZ20sXP+sZlvW20DN5+hfv8ZqgaYaV4YHqpLqygwkWtfm3b/b+0k X-Received: by 2002:a17:907:2711:b0:78e:c2a:a3fb with SMTP id w17-20020a170907271100b0078e0c2aa3fbmr7094147ejk.556.1666192087544; Wed, 19 Oct 2022 08:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192087; cv=none; d=google.com; s=arc-20160816; b=KfBF/FvbtyTsTgH8C6eQWvME353jauKTsavAY7n3mekdM4uCBtb8zCkKifwcf2VHiu MEFAnC2sxPtkvuqPBdyrk+BxqUCNbHSEg7luAfZRjVzN/t+e2QyEV6GI/QHhn4R+CKCe m7bi4EpgeBGan9SasjcOb9k3AYfvrZfYHqHTeBJqQsN0YGO2uRMKk10UjMnID57XOsvs RBot7oYeniy4pTfh3VGSGQv9RPLDEyI/FntKxo6YGd3M3ae4148fVhEkK5K1kMYgXtOw R2dOaDdgcC52E9UKM5h3U+jGL3++M6vJFEEe/AvdqmsO2hTCu86YGm9aS6HCFz7JOaym mprA== 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=jlKWc1Grue9kQfYwJIiewArVOaAkhAK4uRE7V4DMseI=; b=fEnO0KNAOT4TFm0nhT0l816biB2D3iE7NpdyYNs9qsX+5qvUHZxS6G08ytwvIApskV 24FuEGrM6CI8x632HDYtdyLg4094phlYMCI01+K9NX3roQ88oPV6vhVdmL6RadtfgHRT Oj2b+Tzjktp1RgpudsLIxsHQ7ZvFFU+ANxkjEz1jvzR6MeWI+AWpk3puIWeIW1t/vKDe ffmcOqlJb/pLIiLgXNJSD/Bjc2PRGNEcPZJmKS7X5yziG7atfnhsO6kyZ6oTFkCh/KpG 7RCAzPsQyrQyjK8BaU5tmBwI5mIXtUsI/anDGl1t/vjuYMWkLYE+13pdTNCm2SHccVPp QkIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Kk2lnB0D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 x18-20020a05640226d200b0045cc9072f14si17690549edd.8.2022.10.19.08.07.15; Wed, 19 Oct 2022 08:08:07 -0700 (PDT) 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=Kk2lnB0D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S229767AbiJSPEX (ORCPT + 99 others); Wed, 19 Oct 2022 11:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbiJSPEC (ORCPT ); Wed, 19 Oct 2022 11:04:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C308211E46A; Wed, 19 Oct 2022 07:58:35 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191368; 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=jlKWc1Grue9kQfYwJIiewArVOaAkhAK4uRE7V4DMseI=; b=Kk2lnB0DeVDuCcQ2SWcnH8R0PgShB2CZwwsounOmf0c7TAxDw35ZfqSbSJ1PexWKje9a+0 NMoma2X+T0p0buJRG2CD0IdcQ3ox2o2rPGrDdFrPUj49Z35+fPcKgQeojLLcyw6shd+JZ9 7r6p+CtHoY10o8YGBeUNnQ0FJ053rbDPZzoW8bfvOwNdxeAh5JUrxV2//iLX8tpfhO5B/d l3lLWkkazcGkc6qDO/d6aqqwdZkfKULXqPgH+kzjyq67FPhYBElPgpY4K3E1YW+mL8gUT4 aXnp3oFg8O4sBrVcA7QxClrsqr+RzG3dLrE+NIR5PRiZa07ARtMvihKFdcmmsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191368; 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=jlKWc1Grue9kQfYwJIiewArVOaAkhAK4uRE7V4DMseI=; b=Hrgpan7bNf/oEJbZZM6hsAcz+zCVZiCrz6fuzTkbXs/R1ESYYwgaiON5lh57jBdACO27c+ UT3EpQHIZr7qOrCg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 12/38] tty: serial: kgdboc: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:34 +0206 Message-Id: <20221019145600.1282823-13-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129034255327588?= X-GMAIL-MSGID: =?utf-8?q?1747129034255327588?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/kgdboc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index e76f0186c335..b17aa7e49894 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -533,7 +533,7 @@ static int __init kgdboc_earlycon_init(char *opt) console_lock(); for_each_console(con) { if (con->write && con->read && - (con->flags & (CON_BOOT | CON_ENABLED)) && + (console_is_enabled(con) || (con->flags & CON_BOOT)) && (!opt || !opt[0] || strcmp(con->name, opt) == 0)) break; } From patchwork Wed Oct 19 14:55:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp377998wrs; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XdAyQbCREzjaLfidhlpGGAh+m36bIPnaDbYetyIGCwrEJyrxeE052jc+TcA1lbRuyLgGy X-Received: by 2002:a05:6402:1555:b0:458:ed89:24e9 with SMTP id p21-20020a056402155500b00458ed8924e9mr8112934edx.55.1666192095581; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192095; cv=none; d=google.com; s=arc-20160816; b=ZeiNWbPkWBVa7cyUutneaRj4yW+XnIFhxar/2pm2ISH4CvMriHnl2sP76qsZX6Fw3V V8v3h0HJhLATdWACkLSezdEp4h7Xm9KLlEEh/GvyDXsocUAzR2BzUIefPFBgURbMi/5F 7U1b1gqygZVY2vWrQHJeCIcrCG8j9/6OhQ5zeeyRYGTpBxFvrn50uKh+QpH1bZ1/5pCI oqvnqgsMv0NYiwsBNKwjlXIfl2CGgbaESTDV/4PbZ/DqYgzHrN3/z6wc3uCfnibbagjc cM/YCUl/guZGk0mlsbyn5bQU3n5Y+nzJn/faln8avnj2tcbz0Ed78fK5zNMEsC7cF9IT zTYg== 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=CYLncsVrBizTn0tZlGmVU07Lo3jyJ/DS7XfMGutmnSA=; b=LiGmyspoekCUuUFxOM2t4MqxYRk5N0E2LTDxSlmFeG074j1HaamGM10qJFJiSSqA5h q9lq2RjHFtW3pYvQXZjqaYld3pyPoZGJ8VyLtXlj667VtfHHNsrFBw20vbkHBnwtKqUY NOLjh3ujhPYETgReM/lbD0cTKFKJZWduNmtfgJUpdfQ6yG8GD51eMF939q7wJv8nEfV/ bbQbBFXyIU2go9qJzENws70lqJLEV37s8kRPrgTPHDJki60UQ3F98wu2QUTdYkuJ0eos /mhiKsFS5bn5sE/vgMUSVwfBducpTWRebykCHdIwWR6Kinv7clz8Wm4H6DKEhqesUUlX Lk6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JPedjArJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=S7pfiQDw; 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 cz3-20020a0564021ca300b00459be46b0f4si12509939edb.131.2022.10.19.08.07.34; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) 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=JPedjArJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=S7pfiQDw; 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 S229926AbiJSPFE (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbiJSPEE (ORCPT ); Wed, 19 Oct 2022 11:04:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B956EB96; Wed, 19 Oct 2022 07:58:37 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191369; 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=CYLncsVrBizTn0tZlGmVU07Lo3jyJ/DS7XfMGutmnSA=; b=JPedjArJAuY5hRBDkNnnczWzi0rdtYdWSojm+d6XEyT740PpZPGKZQU8tT+uuaYGiVPfsv wihTQwPpb5Vfqyv+jnFaz5aslcibke0hRWUqpVTOTuDJ52Sk0LuaLb/GZm3txhIsikw6KC X9YIkrLQk7MjDOB4L+8dYq42ZQZWa0JICoBu63P2KT3BFI0l6VLvdUELcHhxm1urY9c4oO srY+3ajo1wLeddjhJXCk3lYKZGbHvMEMjeWmEZQ6iCGDF2dgpc5Hw+kMV7spvVFzkpsW9a N9oAjW1J4KS75rVtgGeiiia5qozkB4wZddYkiJVVpOYDHNoA8R8m6cygY7P6QQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191369; 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=CYLncsVrBizTn0tZlGmVU07Lo3jyJ/DS7XfMGutmnSA=; b=S7pfiQDwwJc4IAaG+ohuEdR5wq8i6B5ZKrnBe8A+GkV8vDCEdvI4ws2GTEvObuZQVkx4oN ggzfXJPGE1IMo9CA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH printk v2 13/38] tty: serial: pic32_uart: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:35 +0206 Message-Id: <20221019145600.1282823-14-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129042813643992?= X-GMAIL-MSGID: =?utf-8?q?1747129042813643992?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/pic32_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index 2beada66c824..d70344dc6e8a 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -843,7 +843,7 @@ console_initcall(pic32_console_init); */ static int __init pic32_late_console_init(void) { - if (!(pic32_console.flags & CON_ENABLED)) + if (!console_is_enabled(&pic32_console)) register_console(&pic32_console); return 0; From patchwork Wed Oct 19 14:55:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378003wrs; Wed, 19 Oct 2022 08:08:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4np2FcPU/xbYw8iBeSGDqItfjMl5gWreGgvWw3zqhBQkjUy2VGVYy+FD2Ens0UTUQ86f6f X-Received: by 2002:a17:907:3e02:b0:782:1267:f2c8 with SMTP id hp2-20020a1709073e0200b007821267f2c8mr7048848ejc.585.1666192095650; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192095; cv=none; d=google.com; s=arc-20160816; b=LICgvLCLLCht0pDch3ZHW4qzTKNlaIrBOSJQtBI/DDx1OGTgpczPPxrbehrjJV/HqG 6EqdWfWZkMPgL372skAlxAxERFxO9eY4MilgNjxA8lZU1RbyO2NsNDs63YbLZIm51kNC mDofct6OseZDX8mgW3mOhpZFyNgAjdlbc3YqbVIeIbmHJoHI35EEGB+9B2WyeAqyMMlO gqCYczdf0hNRWhTebzM35JalBt8WHjEPdaaMtHGJpc3J8X9+2CJx1pGwakXFaht4vXJe CE0wIANL48AR/jI2KCGInqX4d2GyDdA3zYVPsYR+kE8aC0Wkt6C3HmkJLSZRiPoHJp2B mDvA== 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=ECvJGB97Hla1u507jwp5akWm1qCQ1lChgjmZWmbHvAU=; b=ho4Wz9/SwcGhznWt42Mpu9P2WnO/Vblg0CTwu2TcxfXp/cN1dREnBplxW0myby2BE9 4awgWRd30zzzi7Lb2Tqu1cmxfa6PK6PhomY8JCmw4nw0BqG/LKCTNRrSi/1ewLA/g20q 042TZWy62ZryujJk7GJYlj/M83DS8G/5JNVkknUJBbQBONGMmFeZn7V+5E3X0/7OiIwY qe/xy410GiVXS/yX6aL6D08uuwYKt9QRQfqeutR3A7XZZau+lJs+2+psM5/MNq5sCu9G chSdPYBcuBtuAcAI++MRG+0llWUKi48B6wr7m1CI2GOeiqSR39aAkW+nu2cLKLGAJIb1 0e+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=U0BupZGC; 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 q13-20020a170906388d00b0078d4b9428cdsi12076912ejd.389.2022.10.19.08.07.46; Wed, 19 Oct 2022 08:08:15 -0700 (PDT) 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=U0BupZGC; 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 S231703AbiJSPFX (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232122AbiJSPEG (ORCPT ); Wed, 19 Oct 2022 11:04:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1153D1C5A5F; Wed, 19 Oct 2022 07:58:33 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191369; 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=ECvJGB97Hla1u507jwp5akWm1qCQ1lChgjmZWmbHvAU=; b=U0BupZGCQHaRq+D5r1dZHhQ+O1tvmXp1DO3geOOs8K5K2OV5M7k0FFEhZuxAaivxGr3jDh LfFdNYEVY3ONqrvO31yQDmC4pv9lZbZ65u9VWYnvToQk3eYero1RZj02ZbuD6ghbDhttP0 lJA7ZTAiSL9vkXIVlIyBZZR4P+kilPLa8KiUKPFUDOhCgL35CEuVqTijttmO8iVFoUk9ik 0QsrUBkBSsE14vhvOIsyklFwXFJO8kecQ310Ish2cbJIx3/4N2ekjBu0ZcTA+w6OhfiRcy m3ozY+le97N9+MO4n35Tyllx9o4l3z7cTXJQyGh2O7btDGrwSYIhS/VdcnmDdQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191369; 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=ECvJGB97Hla1u507jwp5akWm1qCQ1lChgjmZWmbHvAU=; b=GI/hKiJLWVa+vepqZzJ+pH7neoD0sTcrbTqVtFMsZA/DipeGp5quDMaKAppqq2BiIO9vW2 5J+fk9L/z5Q+9zDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH printk v2 14/38] tty: serial: samsung_tty: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:36 +0206 Message-Id: <20221019145600.1282823-15-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129042941561385?= X-GMAIL-MSGID: =?utf-8?q?1747129042941561385?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/samsung_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 77d1363029f5..8142a0e53ffa 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1732,7 +1732,7 @@ static void __init s3c24xx_serial_register_console(void) static void s3c24xx_serial_unregister_console(void) { - if (s3c24xx_serial_console.flags & CON_ENABLED) + if (console_is_enabled(&s3c24xx_serial_console)) unregister_console(&s3c24xx_serial_console); } From patchwork Wed Oct 19 14:55:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378444wrs; Wed, 19 Oct 2022 08:09:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6z65xzNf4d6kUyuKtg53oVW1y5pfrdvQrPSG+x0YQxS8YBoxIOrzvoD1xoilTxKk1lftfP X-Received: by 2002:a17:907:a044:b0:78d:9180:125c with SMTP id gz4-20020a170907a04400b0078d9180125cmr7112273ejc.247.1666192148550; Wed, 19 Oct 2022 08:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192148; cv=none; d=google.com; s=arc-20160816; b=wrlBgyS9aYw+RL8RQ4YeeKM4idfl7sZRUEMjRwcU9n5V0wbBH99DPJnxSBg5lHqfKu w1ovNKKzvEVdkZXiCV+t/ZbtEIU2lpeJ4Xctb6S6so9DbCU4xvCMxqjmrqSsPmq0sACm p9UozMSqQAgvi8y8dQSR2UnA4caOa1KZQzjR5pppCYb4CkhPPvghSlpo/4MtqwhUMrqs 37O6Ev8tu3Ez+0gP2r+fdiTgUGS6d76wJgYn66hT+qYQM/eMqiDUdfuZ4Cg1ePacRadu HvYDpwyHoVeSCToQMeER87HNovsm+eY7YSIR4oK5NPWKd+dW4Izphf7RiqYs0uZd0adA +9ng== 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=KzgyVUdc3c3kCjuysiyU5ciOaxj14Ka8qNAluIGo2ws=; b=yMqaS6Gp8v4Am03FL+J8trY6dpOtbvYdCZrMjyj2gEItzG6NBZL8LxEdYlkX40nMYD YKtn5UUrV3Ar988J9JEFy5te496DwzuLQmX3eGbSUcSnqLD2D2iGj44CeBaOe/l+zuvT montBPRJm1r6oobHag1CYLXa1c+i6vyd2c3FZz3hK5kFrIt/Sb5Z7YiEC/1/O9xBgRW8 2d0kKNhK15jmvMASfTiom9cDpPMi1tZhz9tyjBql5pHFXzyP9qjmTCdfTtFqzkn0EPlR GQWgKF+dKjglr2Ew0r0BkhIbyuKtFFD/v77zRBDcrc6uf8VxOpbXq+ywIDrVQzG0Bu3T 93bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oMqTMwFg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 n11-20020a05640205cb00b0045d03c18e5bsi17808552edx.560.2022.10.19.08.08.42; Wed, 19 Oct 2022 08:09:08 -0700 (PDT) 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=oMqTMwFg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S229610AbiJSPGk (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbiJSPFk (ORCPT ); Wed, 19 Oct 2022 11:05:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEA2D32047; Wed, 19 Oct 2022 07:59:15 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191370; 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=KzgyVUdc3c3kCjuysiyU5ciOaxj14Ka8qNAluIGo2ws=; b=oMqTMwFgA7TRBPKkkgg2SqcRq6lIX5GGgXm4dRv/bMgruBa0iJWddlwoaLUfKzhFqpC6WR gwr90qgT4eOy+NBCyDnpmsmy21dVcFJfucOAlyOaD0dBidVgI84sy3+hasNAbOJlFopeIX EoGBXAmUhpgj+FmhG/kz41N/6M8NIlNgrCEMfeZjFloXm7gwFQyF30r1x8A5O1Ae0MgVdJ w9n7t84CPDZqWN9vXSJzz+kCubBP+BWaDlt+OHM8hc8e8905TZMfm5ln6dAhILh8HZ273m myRuJkzDuM/0PtnahsjcVV7NerXl1J+nrLHS7FK5f2OsLl4h+1Sz88UbEye5LA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191370; 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=KzgyVUdc3c3kCjuysiyU5ciOaxj14Ka8qNAluIGo2ws=; b=538n87jf9fQBuIO0i1kQOYmPKMxRqFehBEvcShiER+MFwipHan1NRjt/wMAfdBOIqq93S6 /K6fsXGFCl2rWVBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH printk v2 15/38] tty: serial: serial_core: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:37 +0206 Message-Id: <20221019145600.1282823-16-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129098525587561?= X-GMAIL-MSGID: =?utf-8?q?1747129098525587561?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/serial_core.c | 2 +- include/linux/serial_core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 179ee199df34..ebf609e4e179 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2573,7 +2573,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, * successfully registered yet, try to re-register it. * It may be that the port was not available. */ - if (port->cons && !(port->cons->flags & CON_ENABLED)) + if (port->cons && !console_is_enabled(port->cons)) register_console(port->cons); /* diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index d657f2a42a7b..ed5d1aeb91e1 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -745,7 +745,7 @@ static inline int setup_earlycon(char *buf) { return 0; } static inline bool uart_console_enabled(struct uart_port *port) { - return uart_console(port) && (port->cons->flags & CON_ENABLED); + return uart_console(port) && console_is_enabled(port->cons); } struct uart_port *uart_get_console(struct uart_port *ports, int nr, From patchwork Wed Oct 19 14:55:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5636 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378480wrs; Wed, 19 Oct 2022 08:09:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Lq1Pchc/7rMH9t5C2VTK6fy+r3JC53mCtTqn9o6yAJ+CIw+HmFG3KtF12IsbxGhInTuKW X-Received: by 2002:a17:907:868c:b0:78d:f741:7fa7 with SMTP id qa12-20020a170907868c00b0078df7417fa7mr7187588ejc.648.1666192151677; Wed, 19 Oct 2022 08:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192151; cv=none; d=google.com; s=arc-20160816; b=bQ2kI3wPsNW6Spt20tWJwB0rzqOaG+5CQdzmSEc1shcN25WX8yNn1KPraek9/CdgYu JpZM2omyt1lOW++SLMze/B8oEAA0/dGn3w1l2UaSAtXosfBebEScjSVtIVIJbZHrxGUs fgknXAt/4TDVkREn9/CT5E4Cdl77Y0ur+vDJ3AHnYZv8GNLIeoFXAMZ360/EE9UFmzgM AgpdVEJc3a+sv5gYvK3LRVZb3KyFoVS9d0kZyuYWjASzHkX9SX/a6Z5XR5mjKWzmVD0C WbBDAeq5CGP38KMv+QcllX1f+2D4Xwb90meTbN/cbkZCOsDUtH6r5ASSbGVIM9NSJxd+ wokw== 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=jjpBzMIZil2dmLUT+irfoeemb7oKmLhPxEY4dlNGawQ=; b=nv4qlCSJlSvWzLvuYfQPr2aKWV1onNyKck0ne+voAI4ncDITglT0CVspE2b4oRy6Xc Smmv+PCxztqIIF/Ea9r++19qTBIz3T6pmt4oPMYfVhEUgP/3Zs1NomkZOQStNtcIE0lJ mbbi7wcaAPSbwTYBcMP1ax9r9fl5fkPQkKQKkpeGDReboMEaLybQ3xKBuiuNNoFsAHoQ ObZtAlQrgCyQ/J8notJtZfTrJ7yxH+RrQDhm2TmMxM1kWkJq7tfojFZk4yR17J+mCf9A JWd67H1aiKJAYmGPlInxmwleNi8Ndq8SIGwt2LHmKqdwBVF5a3hRh5TgtH3tuQpb0JHa Gk+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SRSJfh36; 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 a39-20020a509eaa000000b0045919a1a07esi12864323edf.126.2022.10.19.08.08.44; Wed, 19 Oct 2022 08:09:11 -0700 (PDT) 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=SRSJfh36; 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 S232072AbiJSPGn (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbiJSPFk (ORCPT ); Wed, 19 Oct 2022 11:05:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8C334993; Wed, 19 Oct 2022 07:59:17 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191370; 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=jjpBzMIZil2dmLUT+irfoeemb7oKmLhPxEY4dlNGawQ=; b=SRSJfh36p3UleipLxlUtTUFpPUDmxLS8yo+PBwx959oqjUNw376zK6DIo/TpEECQam0Wav /2i/bDbwVlsuguU4ipVk+E4hAwVZr3ThbxI4eRGPkgdkCfPFhUgsuu/0h07oZavqc7iS6J j2MiWZcfTsr11cF4dBtCFOpcYxI5k3TlsXRagqXz+bBUpm3HMvQNYCWx3izXsjdjez+Q9W wEFLfevTyEeT3C/B5o9VIhitHIt0qyzvN3XoWRCvsHwrp7R5LrgqTxXEsewej4Jm6gnydQ aBuETCfoPiaOSRdbyc7ZRmpDtL6UqKZgreHmyf0z8VczL/og4nKGiDSM/2agug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191370; 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=jjpBzMIZil2dmLUT+irfoeemb7oKmLhPxEY4dlNGawQ=; b=HzSWZdqEZL2J95BBvsCPnMwoU3L+/EMg5oVAvdeTTFj3KSaG3KgrIou7oKqs+PVEiiY/lu WxdYmH+I94CFn5DA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Michal Simek , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH printk v2 16/38] tty: serial: xilinx_uartps: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:38 +0206 Message-Id: <20221019145600.1282823-17-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129101864890250?= X-GMAIL-MSGID: =?utf-8?q?1747129101864890250?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 2eff7cff57c4..e1fe95bd55c1 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1631,7 +1631,7 @@ static int cdns_uart_probe(struct platform_device *pdev) #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /* This is not port which is used for console that's why clean it up */ if (console_port == port && - !(cdns_uart_uart_driver.cons->flags & CON_ENABLED)) { + !console_is_enabled(cdns_uart_uart_driver.cons)) { console_port = NULL; cdns_uart_console.index = -1; } From patchwork Wed Oct 19 14:55:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378184wrs; Wed, 19 Oct 2022 08:08:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM516WidMSA9F/o6KJsONZiv6Xk5YuFjiTgvD9UOttYgRCp8AuCYgpa4tmuXZ5zra8ZYhQFc X-Received: by 2002:a17:907:720e:b0:78e:2b59:fdf1 with SMTP id dr14-20020a170907720e00b0078e2b59fdf1mr7377979ejc.659.1666192118889; Wed, 19 Oct 2022 08:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192118; cv=none; d=google.com; s=arc-20160816; b=DLFcx7FI7RKR8qe4Na2wb2SefLe8l0Szh0p+McvQJGY1d7Q0SOZJZcAyaEBs9BMILn +mInKrmy/cXO/DF2yyninsLegwSJbNo//0d4wz+4EHbrEq+ZH8/WzYIih3gs9rP/fmwY afVlVhVccOAJRWUHHi4YkuzDBoOH+mZ4BYt4ZIrHhNcdjbaShOdiTEDMYA0rR6d5133i iXEuOXXADLexpvC5+RLUwn93wg75oKKHYGXQg4sLCWrLBS68FUW9I82yHYb798d+fV2S r24YI/dXK36DW2Yu/1kLbKgYWYmPzdTwpHzPUyQ0Qx6DnKGh+38cVOUHh1v1AFw/NAQ/ a2Rg== 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=A5NubkodPN0irIWt1R4/lmY742ka0PyGCnf6KGs6APw=; b=aIQw3j1pyWmM0VYmsehwXecGrchxoZqp7L3SXxn96jQFyxWZrcKd5nZyAk8JM34QTl 7nv1GA0xEIzDa6N3p5tQyJa9JiFB3eIrYxTSuFHyM+gWOCRD5cXVAXjrf1U3dVU8N9U8 6oDez7DflxcCWTQIwba040hxKXF5RJgOWRdzUA7/UfpUI/z1i9lOVAzflhgnI7hPEenD rshxwESQzlyVRR7Acv+t18tTu+EHlUkBIreg6q9cZUvAkfEL73Hx0jBSixvUrSjLjm1h CRI8Ti1XS0wHSCW0B7yNBI5Al4s30NjxWMc6sRy41DhIKfCCLhc0Fb73voxu8mFo5YTN 4rXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WEzWfi4K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=7C+o7eTS; 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 cy19-20020a0564021c9300b00451db83b2d6si12276494edb.312.2022.10.19.08.08.12; Wed, 19 Oct 2022 08:08:38 -0700 (PDT) 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=WEzWfi4K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=7C+o7eTS; 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 S231344AbiJSPGJ (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbiJSPFF (ORCPT ); Wed, 19 Oct 2022 11:05:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5091DDC6 for ; Wed, 19 Oct 2022 07:59:03 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191371; 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=A5NubkodPN0irIWt1R4/lmY742ka0PyGCnf6KGs6APw=; b=WEzWfi4KYJK6tM+UtRO9gMqcL80wT6ZfChj8pVIGHeb3YIK8WqcUSy2zLWw/YojPSsGNup y7TQiRk0nnLkGjmOTqw0TEl1/pK8HDisoKp2Nk5Yb4JeRsivDB1CzI0E2o2qg0LVhsdq8m zyNH5ObjKPbpSu80an465e/0eKD5IrMpnPWTzA90Ir/JAkTes5pABQ40isFhZEHLol3hQf G/9qi1yXpMDuoHf2/pGXSYMCmXLbcMI9K/QMqEtFkkge19m+3XWRUYic9PsXu+yn2/vmRZ FNkJG8kyRt1kEdOSxEc5o/S3bJfASgsb4wf/OAS1njjVebC3sch6ryLQd2ZEmQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191371; 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=A5NubkodPN0irIWt1R4/lmY742ka0PyGCnf6KGs6APw=; b=7C+o7eTStwH+TXiK5kilPxMT0uoA0rWx2USLmgf4Q5VlRjt97pmtga3hTsgy3a6OZTtOaX Cj0gT50z2MtWHsDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH printk v2 17/38] tty: tty_io: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:39 +0206 Message-Id: <20221019145600.1282823-18-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129067417336861?= X-GMAIL-MSGID: =?utf-8?q?1747129067417336861?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index de06c3c2ff70..2050e63963bb 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3532,7 +3532,7 @@ static ssize_t show_cons_active(struct device *dev, continue; if (!c->write) continue; - if ((c->flags & CON_ENABLED) == 0) + if (!console_is_enabled(c)) continue; cs[i++] = c; if (i >= ARRAY_SIZE(cs)) From patchwork Wed Oct 19 14:55:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378116wrs; Wed, 19 Oct 2022 08:08:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FqvAqC3oACm5X0N+1YhOatWmXXCL9WKclXukffcjr11HkOLU1qIUbUiu7CLRafW3xcoAl X-Received: by 2002:a17:907:7f8f:b0:791:a840:56b4 with SMTP id qk15-20020a1709077f8f00b00791a84056b4mr2749604ejc.540.1666192109494; Wed, 19 Oct 2022 08:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192109; cv=none; d=google.com; s=arc-20160816; b=j9uLFaxdAUMUn+MJTzDFDzaj3vanZMBI9Fmye0uc5m077AdAsJkuzCPyGtoyIuILTJ t6wNzcW6pAirnn4FNQaRUGjNEvLy7Zmzq0bPiSjMBr9Db4y6vW2DX85j7o1FS5TF4dAG C1MKy5ybe5n8ru3wa5nZZQFX7T5sGMRO0jsZkY1KxiY2jE6jkAG24Mf3r59aTmhPLWi9 Khod3Tt0MEJrbvsgglrXExFv4iiN1Yn5kvlKIxfmQBtAh2zs4DqFm716OZm/NIVsbaru NhOcoPcNS3c1BBhsJUT9OaXpNlnn5MTK3XNRo0XZ98ttlTLO79/0qe9Nh7XMIsM2J8ub SA1w== 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=ROOYEsR0MhxheCxKtRPcb2mfw4k8DWEDO6Xw87lE788=; b=di+4avcc1cikiQixVgyECUYD3bnshI0pVNGDLdFp+LB/40fDO3UmMR8dIBu4/HFvI5 uFCz0TftEDlnVA18qPDNdvBWhwkOD9kHaX9QJyvlTsh6kLqEG2Uq/9zG90rvIOfh00L7 yWVrDM2TCEy9HutdhRF7VK7+nx3aVMvoSQKagHq/CuJFEW9PUWmR7e806IJ5I+xt9c2t UWm9T1KtlRF4RCWDkNQV27vRtWSZm7RxLNxq+MBZZH9zusD2Jo+GEodQIyemQhQ2haEI 9KWQmFzxGj5fyloO9DE9XX8ey/gfI+tjwW5z1QjB/8O8HgbyqvdVf/6FZovgMWrdqBLu npqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dj7K4xyS; 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 p7-20020a170906498700b0078d78fbb88dsi13246164eju.967.2022.10.19.08.08.00; Wed, 19 Oct 2022 08:08:29 -0700 (PDT) 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=dj7K4xyS; 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 S231700AbiJSPF7 (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbiJSPER (ORCPT ); Wed, 19 Oct 2022 11:04:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6B413FDDA; Wed, 19 Oct 2022 07:59:04 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191372; 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=ROOYEsR0MhxheCxKtRPcb2mfw4k8DWEDO6Xw87lE788=; b=dj7K4xySpq7whNrvoUhtROBd4luyoKbpg6xTwFwhdIXZhbdt5NpgczLROroEXs3PgPR5nV 6HyH+7+1+Yrdno3e7XSvm+Rjun5P+yUigjsQD0kip44MepJ/Q022Y5oOoN2gaVaa8YRfl2 6KkfTfDFLG8D29GLh1KJj/8usWDl8staheqlg16yBFk55WoMgh3s8R3HdP3566EXWHdGH6 o7Jh2LwVPpRUpZwQ1KaXB7R3RaCUqh3kXswyT6GrZvNhezCCaXRsvfm77BMTZHoEQMPfxJ d6S8ayitsuWXl06xJ3vmxP14O6b/Blx/0zYuHK1UiScgBw0QdiyNqqvsWRpJLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191372; 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=ROOYEsR0MhxheCxKtRPcb2mfw4k8DWEDO6Xw87lE788=; b=ryuSpo1BnIE5ZnNgWQJ91gufZbr2BMikTU+gIGl5WJJn0EfZEC0dlR7JSp8t5SfbRRzeKa qe9zWCaaaGZeIqAA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Peter Zijlstra , Mike Rapoport , Mathias Nyman , Andrew Morton , linux-usb@vger.kernel.org Subject: [PATCH printk v2 18/38] usb: early: xhci-dbc: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:40 +0206 Message-Id: <20221019145600.1282823-19-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129057440152800?= X-GMAIL-MSGID: =?utf-8?q?1747129057440152800?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/usb/early/xhci-dbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index bfb7e2b85299..b1a9c393160b 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -927,7 +927,7 @@ void __init early_xdbc_register_console(void) static void xdbc_unregister_console(void) { - if (early_xdbc_console.flags & CON_ENABLED) + if (console_is_enabled(&early_xdbc_console)) unregister_console(&early_xdbc_console); } From patchwork Wed Oct 19 14:55:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378774wrs; Wed, 19 Oct 2022 08:09:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DSNIRZ8t1nMlccgoI3wdxYr+9F5zQScRBndsqDpXIUFF0mzu4OuQ8/bbqm1zwzsjHCKYH X-Received: by 2002:a17:906:8446:b0:78d:9f1a:9afc with SMTP id e6-20020a170906844600b0078d9f1a9afcmr7223662ejy.637.1666192184385; Wed, 19 Oct 2022 08:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192184; cv=none; d=google.com; s=arc-20160816; b=Nv1JdK4MmT52fAcdoxe6idZtBOAheitdYy5PNReRW3PJ5yvszVEARF0r1mOolXlF+8 RhTUqcvnWrCE5njGqAYsgvNQlRIkwOIxd77abT5KYLtmZEZ1ZnJX6nyNd0hueD6+M4Vg oP1e2deZWgymMWpwFWf1GXNFgSMrbF4hnR5EC7okfaVQZXc4RTqo7Obuj0ie0CRPKshu M/nzsa81WWWqPR/bKJ3KKdY+MIyTZE47TNyCI2vi4JqDg41rMo+fsdI23T3oX6C8iA0a rFrTv+cHOVRavrxlNSTpOTW/2EPc/ivmt9O3jQG9/B7n57bsnrNFSGPe4xrRBbWfTmfe syTQ== 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=I1RFx/v+hUfcDGQrJ2jjINSDPUuF1n3qxJyJC8w20Fo=; b=ax+d70vTxKYwqgPPQiVbF28XCNy8WHs4pNAS00JxNuwNbQxRxnPAkYqyuo2zAGRWN/ /MaynXrvKWTqUXXISBdYqLPVaWWnOpAPi+XVhog3Gwr5DkV4jYmELhTTB+t/XZg5N2KH nklLX7resaNW9hjVBnQjGfrr77UH71a07GiDpw+emvj/4goDsioybRrswLaN3jSOVaJE UVnAyxCCTg2wqlqgL4elf90wK6Qf88/IZlg/0yzn7jR3Ml87SJmo/dWqNP/lxYl1dpXa 5kavJRZ8lwrngA6QoEd51qiVF6UtAoxbQUF6hnI7Frs9HchbqcHObm4vPmHbWg5452/R Jsdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Na76VoWV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bXJPsQ9I; 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 sg39-20020a170907a42700b0073dd47c3873si13603845ejc.878.2022.10.19.08.09.17; Wed, 19 Oct 2022 08:09:44 -0700 (PDT) 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=Na76VoWV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bXJPsQ9I; 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 S232040AbiJSPGU (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231804AbiJSPF0 (ORCPT ); Wed, 19 Oct 2022 11:05:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA86192D9F for ; Wed, 19 Oct 2022 07:59:05 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191372; 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=I1RFx/v+hUfcDGQrJ2jjINSDPUuF1n3qxJyJC8w20Fo=; b=Na76VoWVvHR8U/NeE5ZW4Qj/8y6x7pe9hXOgikZ8soMx+eMpjEC1D0Ljtsuf7gKOPi1SDV O3H/i2rcTIQgphMFvzlgRv/uQQZ/LEqst5WRZnTXPkWrOxFhCP0cC+X4xmwV9QwQt8kwca JYqIAB/VA0uqLjmgRGxiFV3y2r4MhAxXTUQjFEifIzKwTlsUDV55eIk4i97ma0O49fC/xv vZIf5vcZpREDTpUHMQcJcVIUftRDZvqEiNVhEF4yBmFJvpLY8XZrmnW3/QU04Bt97BGLkB AELofnWb5Zk+quDqxs23odjOpZ43C65y97abkXno++P/O3VWUEZmj6ZrHjrAFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191372; 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=I1RFx/v+hUfcDGQrJ2jjINSDPUuF1n3qxJyJC8w20Fo=; b=bXJPsQ9Ibdzn9lP6cPILeOojpe35Hpu6UnYqHQ3BjsYI2l13B6GR71QgyJ9Uqh17/ObVif drEUXkAw21hR9pBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Luis Chamberlain , Aaron Tomlin , kgdb-bugreport@lists.sourceforge.net Subject: [PATCH printk v2 19/38] kdb: kdb_io: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:41 +0206 Message-Id: <20221019145600.1282823-20-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129136049900246?= X-GMAIL-MSGID: =?utf-8?q?1747129136049900246?= Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). Signed-off-by: John Ogness Reviewed-by: Petr Mladek Reviewed-by: Douglas Anderson --- kernel/debug/kdb/kdb_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 67d3c48a1522..550fe8b456ec 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -559,7 +559,7 @@ static void kdb_msg_write(const char *msg, int msg_len) } for_each_console(c) { - if (!(c->flags & CON_ENABLED)) + if (!console_is_enabled(c)) continue; if (c == dbg_io_ops->cons) continue; From patchwork Wed Oct 19 14:55:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379689wrs; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UVDBEbpXA1IF8pYiLQo4flYAbmKBViWpYN56WxkhWta/QtGim49s70lD7lU89WZWdNkqj X-Received: by 2002:a05:6402:1587:b0:458:fbea:436c with SMTP id c7-20020a056402158700b00458fbea436cmr7956464edv.407.1666192285084; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192285; cv=none; d=google.com; s=arc-20160816; b=Kyfie8oQHT5dWHIGU7jIiYssUq28MpSBQDTa8fnbZ2sVeWrIuqC1vZxKlXVD8aRANr M7cPMD1mUrwKLYAmCrdZGrspkmJAEK0SYtaOwV0nMbgaKXDir6YFaODwKb5FoOCwOTLU bqrbsoW8nXi4kVOhDfXpF18+cp1Yr3nCgY+tDusXMDVSeHIimGVaPOcAGCpi99NCHoOw EIn3swXRTZnVsYwESh3C38Ob88lR3zQvjDJaSbxB9aTg9T3ni9fNNIqJFqOOgW4vhOYe Xk8vunLfA+10q5BKzpSxemSWWJKUvqqqbRF9AbWaqgmgGNgbMR0vL+HSIikrwlHX9oER WetQ== 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=2RcyNuvhxtc3XAp6KUXXBEZGfBTKoyRNmah0KdJRqUM=; b=fXG4pjRv22aV4vvGjJqMDFip2QO4hZceEUux1K5WKb4ZuynUxLOc5mjS8Vz3zAenqW mbqy1I4cPcgqAEnYWSYaMtit/APyrhhmI1TTiIXPe0ydmyzJ0MjzvRwlTF9Y2bxs4zX6 TUqoMac8ySqkWWgWegjXk1iL7xFyxQlcXf1tmkmI5BJaPj0+DwW1TqMTZGk3oylb8XP2 CajcOMj75f+P/k/afEP9cSsDEptCYAX1Iy1AFsnLq5o/G+z+Wj5ZtgSyW9n56/t0bDv9 15y8yECKuoDz+yXCPb+kv9Rl4BwkNuavY1lhPlKl/K+0BR2FGMP7NBW7pJ6UCFLVNEzR 6IjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=s+uK2CVy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=o+Tf43pK; 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 dz10-20020a0564021d4a00b00457fb8f2a64si16572055edb.563.2022.10.19.08.10.58; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) 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=s+uK2CVy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=o+Tf43pK; 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 S230154AbiJSPGR (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231617AbiJSPFF (ORCPT ); Wed, 19 Oct 2022 11:05:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50FEB17A023 for ; Wed, 19 Oct 2022 07:59:04 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191373; 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=2RcyNuvhxtc3XAp6KUXXBEZGfBTKoyRNmah0KdJRqUM=; b=s+uK2CVyfeRWS2SM8ONtEm3ezF4TKCfBKPBHIwbQeW7/3EKdt2DXK8Se8xiredxeNeCSkY ZKidWJ9kOFMnJ+GDRhqzajlfU0p4AFkX17OY/4V8RDFxWqEJS/1ZvxtBmCOcbU/4l2IV5+ uARnYyoVv6Nyvh9wOtzsxW1T3vJw5LOkY1LuXAHyxPLMVW6YaxF14EZEX4gyzIy+5CXUjS vS1F3O108Xc1xgSipOJuPxZcLQ/qV1jeZloh/cC1xGCqj2wAIwT9zN8nuby6knA2dC3umy BQvb2BMGIRylFs6NDquzoIBMVcnZI7H6sM7m8P0T/FddSctNfiRBDKDOqpiRPg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191373; 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=2RcyNuvhxtc3XAp6KUXXBEZGfBTKoyRNmah0KdJRqUM=; b=o+Tf43pKW3jb3K3SYt/Uyhx64JMO0G2cG8/ulnFuahJncjT6ev9pQxCcwgJEpI8Oeo5SuX YSUluQ/obMklGtAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org Subject: [PATCH printk v2 20/38] um: kmsg_dumper: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:42 +0206 Message-Id: <20221019145600.1282823-21-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129241497581372?= X-GMAIL-MSGID: =?utf-8?q?1747129241497581372?= Rather than using the console_lock to guarantee safe console list traversal, use srcu console list iteration. Signed-off-by: John Ogness --- arch/um/kernel/kmsg_dump.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 3a3bbbb22090..44a418dec919 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -16,20 +16,17 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, struct console *con; unsigned long flags; size_t len = 0; + int cookie; /* only dump kmsg when no console is available */ - if (!console_trylock()) - return; - - for_each_console(con) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { if (strcmp(con->name, "tty") == 0 && (console_is_enabled(con) || (con->flags & CON_CONSDEV))) { break; } } - - console_unlock(); - + console_srcu_read_unlock(cookie); if (con) return; From patchwork Wed Oct 19 14:55:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379037wrs; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ukygA5lXSjBK+Uxtmt2Oj8ow0sP30nzRVnTzZxdosigSW6xFxA5MkyR1kTygK5XisWd3i X-Received: by 2002:a17:907:7627:b0:78d:b6f5:9f15 with SMTP id jy7-20020a170907762700b0078db6f59f15mr7207330ejc.149.1666192213768; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192213; cv=none; d=google.com; s=arc-20160816; b=melsmZHQYcY160etFQIkks3XNS31aUrCrZmcblZDkoF9cvmh7QIR5jQ8QwP8aYWHte O9FhG7vHWbeBHZ/1HCYTE4ZRPZhOKXv/UVVFYGsPtWIuM+u0aAC5DSO4EcLVp58784Tb Vkd4HiqpxzgIfHu9taD3N5ioMsa3I/s54zZsJ3myxfxaR/t07o+vGVljHQfOyf4smtMW pY1W6OLecFP0n8FAm+kJwmbI03hha7EdsQnvO9x+wyxGB2nTieMK6126oE9SuhKppvcN IKkXAJTJEADPtRzuiXCTNmuL5Bfeo5rtD+kEwgDWrnuD5qHh+8O8SzGnUAWzzWUe3whi SZAw== 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=aHpEExScLzm4b3PGICcqjxP6eSShWDRVil4o7DIdRaU=; b=rwdvJ3k6h50AmF/sbI037OYy3TNMGD49rtsF86ZPVyUvsq3LKl86UrKlGlBa8VGQf/ 2d0cUskShM5QZDHtW3wPMO1k8T6Ee098IjM/91G2Ao2TTtaPBY/CwZ10OKxWMaDMpwRa nPfoHdJPlNGmhYXt6AKpTUWpFdfzmnDYF8ABRH+KIvk6UcSv3hFDyeAZQFQfFnOGende uBZiGkgxoGidC3NJrk6g9iQ/EAszfK6Im3StSkJwxD27ldlimCL8pTpePDCl74QlErxp +ZVMwqJTg6D4EPxPW3hPHJbxOcwcRG52xkAPG6+qKiG15EdpL+wXciQRS48qKVB6EREN FLxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="eDfs/FrH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 l16-20020aa7cad0000000b00459c1e64776si13018144edt.412.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) 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="eDfs/FrH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S232115AbiJSPGx (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231892AbiJSPFm (ORCPT ); Wed, 19 Oct 2022 11:05:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432F6193EE9; Wed, 19 Oct 2022 07:59:07 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191373; 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=aHpEExScLzm4b3PGICcqjxP6eSShWDRVil4o7DIdRaU=; b=eDfs/FrHZ7HvnRF4atKhYEZ/pRXno8GEGAkw6IqnyiCmO75Q9sEJ6bqLoRWApu5I/kGcQh KCTzK1MrPYWFQHFbhhZ4ddIBd7thtElTQ1FhTZSvTGr+D/NiY6ja5av6esQrgKRy3JmdV3 rrRE8vZ1b74ucDPVRwBFE1RIC+RhuKL5DdLWniGfxLfcajr60p331h+dY6KdEzGysIZMdC yATsOHK/PLnHwsUFjoxiti7aJ0XxaKU0B+KQDroX00sQ4UKCeboef9oWWEJpZprSsCboLS UQL5y2A8i38TojR6bF2UMoVPjjyV/EALMD7ITlxAjhc539biNA5Q3/A88oMp9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191373; 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=aHpEExScLzm4b3PGICcqjxP6eSShWDRVil4o7DIdRaU=; b=ag8wipmZjScVK96FvYUT41NwW8W8jBS77tduneOJOnLYN8uLmQW8RkuO+x9sTyAf/SfPXA QV5RyDV2N62v9UBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 21/38] serial: kgdboc: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:43 +0206 Message-Id: <20221019145600.1282823-22-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129166988124279?= X-GMAIL-MSGID: =?utf-8?q?1747129166988124279?= Use srcu console list iteration for safe console list traversal. Note that configure_kgdboc() still requires the console_lock in order to ensure that no console is in its write() callback when its direct() callback is called. Add comments to clarify this. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman --- drivers/tty/serial/kgdboc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index b17aa7e49894..e9d3f8c6e3dc 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -171,6 +171,7 @@ static int configure_kgdboc(void) int err = -ENODEV; char *cptr = config; struct console *cons; + int cookie; if (!strlen(config) || isspace(config[0])) { err = 0; @@ -193,8 +194,14 @@ static int configure_kgdboc(void) if (!p) goto noconfig; + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ console_lock(); - for_each_console(cons) { + + cookie = console_srcu_read_lock(); + for_each_console_srcu(cons) { int idx; if (cons->device && cons->device(cons, &idx) == p && idx == tty_line) { @@ -202,6 +209,8 @@ static int configure_kgdboc(void) break; } } + console_srcu_read_unlock(cookie); + console_unlock(); kgdb_tty_driver = p; @@ -451,6 +460,7 @@ static void kgdboc_earlycon_pre_exp_handler(void) { struct console *con; static bool already_warned; + int cookie; if (already_warned) return; @@ -463,9 +473,14 @@ static void kgdboc_earlycon_pre_exp_handler(void) * serial drivers might be OK with this, print a warning once per * boot if we detect this case. */ - for_each_console(con) + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { if (con == kgdboc_earlycon_io_ops.cons) - return; + break; + } + console_srcu_read_unlock(cookie); + if (con) + return; already_warned = true; pr_warn("kgdboc_earlycon is still using bootconsole\n"); From patchwork Wed Oct 19 14:55:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379354wrs; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WaUDiFeYoY1lPZQW4JxyK840JLQYvmNWzaQ2UL5jC/x6s0paOQno7QGlXx8VyMKh79BN7 X-Received: by 2002:a17:907:da4:b0:78d:4bc9:2497 with SMTP id go36-20020a1709070da400b0078d4bc92497mr7324088ejc.183.1666192243547; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192243; cv=none; d=google.com; s=arc-20160816; b=cHBQKwBSerpt21rYNF91f3UQyPvhCddoxwf3IiJvdorn9wMa51PYoSkF3XcSMWf61J gOPkrOSewueIWcA+chA7EbJq/s2VJcVZ4xhKJWEydNA5flsvLIB/Z1HueeNVnbcLDpew pVoLc4vFr4J/4fUqjY57B9cXCSCw8179DTae15Y3g6Chj5bLD2q67HTT0ttZ4uPrFY+G KK2004GEWF7Jy8ZeWsOOE8gfdB+8chiEOB55HXWARgdq204ksnG6cTDHrv61Xh2fOl6b PCnAZDcpgLv1r56jVfXOmMiigbrKgWAZWxuAF6Pv7srPUJ8C8x5J31fUoEHcPsV7YYQF 2YvQ== 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=LrGk/0HyKJ+1t8t9+1TW9QjluUem4tRuCx3Ywc0uWbsRprUzzES0UZW0xKZEDNMuS2 ZNfGiyNs7nKK0ISLJTTJi9NZp91MrTzDp6BN6YRZcXiU2lRnX7TqB9klM7fNfDIU/XbN SdzvqDOOHIIr71IUqcP9lCUhTX7SWBfl2XVpXRFfT1HJOPd7OiYjBIwbfXTsOwyBEm60 2j34cZWCjae5TOILwhTotDR1vB7pENsy3mvTRMtkkSnvdsx3uPNfcFES3Oj6TyFXas72 q1sQ0e5CMtw0zaDvDMpq8D0p7wZj30Mlxm2MGAyyUrskaAcUqxoVFv5nzQ5cscV1h7M0 U8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Ccgy/tfH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yIzC1pH2; 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 lv10-20020a170906bc8a00b00775326fb2ebsi12792073ejb.665.2022.10.19.08.10.15; Wed, 19 Oct 2022 08:10:43 -0700 (PDT) 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="Ccgy/tfH"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yIzC1pH2; 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 S231801AbiJSPGE (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbiJSPFF (ORCPT ); Wed, 19 Oct 2022 11:05:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B872F007; Wed, 19 Oct 2022 07:59:07 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191374; 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=Ccgy/tfHlK5pUky0RE3+PgIt1rgjfkq3Tlb6Sd8WDUWfjg35ogZEbfXvjsXgVU7QAtpI49 nw+J0Yr/pj68t053bnHszLo5Yf5Got25SfdJCTQ1XQR/4b43Xz8/x2LVdovnTWreK9d35z WppqeLftN6a6CqKiUrS4MgpzyM4QuBB9/5G05SLCI2HKV5qPIqRLUZfGfcz/gCiINc34o6 h7jJYblRSvG5ZqO55I7PrZ9Ycato2Lu3jOD83rw09TuE0vlq+TQ/1tpX9HLurzS3xA447+ yFPYxB156iSolo2OCep4UyfsiV0RLod+tQBCSKSpjrxSxsn1FDpKIja+pCHk1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191374; 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=ACPI8gcDk9OHrPL7ke5XVpq5ui7KkEF2l2bHZNH8aSI=; b=yIzC1pH27dxiAovKC98wbTRSEd+6o8YRWTr6jNZ8jbaA2SP9qlYcbF+l4kQ4Idnk3qN43O wYA6fbuZuIsJFdCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 22/38] serial: kgdboc: document console_lock usage Date: Wed, 19 Oct 2022 17:01:44 +0206 Message-Id: <20221019145600.1282823-23-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129197982960680?= X-GMAIL-MSGID: =?utf-8?q?1747129197982960680?= kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. This is necessary because the trapping of the exit() callback assumes that the exit() callback is not called before the trap is setup. Explicitly document this non-typical console_lock usage. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Douglas Anderson Reviewed-by: Petr Mladek --- drivers/tty/serial/kgdboc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index e9d3f8c6e3dc..48000666789a 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -545,6 +545,14 @@ static int __init kgdboc_earlycon_init(char *opt) * Look for a matching console, or if the name was left blank just * pick the first one we find. */ + + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until the kgdboc_earlycon setup is complete. + * Trapping the exit() callback relies on exit() not being + * called until the trap is setup. This also allows safe + * traversal of the console list. + */ console_lock(); for_each_console(con) { if (con->write && con->read && From patchwork Wed Oct 19 14:55:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379748wrs; Wed, 19 Oct 2022 08:11:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WjZjGMbLPTEny88Gjx4E36h2t02wgEpuph+0H4rk8uphPfZ5c+uYMJ2rlJ0UDaa9flMw9 X-Received: by 2002:a17:907:96a3:b0:790:65a:3a0a with SMTP id hd35-20020a17090796a300b00790065a3a0amr7441041ejc.728.1666192290836; Wed, 19 Oct 2022 08:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192290; cv=none; d=google.com; s=arc-20160816; b=gGNGnBTXfVLo4Gdl6Ry4PySL2+hPazILhvN7/bn8TBbTMXGTkcxadUovK1M2QR50xb 9iQ+ABpr4DhmmEpcLsWrtqzFXUYGxWqOf8oOYxjSoyqrSufV7Cs9Wx1o5TAc6w4GoZdA OEMfdJiQ5aSg6RndERxsSoZ4bP6IU7ZMnjRqA2JaSCIJWyK20eD5NEkhZ8sl5CJP/0ap p/pebry7+BeYReZZJ+VFjzvBumT3KvoEoP5pijPpv1XrxJceBPr+WjY+eur+fsIJhvs1 WayBCztrFK3L+zF9Zpl+RKJ3iAR7B3jto9wIiU5SSze0ZGyG6bVxlq6OghVqN01tMHk3 p4Rw== 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=Rxx7a00tnCHfnWXA978Xi0IL/mfHFWoLJumPfZjxuVQ=; b=IdB2bEluVJWdDatBRIh2rxAIFlLyjzFHxI5+PvxTwSMTQicEEblaq/ukmAeucX/nC5 3o/BPd99hk5cJJHwReK+AE7HZWVEqOLDDMwB+6VLhXIsWpkkzdxTsDJf230ZKRw6so0C mnqIknumkdhwp00NHmjr0kq/SDGpgS1U0jTmIkswMBPp6qR4sTQD7IXfimnDrw308qLW Zs43wkYIEZj0/0nsuHTbzaMh4xQlmnVtS49ZxASpnS4hIW3JdDioG40Ntb1fBp/IRtTq MQDZHCkiULeuIhDBr1t+uBzCcspxRNS55oExevpZ130C+bljanWyOWJRL8204LRVZqNh dFsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=odMAd6jZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 q14-20020a056402040e00b0045d8bff7b1asi7003968edv.403.2022.10.19.08.11.04; Wed, 19 Oct 2022 08:11:30 -0700 (PDT) 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=odMAd6jZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231927AbiJSPGf (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbiJSPFk (ORCPT ); Wed, 19 Oct 2022 11:05:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB4B13D0F for ; Wed, 19 Oct 2022 07:59:09 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191375; 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=Rxx7a00tnCHfnWXA978Xi0IL/mfHFWoLJumPfZjxuVQ=; b=odMAd6jZuExx16Yi0L8xd1hm9Jh9VTjUOvjUUgrX8qFZQuCWOzfAaZvh89StL/uY5ZVjZ4 7F0py/hns3GzhNljNb4CSr+P5RvwEKeVFVSo7ucX0apDwGWsb+zxnCp4263f8YKJ9a5ej1 2rV6t+eru8+PT568/dvEv0WiF4bn/adCAwyLxplBuLF8aZHWoHD+n5evDi2JVgnqY8rjNr Pt3sSFfwb1FV+WRk5mWlhtAOGR/p0dm76Sw3rc+OGGbhM33YJGS18mUoUTGARbsvXP77z4 CFsQZ+FmootigSKYJ31Vjh5hqGF6+j1S9tpl8U4eAuAup1tordjr0REfQ7pl7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191375; 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=Rxx7a00tnCHfnWXA978Xi0IL/mfHFWoLJumPfZjxuVQ=; b=q9rIFA276lgWZLXV5mkpOktuUZD6YWke7bg19dKAJViyJu9A6OrFIkzYrQzLJ2n8EtnLIQ id3MWXWGrsWj0ZDA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH printk v2 23/38] tty: tty_io: document console_lock usage Date: Wed, 19 Oct 2022 17:01:45 +0206 Message-Id: <20221019145600.1282823-24-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129247991016914?= X-GMAIL-MSGID: =?utf-8?q?1747129247991016914?= show_cons_active() uses the console_lock to gather information on registered consoles. Since the console_lock is being used for multiple reasons, explicitly document these reasons. This will be useful when the console_lock is split into fine-grained locking. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman --- drivers/tty/tty_io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 2050e63963bb..333579bfa335 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3526,6 +3526,14 @@ static ssize_t show_cons_active(struct device *dev, struct console *c; ssize_t count = 0; + /* + * Hold the console_lock to guarantee that no consoles are + * unregistered until all console processing is complete. + * This also allows safe traversal of the console list. + * + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ console_lock(); for_each_console(c) { if (!c->device) From patchwork Wed Oct 19 14:55:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379199wrs; Wed, 19 Oct 2022 08:10:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OTGnh4LOJBYHRDdJRgr1+X2ccd0hhLgFCKuZMELWK6JjakRjP/ig8YY4Am3tb1mVZ3YMC X-Received: by 2002:a05:6402:28ca:b0:43b:5235:f325 with SMTP id ef10-20020a05640228ca00b0043b5235f325mr7903623edb.320.1666192228720; Wed, 19 Oct 2022 08:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192228; cv=none; d=google.com; s=arc-20160816; b=VpudNb9ScR97OM6zvG8NQHev1CWGZRodSHE3Cgzjrx2XWvv5hbicrTcepQikt1JZ3+ GmyopQUuME6W4l9cmMiYnq8G34c36ZijJDbeuq2VgfO/PAeNlG+ucoEnpPJo7V6iBpvF adt2jroU6E0cHH3YwDdaRjeGO2MhjvHQWdMfynxf4Db4Gk0HZekCayuNqbVCOtj2CPn5 dAURpB+FsU4g0Bx25dYkKPFqg0XmYjtzFLZZS36mj8h2CTMUiq8zWcNcyZDwE065IlB2 QI3fVVKR6t6+1gKMH53sKUJaObQO9qgyfAL1J73vQm65ixzIL4kK06ke9K043e1gNSZl INhQ== 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=yQcHjaE6CQfq7iO6zRmu96wMYI8aMwb9KZsnUEYxyHY=; b=ZoMQ890reTKR7xFYFleckeKRx+rvhYq+wso337IQGh26ukuNgBA1j16ExuWvYYIV3C kNMM23zVyIpcnjidvmO2SUQj5kh3xUTgW8Ml1ZZlrnifxvG6jiKk1z3nfx7dCbeko8SB s/2GiUkQ8WF+nEYEqJWLBCp3w8uW97zGbeHAJP61PhijXguF9MKuWxF+kpcsbltYQaU8 4urmvPa3gdYUbS/nAYPwsUBDtDYT31C9Vflpk+2pIx7hkygnVMkKAVfk3OjHh2Xu83kv LFmx1sUT6W2ExcF4SP2tXScIFNQ+MQsMxt9Gl2/Xyq75z1+Xhu0qKYHdIXTlU5blAMbE QzfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uJxwQf34; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=FnIygPB0; 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 z96-20020a509e69000000b00459148fbcc4si13367979ede.483.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:28 -0700 (PDT) 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=uJxwQf34; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=FnIygPB0; 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 S230393AbiJSPGu (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbiJSPFm (ORCPT ); Wed, 19 Oct 2022 11:05:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87FCD38A0; Wed, 19 Oct 2022 07:59:21 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191375; 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=yQcHjaE6CQfq7iO6zRmu96wMYI8aMwb9KZsnUEYxyHY=; b=uJxwQf34Ytc+E+xlVFr+QJdkNyrMOfUvwvaZcWKOsw0HPBVGrb4yMLRvikG5fD7cUCCc3C 28HKnPfM+uG1Z5z4L56fxWXyrRIKTZSVZptsjItATwqm3Q4MhzYIPKqCJpyLB7fFVS0j6u /X9PqMg8IxzzFdciI7TDe8A+OYuDmG+ME1toyuS2fFqmqa1hTm+YBUxQV3oCJZHXuqalbQ QU8S/p/3lIK/8LUUToUovSXE4jfY76zMpDU7MTtRzM++2mNnVj7bKvcl8AgTMdYYD4YXz3 z8y5puCaOyxnbNpSsfsdnnyyPts9YXiBFHfz2EsNyXbwpHaTQcRNqZA6iu/ZOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191375; 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=yQcHjaE6CQfq7iO6zRmu96wMYI8aMwb9KZsnUEYxyHY=; b=FnIygPB0dsrSCCUyaFzWqQi5S8pnwh8nD/V378wLSKMrAbys4FHt9SsFaYaowHj8t+QBgh QwF/uqpaFI+ppICQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Helge Deller , Thomas Zimmermann , Javier Martinez Canillas , Boris Ostrovsky , Juergen Gross , Tom Rix , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH printk v2 24/38] xen: fbfront: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:46 +0206 Message-Id: <20221019145600.1282823-25-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129182273632452?= X-GMAIL-MSGID: =?utf-8?q?1747129182273632452?= Since the console_lock is not being used for anything other than safe console list traversal, use srcu console list iteration instead. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- drivers/video/fbdev/xen-fbfront.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index 4d2694d904aa..2552c853c6c2 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c @@ -500,16 +500,18 @@ static int xenfb_probe(struct xenbus_device *dev, static void xenfb_make_preferred_console(void) { struct console *c; + int cookie; if (console_set_on_cmdline) return; - console_lock(); - for_each_console(c) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (!strcmp(c->name, "tty") && c->index == 0) break; } - console_unlock(); + console_srcu_read_unlock(cookie); + if (c) { unregister_console(c); c->flags |= CON_CONSDEV; From patchwork Wed Oct 19 14:55:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379247wrs; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wZFiKZTx2l0o3hkebYJ6bIyjl34qrD3ruELlK3qciMWhQJ05DtN73+pKDY8s4XZ92Wvxl X-Received: by 2002:a05:6402:c4d:b0:457:99ec:1837 with SMTP id cs13-20020a0564020c4d00b0045799ec1837mr7880039edb.86.1666192232738; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192232; cv=none; d=google.com; s=arc-20160816; b=D9H38dUKgHZu4ZumpZSlOYKUtNONmAxEFaQsJI7GUUkreO2mFU0qswPsBwzHlpgb8A Xi6pl9mOzPlWHSUeDoCdf9m1V2Wn8je1n7WC6OR01OCqVNHzRZfNyoslxFUjVFLprz74 DUPmBer4yNdUHYt9UGJLGksJGs7UpVOphjCam7YPqXd2JAvZFlDUEFg9Eb7xjL9nvYED Ek8FGR0c5fqAnG8ldw3nlVTDOd3zzJHvHWfuyXV6RUssfm48/pNo5jrtLGa/WAlcCm5P 4S0GTKssnwMX95z5732uk57OuLAqmAm38z7lzo412TlQQnj8ljCq+q8vQ9pJxj4bLNll Xi3A== 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=EK5+Sl7RRycigi1xgCpc1e/ZklpWCkacOe/zGWStrLF8cLDMVovxUjyqMppnWQwTYy DxCh6AqVaTtEhAMhQOCa/03H6G2jvhZaD8Et6QPO2IEzDi/9+U0Rn64xAOPbvc6NL1n3 uwTObEq+ZRhsGJAwtHDwrzVB6iug8s4pCwP56Vm0DjpRoMJlRBQv7O6drm/VLk16EegC SaIHZcUYdpT1NoYD9ehekIGyP3UD9SaWWay1rSfC4pR5wrjG6XiYIqtU+i4QOSBgx1jc zjnohDlcrmgyI/Wkr6SQt636MhfpM+Z2efDpBSDSK0EQbBBhQVgQDwWtZQqJsijSkzz4 xbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qy+XfEMT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Bczhayh0; 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 g10-20020a1709065d0a00b0078277d265bcsi13738452ejt.204.2022.10.19.08.10.04; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) 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=qy+XfEMT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Bczhayh0; 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 S229784AbiJSPHJ (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbiJSPFq (ORCPT ); Wed, 19 Oct 2022 11:05:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DACD4BE38; Wed, 19 Oct 2022 07:59:24 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191376; 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=qy+XfEMThEbkLnrE1n36Z2pN+sVWm/xcWaaykneLdYt/vpE15mr9kwHlg/KLo+RWPWYf34 etPdErRihRuc+qZDB4lMGkJwkzOj0k873ip2RAnXf1ME6l4C75Nr7d+ZfLt0A0Xix765FH uOFeEgTaLBDP2HXzMyNMjWIC6zZ5DT5w5YwqCIu/1LYCInpQWEgjFfzVpFkk5Po66g2mEg NgEYb4GBaW4tD2U/AaebbabvrhjAUfC3V7esyJ4gKfuPnB8m9poV9ANs+Oggu69i9E/XY4 u16HcZa6/YcQ4gML73ZuMD0kDTA/mUUFqcAiH6w2xMHdUNjXCQYt02KOINdzng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191376; 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=vk9lLFSPw7DVFHn+Ltr9+ux4PzL45JriVQ+GTbz1WOY=; b=Bczhayh0iGG8icRI55cYRrg7pJAHOfB2u8QZ/VTPoePhI61+DqIcsXd3xFHatJNL5JU+gj 3w0K/ax5IwNRZjBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH printk v2 25/38] proc: consoles: document console_lock usage Date: Wed, 19 Oct 2022 17:01:47 +0206 Message-Id: <20221019145600.1282823-26-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129186611816604?= X-GMAIL-MSGID: =?utf-8?q?1747129186611816604?= The console_lock is held throughout the start/show/stop procedure to print out device/driver information about all registered consoles. Since the console_lock is being used for multiple reasons, explicitly document these reasons. This will be useful when the console_lock is split into fine-grained locking. Signed-off-by: John Ogness --- fs/proc/consoles.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c index cf2e0788f9c7..32512b477605 100644 --- a/fs/proc/consoles.c +++ b/fs/proc/consoles.c @@ -63,6 +63,14 @@ static void *c_start(struct seq_file *m, loff_t *pos) struct console *con; loff_t off = 0; + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + * + * Hold the console_lock to guarantee safe traversal of the + * console list. SRCU cannot be used because there is no + * place to store the SRCU cookie. + */ console_lock(); for_each_console(con) if (off++ == *pos) From patchwork Wed Oct 19 14:55:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379238wrs; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60g77yr4+7+1R/xo+QUd6C61M1E99+X7OdSSBB/vyL0As/869OfR+4ClUp5goWCioM7hDe X-Received: by 2002:a17:906:7952:b0:787:a14d:65a7 with SMTP id l18-20020a170906795200b00787a14d65a7mr7361738ejo.108.1666192232004; Wed, 19 Oct 2022 08:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192231; cv=none; d=google.com; s=arc-20160816; b=ll4BwM//OuL+Hgp8qFh22LwUqFXNv/kJhAax05UqtY77D8W9V+FY+G9Q06JxZ/2dgS kE070J2QZy64w/kzO/0aJgNUGe+wGZ85QsTJFotA2mr/8ia6i8NG6/lgRwzs2rIloq4D EhEHa6pInxvzqrzP8oIailYo6p2LpnzF4cWNOOo2GWAuFwiLq/V6jZrR8u+OKXt3y2S/ KSABeIHggeIrPnVEKhcy6ffjez+CcfSOUPth6mj2HJcJxNDDGGNh49aqj2Y1dVTguPYp FqE70Tcg7UMVt5STEpL1jffMsMDNOfC6xKVIibdJSnIBzvKgAZkzNVjyEe27UGk0K+44 R31w== 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=l6JL8Q05OijoTEvKKyIiYa7K6VvZeDLREPexuqG68w4=; b=eRzv+KaEEOoM6LAsH06m4fIZjwB7RmtrSpJp6S2Awkx9n7V+2iPsFsmeyIwB93YwjP x4Jtvt8HL0Jcf1siMK89tzRj4RmO7T8AQZ2wlCUau/IuxtzLraQM0R6zdAkgFq+LSoQy uGBgrVQufYsRBJ66HTNRNkWH9ABz8EkEqkoo0lYDuu9iIda1GjfHZ/cBnsY6IHcsKcUv 1OWcBcVBvhlJgS66LECJCZRfQ+xcY6C1cBrBwSpD45VcX8EAJ6D9iZCymgdbw8HswLGM 169nwfpKkDOpDcB0yKAIiqJiDVxbxfJ/A9e6Yxh8SaDLLOBZP0aBlUFS2YQTu3QgWV0P s3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2lE2ZSVv; 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 n11-20020a05640205cb00b00452697eda4csi17237808edx.58.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:31 -0700 (PDT) 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=2lE2ZSVv; 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 S231931AbiJSPHD (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbiJSPFp (ORCPT ); Wed, 19 Oct 2022 11:05:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DCD6573 for ; Wed, 19 Oct 2022 07:59:25 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191376; 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=l6JL8Q05OijoTEvKKyIiYa7K6VvZeDLREPexuqG68w4=; b=2lE2ZSVvaLYxX/mxts/imwzBNHAp8IFSDC/ai7lkxP1zyF6vpMFV8KAaG0pwB+zKzWkutn BNZQsjhTA+fE9mUGf/9zLZQuPNRIBu0owJpd7GDzfuULoEKri5Ic8olH4bE1eI5Rf1CKGy vTs3ThAfna4xN6EPjQmcBVcPNNwb7z99UsM+MaDiSMsHRWQQdQDukhcxIu7T4tOZ2TYmxg Bfdt5cy+/S+IRAvC/LS6NYxQYe0e79/FQQRYb/Mcd8jS8qxWB1iuXQe85SqXEhXYqiH8j4 +8mgUokSmCQOtAKhWeO3fUlqU5Flbi2cC2akX0Xw1B69Gv1ldKxWWm+8ITOUfQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191376; 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=l6JL8Q05OijoTEvKKyIiYa7K6VvZeDLREPexuqG68w4=; b=CQZkI2DXDnPwDZmhG2PVbvPciqqo6PQ6K7EPwjaFXRMKTNR/ZrE840g4rZSpD8aFVitZok a6Wx9DhxTm9LofBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Luis Chamberlain , Aaron Tomlin , kgdb-bugreport@lists.sourceforge.net Subject: [PATCH printk v2 26/38] kdb: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:48 +0206 Message-Id: <20221019145600.1282823-27-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129185982216029?= X-GMAIL-MSGID: =?utf-8?q?1747129185982216029?= Guarantee safe iteration of the console list by using SRCU. Signed-off-by: John Ogness --- kernel/debug/kdb/kdb_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 550fe8b456ec..5c0bd93c3574 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -545,6 +545,7 @@ static void kdb_msg_write(const char *msg, int msg_len) { struct console *c; const char *cp; + int cookie; int len; if (msg_len == 0) @@ -558,7 +559,8 @@ static void kdb_msg_write(const char *msg, int msg_len) cp++; } - for_each_console(c) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (!console_is_enabled(c)) continue; if (c == dbg_io_ops->cons) @@ -577,6 +579,7 @@ static void kdb_msg_write(const char *msg, int msg_len) --oops_in_progress; touch_nmi_watchdog(); } + console_srcu_read_unlock(cookie); } int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) From patchwork Wed Oct 19 14:55:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp381015wrs; Wed, 19 Oct 2022 08:13:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pUDva4wR+gNbBdkEn6bN9jjN3BKIDwsPUhObzyS98kHWAKszBq+kNyZqHGiPrw9JMSb1x X-Received: by 2002:a17:907:2d2c:b0:78d:d289:7efd with SMTP id gs44-20020a1709072d2c00b0078dd2897efdmr7284958ejc.166.1666192415429; Wed, 19 Oct 2022 08:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192415; cv=none; d=google.com; s=arc-20160816; b=QVn3PJQkCN4fcclKnhDOv8jgMk/KuYC1oH+8AlyWVTPGL0IfIUfFfNMteEsts3tcaT LO+68kgoVd9OngiIYzcB8nALJIv+9sbIvMbt/7D8CYKwidbxglKqHrO7GVkaY4ITCt4W BtjwhLfJgmbbD6jOcathz6p6HXdqSXFAgsfYA8P6HRKoFF7ySCSE7MRqFJfpupsvN0UB FUKR7XWswAsgZjX48H+chHGwLYNP06x0sZb/QZ7x9SUqJDAOeelHXhUD0Q1cwpl/JX/F sMW4hXI4SzJjX8doj+43wgEllTLXSJQdKNQlnxIVDklC/hNumA6p1VVNBoVH9ZSwKinG q7xg== 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=Dg+eirxPEtXsZsT+nvxwn7klIpJXP2S7/lYWcLQsq5o=; b=UGP8x64OsjZ9D4dfB2gq5RcucW1Gevg/WDsMN2mYgYwKeB/DFP0nudkLbh1B7fAyeF 0GtBXZYB35R/JHtXYVnVUqRRDxDgEYXCbLV1INJgGxv3AMPzN+ei1F6/Ww6wsQQjg4AD xZRr3020oignDRdCzxdyc7wYBQU1uYySX4AG29ufWz8Xxei9mENQCpZe6FP1mIIfkXuY Djx7JIr/4RouQyWHKy2p6SJP8PsrKu0/myc2TRZ+qdEfHEZIW2NmqWHypUYys6i12mIH GeBw5Xkrkuzcbw710vUzOCVDmcHIpcWMdXClXX1Q4OCLRaVWWJv0WDl6lksrRvllDans Uq6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MPYjmlBA; 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 ho6-20020a1709070e8600b0077afe48c791si15149935ejc.538.2022.10.19.08.13.08; Wed, 19 Oct 2022 08:13:35 -0700 (PDT) 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=MPYjmlBA; 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 S232192AbiJSPHZ (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiJSPFr (ORCPT ); Wed, 19 Oct 2022 11:05:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F823220FF for ; Wed, 19 Oct 2022 07:59:28 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191377; 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=Dg+eirxPEtXsZsT+nvxwn7klIpJXP2S7/lYWcLQsq5o=; b=MPYjmlBAQJxd8Rggng1mxW4di7b7xYOCjLNGRWpjRItXh3zWEx5mIiT5FQKnOr3++nqdFC pe86OdsADSBSH5eHo+UuSujM5JBEBpxz4EqDYayBdbpNcMLU9lC9OlX+CxEuViL3w0XxBH xw8pxjWFvUNr5Edl/oW9ZbygohqM9mxtghTUvuuRVvuUhF+m9H0bWLFljDXTwz8k7NuXOO sCTinHr3ebMbna/ZdTfsspODBgffQYwaNnL2PKRKsQR5J7KHns5Ztl30N8PQHMgTWj18rj 6HnkVcBl5OkAIL3PZyV8kgLNYcAjsfCjNaihlBxF2F8vGFgwMhFh9yuFifCIOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191377; 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=Dg+eirxPEtXsZsT+nvxwn7klIpJXP2S7/lYWcLQsq5o=; b=EtIY4tyi7hLpay8rDK+lcQKRKX8CIAg4otKaMkH3lPH6wnLHsrvZ4XcHsVGirSMNMsusC9 780jjF0WOKRvUkDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 27/38] printk: console_flush_all: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:49 +0206 Message-Id: <20221019145600.1282823-28-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129378045948134?= X-GMAIL-MSGID: =?utf-8?q?1747129378045948134?= Guarantee safe iteration of the console list by using SRCU. Note that in the case of a handover, the SRCU read lock is also released. This is documented in the function description and as comments in the code. It is a bit tricky, but this preserves the lockdep lock ordering for the context handing over the console_lock: console_lock() | mutex_acquire(&console_lock_dep_map) <-- console lock | console_unlock() | console_flush_all() | | srcu_read_lock(&console_srcu) <-- srcu lock | | console_emit_next_record() | | | console_lock_spinning_disable_and_check() | | | | srcu_read_unlock(&console_srcu) <-- srcu unlock | | | | mutex_release(&console_lock_dep_map) <-- console unlock Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7ff2fc75fc3b..c4d5d58b5977 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1851,7 +1851,7 @@ static void console_lock_spinning_enable(void) * * Return: 1 if the lock rights were passed, 0 otherwise. */ -static int console_lock_spinning_disable_and_check(void) +static int console_lock_spinning_disable_and_check(int cookie) { int waiter; @@ -1870,6 +1870,12 @@ static int console_lock_spinning_disable_and_check(void) spin_release(&console_owner_dep_map, _THIS_IP_); + /* + * Preserve lockdep lock ordering. Release the SRCU read lock before + * releasing the console_lock. + */ + console_srcu_read_unlock(cookie); + /* * Hand off console_lock to waiter. The waiter will perform * the up(). After this, the waiter is the console_lock owner. @@ -2353,7 +2359,7 @@ static ssize_t msg_print_ext_body(char *buf, size_t size, char *text, size_t text_len, struct dev_printk_info *dev_info) { return 0; } static void console_lock_spinning_enable(void) { } -static int console_lock_spinning_disable_and_check(void) { return 0; } +static int console_lock_spinning_disable_and_check(int cookie) { return 0; } static void call_console_driver(struct console *con, const char *text, size_t len, char *dropped_text) { @@ -2695,8 +2701,8 @@ static void __console_unlock(void) * DROPPED_TEXT_MAX. Otherwise @dropped_text must be NULL. * * @handover will be set to true if a printk waiter has taken over the - * console_lock, in which case the caller is no longer holding the - * console_lock. Otherwise it is set to false. + * console_lock, in which case the caller is no longer holding both the + * console_lock and the SRCU read lock. Otherwise it is set to false. * * Returns false if the given console has no next record to print, otherwise * true. @@ -2704,7 +2710,7 @@ static void __console_unlock(void) * Requires the console_lock. */ static bool console_emit_next_record(struct console *con, char *text, char *ext_text, - char *dropped_text, bool *handover) + char *dropped_text, bool *handover, int cookie) { static int panic_console_dropped; struct printk_info info; @@ -2764,7 +2770,7 @@ static bool console_emit_next_record(struct console *con, char *text, char *ext_ con->seq++; - *handover = console_lock_spinning_disable_and_check(); + *handover = console_lock_spinning_disable_and_check(cookie); printk_safe_exit_irqrestore(flags); skip: return true; @@ -2801,6 +2807,7 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove bool any_usable = false; struct console *con; bool any_progress; + int cookie; *next_seq = 0; *handover = false; @@ -2808,7 +2815,8 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove do { any_progress = false; - for_each_console(con) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { bool progress; if (!console_is_usable(con)) @@ -2819,12 +2827,17 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove /* Extended consoles do not print "dropped messages". */ progress = console_emit_next_record(con, &text[0], &ext_text[0], NULL, - handover); + handover, cookie); } else { progress = console_emit_next_record(con, &text[0], NULL, &dropped_text[0], - handover); + handover, cookie); } + + /* + * If a handover has occurred, the SRCU read lock + * is already released. + */ if (*handover) return false; @@ -2838,14 +2851,19 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove /* Allow panic_cpu to take over the consoles safely. */ if (abandon_console_lock_in_panic()) - return false; + goto abandon; if (do_cond_resched) cond_resched(); } + console_srcu_read_unlock(cookie); } while (any_progress); return any_usable; + +abandon: + console_srcu_read_unlock(cookie); + return false; } /** From patchwork Wed Oct 19 14:55:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378088wrs; Wed, 19 Oct 2022 08:08:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MroDKbJHDOL9FUb5dgJj3Uvla1a1WzYKkkF3fOUctMANQByaqT4B9eCfIJEGm33xwXq95 X-Received: by 2002:a17:907:980e:b0:78d:b6ea:25b3 with SMTP id ji14-20020a170907980e00b0078db6ea25b3mr7234883ejc.98.1666192106531; Wed, 19 Oct 2022 08:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192106; cv=none; d=google.com; s=arc-20160816; b=RIw3zM3+R7n1xSQdFJzZf3blAE/LJTSMvkE+CZL7vOF5tXf5pv8Buvipo6BqsOcM+Q n+jxsVmUS0qv/3bjRjsw+f9aT8yZWvIb2Bzo2U1GPTXSVo0qUpVjcaG1ROxcA64LxE36 6ETx9QM0IszOOTlkOPUD/iArG77ry36sxiMlDf33v+4Ck6YKUwd6FVW1nCldIeDaqKs5 jrDut52qgj4M/yAJr2IJwsrgWFNqhoo2pA1jbNkIA1opMbY36PCX6lAFU1k/F70l0ncx kz9ga/uRDl8/AckqO7ABUuZvsx9qSGJoo9DmYUeaVyDAe5GN5F3/8N9rvrbG50fYq0Ja lfbA== 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=EqMbZeBSwCTLR7jNGQqhFOnz+Wzb4xZRR+OQHg2ho6o=; b=HAF8oc0qO9RZcVhEt3+E6x0TGZ9l3cvG8nX9Bk8EvLQ7LAsZOR/qYTmQY0qwUUs7Tl lRwqxC3iLV6Co/hJRmHdGLS6iblLZ7GsZpiGYavahlfaB6AckgD0INawDG6yM0joGasX uADoyCdJu82u2maZxyhJVzW+AGCsthJVKRoXWuuhgix5Noq849ZBq1+OatPhqLQZ2IX3 6iTgd4xHgZTeBx3Ek8Eu6nC0JOaSeHYtmAPM+obsvG9E5pBxxt0EWzLZLtLRkMWiw+bc NJTebLrVt/hYsFymrRQo8FCqbnTTrrdsNSfKqK2V0cbNzfF+hy2P320herP1H+jBt+np 72jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lobQdIkS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=hLMMc2Kr; 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 l5-20020a170906794500b0078e1d213831si16645410ejo.122.2022.10.19.08.07.59; Wed, 19 Oct 2022 08:08:26 -0700 (PDT) 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=lobQdIkS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=hLMMc2Kr; 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 S230493AbiJSPFx (ORCPT + 99 others); Wed, 19 Oct 2022 11:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiJSPEm (ORCPT ); Wed, 19 Oct 2022 11:04:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4AED17A00F for ; Wed, 19 Oct 2022 07:59:11 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191377; 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=EqMbZeBSwCTLR7jNGQqhFOnz+Wzb4xZRR+OQHg2ho6o=; b=lobQdIkShxdMxRZEwTiKHKRdYrav0E98bLb9pr2dQOcNULPLucAZSh3RnXK47pdlrnRy7e rKvaMi2imL2d8ki0pJMqOXyRXTfCb+ul8uXBYGuHo7GwL49QRSx2L9VK1XBQJjs6yP2zwb tOnmcTHkIw9Qp1vNXr9lSiMYbFGeETSZwSlVVvooCwWgx2rrd9VrlCjUbcosHABwVQxDAH E71fyzXayt5EED6w2RBkiifmqE+ntg+B5mJ4fxLHsz6pTtFDVtbbKrjvpFfXmyj4++KFLZ y4R29TPq7RP6erhqm2MBnwMRn01T7DiJXs/bj+D5Af6g9rFIHk5t0eTS4nhrww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191377; 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=EqMbZeBSwCTLR7jNGQqhFOnz+Wzb4xZRR+OQHg2ho6o=; b=hLMMc2KrQ3G15NfP/J2YPlS4qSK28nPxhtnXaVM7oNoI0MAE7GvWTiYbgzRVHjyLUFvKEt Lp1mlmci6t0st2CQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 28/38] printk: console_unblank: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:50 +0206 Message-Id: <20221019145600.1282823-29-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129054556300015?= X-GMAIL-MSGID: =?utf-8?q?1747129054556300015?= Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Signed-off-by: John Ogness Reviewed-by: Petr Mladek Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index c4d5d58b5977..0c37ab208395 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2948,10 +2948,14 @@ EXPORT_SYMBOL(console_conditional_schedule); void console_unblank(void) { struct console *c; + int cookie; /* - * console_unblank can no longer be called in interrupt context unless - * oops_in_progress is set to 1.. + * Stop console printing because the unblank() callback may + * assume the console is not within its write() callback. + * + * If @oops_in_progress is set, this may be an atomic context. + * In that case, attempt a trylock as best-effort. */ if (oops_in_progress) { if (down_trylock_console_sem() != 0) @@ -2961,9 +2965,14 @@ void console_unblank(void) console_locked = 1; console_may_schedule = 0; - for_each_console(c) + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (console_is_enabled(c) && c->unblank) c->unblank(); + } + console_srcu_read_unlock(cookie); + console_unlock(); if (!oops_in_progress) From patchwork Wed Oct 19 14:55:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379437wrs; Wed, 19 Oct 2022 08:10:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wSIqE39SPnbdZwEDwuQBlzAgWFweUbAfvVaHwqumYHdXn9oHFCP3AlHSypwFU+ijBZkBH X-Received: by 2002:a17:907:980e:b0:78d:b6d8:f53c with SMTP id ji14-20020a170907980e00b0078db6d8f53cmr7440928ejc.70.1666192251855; Wed, 19 Oct 2022 08:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192251; cv=none; d=google.com; s=arc-20160816; b=N1MmE5/6GOGEHLTSnWX23ZuYcOhQM1Nk+EzxXzBSsFR2rnVthx+ifDM+gmbuX5dmQT htwiSDy7r9XHwA0K15QTHhfVRPl9/oVUB/uURYGrgAIPTsn5L8tMwRooLnTQSAlH1nK6 7kZm0nYbc5hIww1yD3csKj8yOAToJMfYWNvgNiUDmcYw48r1sWboyuoWDUE422tCDqxH ICvxOF0f4mxj+pNrAGPQm09ywKsi0RVtwgsA/osoU0k1nsx8AZE2o7mXc/JNLiTxb7WQ nQ5QLkwaiTJvidndAeMluGkjsDTf0TuR0OArmETdhJSrUMZ1mqvnGdS0Lbmc21FDWuXm h3wA== 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=s9ex8lzRPv2fLvIIrbPhNI07gh3HOaIObjp42xbSQhM=; b=qfjc2xlo8uvgxRaf0ZVNL6OiAvCY4/dJMsTPmexzpb7RosgcBhVyLpT6GgcdUA7fjH APfjEqC5q9/XoAVGezeNfwZqgt9ZH6GHmUMlU1+Dep0A4v/aimk4YYxjDiDgEdY4VsI1 Egmc9knSIXF8uqS38o6oGrMFRhEXEMe9pYrWygaaHw4zspqpL5V01t62p5LdhE3ZmNc2 W0/eNEsRINt1jQuv7H+KSyPhfjjkpiQW64zDiOARulUgmqtF5TZUtRngH24zKULu8OYk DcDS//aflwtV+VwPNsCJlyujOA5yad3kfTHt9vZjI66fz2sJ7eE9i2Nl7KxZQng/nkbO HeMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dV8eeJVk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=3QTHJMOI; 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 nb35-20020a1709071ca300b0078dce6e5cf8si11982320ejc.436.2022.10.19.08.10.21; Wed, 19 Oct 2022 08:10:51 -0700 (PDT) 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=dV8eeJVk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=3QTHJMOI; 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 S231625AbiJSPHN (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231948AbiJSPFr (ORCPT ); Wed, 19 Oct 2022 11:05:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 169E0201AE for ; Wed, 19 Oct 2022 07:59:27 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191377; 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=s9ex8lzRPv2fLvIIrbPhNI07gh3HOaIObjp42xbSQhM=; b=dV8eeJVkJqnYI4Tntl1R3l7jZCsG9aTkqgpLBzaep2kY0IpfWQ7AkgrFxuD0Aa3hlViZnt ZZRK5iRTG84EysIrt3V4DA4GmMpvfrR4x9fqaPMgBv4GmPgnJmb14MJFSFl0uFVMr9q71p oSDQNSWKNoB8WJZ8deTwEu0BfGAlvwRs+SgN/tNjuqT+X5J1YgCdw6HanP40357h5g2B4A 6YNAFBkSg15DyUCvdL3htD/Ho6Tf0MCwFafxoCOOfoRR0aeGRkfoFItU243LcFdgK+9JP1 hERXGmQ7msAr35hPgWEk40C+RcKtWqBob98VeE5EsrIjw0MHnYs/pQEyU7BwPw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191377; 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=s9ex8lzRPv2fLvIIrbPhNI07gh3HOaIObjp42xbSQhM=; b=3QTHJMOIlL3X1RHmjXFjR8ZUj0J6xFSmlHeAL+ESJ8836arfruLwiyCsruxtdvCScpYlAN bsHq2FAjEV58YVCg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 29/38] printk: console_flush_on_panic: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:51 +0206 Message-Id: <20221019145600.1282823-30-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129206665228152?= X-GMAIL-MSGID: =?utf-8?q?1747129206665228152?= With SRCU it is now safe to traverse the console list, even if the console_trylock() failed. However, overwriting console->seq when console_trylock() failed is still an issue. Switch to SRCU iteration and document remaining issue with console->seq. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 0c37ab208395..e478cb92e7ba 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2998,21 +2998,22 @@ void console_flush_on_panic(enum con_flush_mode mode) console_may_schedule = 0; if (mode == CONSOLE_REPLAY_ALL) { - struct hlist_node *tmp; struct console *c; + int cookie; u64 seq; seq = prb_first_valid_seq(prb); - /* - * This cannot use for_each_console() because it's not established - * that the current context has console locked and neither there is - * a guarantee that there is no concurrency in that case. - * - * Open code it for documentation purposes and pretend that - * it works. - */ - hlist_for_each_entry_safe(c, tmp, &console_list, node) + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { + /* + * If the above console_trylock() failed, this is an + * unsynchronized assignment. But in that case, the + * kernel is in "hope and pray" mode anyway. + */ c->seq = seq; + } + console_srcu_read_unlock(cookie); } console_unlock(); } From patchwork Wed Oct 19 14:55:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379208wrs; Wed, 19 Oct 2022 08:10:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I3l7tejRpgd3AuLzJVvrWUESgeTnL5dad374eza0+I1APSkFmCvYKN5C3tl16Qw5bvNd9 X-Received: by 2002:a05:6402:40c4:b0:45c:c718:54d1 with SMTP id z4-20020a05640240c400b0045cc71854d1mr7960568edb.319.1666192229826; Wed, 19 Oct 2022 08:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192229; cv=none; d=google.com; s=arc-20160816; b=Qav4jNVvJGkaDRc/gBGTMVMyWubVPyflnCgaIecJw3KhLK1zSB3opjD8gtQ5hx4LhL c2HsfLMND7Ozdig0YQl+5+GCO7yJB3pcG9XkpmN1rbgLsQup63a1ZiSfgX1SJhJAhxm9 3SWCJ3o/LOh5Ys7aQ6CDkcu7FT3hvROJ/ulcS4X5XlAFKbYsfZ8mlI+WsTCybB7BROmV Raj667LYsvt//OoLq0QLROBcQ7D9Sbd+12KjLNYtLr2zGNaoWB5HvZIkGW0YUkAsXfKh KvgXO9Dx+kCX/Q/8hdYqJQa2q98zENMIJnz/8DHIMxNYvglG+JLU/bEV2qY08tTBWiiy zCJg== 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=IblqMgAHge4oNGFouCeyG5+rIv/XWIio7AfxcMZprD41/FXLRhSyrf90Brqwya58Gf Iqy4v3+P1vVHNVDkOGriCf46O8dwBYfbKonS+Lm0cx9dyt/7nLspwKFpSWkghZg/WVxC mJgJDwJv7a2j4vqPNeV2OGdgxfyAYE+fw7mqesvBzMwB8EBCTHBZJ7lyGrs4b3M1XHlU HrWGBTQ1e4PlfEuA5AUe649F3jWVpT3v6rR+Aq6wxt3RpbmyfdCwMMB+v0+VhvzryIqY wegQRKkjEX7+/LcPsa9eVBdj+DJBLpu8ezhE5gBHBcDsn0VKX7UMGJUwqFKaPYHhlz9f lakQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vZ++W4VE; dkim=neutral (no key) header.i=@linutronix.de header.b=zlEFWao8; 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 hg6-20020a1709072cc600b00791a41d1b39si3160435ejc.656.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:29 -0700 (PDT) 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=vZ++W4VE; dkim=neutral (no key) header.i=@linutronix.de header.b=zlEFWao8; 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 S232000AbiJSPGM (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbiJSPF0 (ORCPT ); Wed, 19 Oct 2022 11:05:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98472153835 for ; Wed, 19 Oct 2022 07:59:11 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191378; 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=vZ++W4VE4AQQNPASVoIgQEv9QFic6MvrPxW9APkzUtJQWlJmpTRafFJlXDcuEug7iTrgAr Q68gq3cOHoYxad58FRzrhkyde3adxE+hwep+0uWLN2/qDedGH7Q7xx1AmRkMh/mK0VoNFv nMsU91BskHVFEannoZwBQZA7Z1nTnh3feCTKpKo/0ocU/OTDbu3KpsM2BSapW5B13XOBk4 XEBAiQvwiu+9W09sKCUpa/szF8Xe08dS43bdhg5WwWcE38dtMvjprltTZX5kT84uDgwvUo ks5/LYqdhSVgBppHnyQB/LpicRRiUXa15t6U5CopyRfzugDG8cvli1d2t8CL9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191378; 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=zlEFWao8VJz19cq1+qrdLmGFpWXLPFk4nyCnR24oE/kjsnhlT2viimgpJo1H5sm4DIHUYs PFn0fdw64FnnTOBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 30/38] printk: console_device: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:52 +0206 Message-Id: <20221019145600.1282823-31-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129183622784547?= X-GMAIL-MSGID: =?utf-8?q?1747129183622784547?= Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Signed-off-by: John Ogness --- kernel/printk/printk.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e478cb92e7ba..410ad9d5649c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3025,15 +3025,24 @@ struct tty_driver *console_device(int *index) { struct console *c; struct tty_driver *driver = NULL; + int cookie; + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ console_lock(); - for_each_console(c) { + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (!c->device) continue; driver = c->device(c, index); if (driver) break; } + console_srcu_read_unlock(cookie); + console_unlock(); return driver; } From patchwork Wed Oct 19 14:55:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp380907wrs; Wed, 19 Oct 2022 08:13:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76r26HsFFBJrgZVzCsHtFuajAI0MUFcbFc6Y2Wczc9vAbUg2rBUrxMdvPgtM7g5XswM27k X-Received: by 2002:a17:907:608f:b0:78e:1b60:60e2 with SMTP id ht15-20020a170907608f00b0078e1b6060e2mr7241542ejc.382.1666192416847; Wed, 19 Oct 2022 08:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192416; cv=none; d=google.com; s=arc-20160816; b=NaZ8iWcMYT+B6CXlsRPwiH8fLWmWJSaCw77Z+oYOWVcEUvD3ptPT4y0ut7R6BgdHzY a5NFzvKSOFhvU3uEJjKD1Ob1FBirjfiSEOnjUGPhALcnKa86PBhYKCcYDzsFECkY9LTU G/7mHRhLc3X+vsZs4epnyRbbM55iABuxhDQ7NjrXssjCYsZAEyLMwFKaL08QEXoEphvs KYcavtq/Vg+iBTYZfhDIsMBoKY6YpiPk45fEhIIIZV+sg6xMwvYWQI9sGNlof2IsJXqD JO+zF5Wa7DMVToerXFttfb4B9bbqIoHTKqzHRnrF6UFVzsXZTTuodDAIJ79IvLrv+9VS 3cKg== 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=f12nNYu1o1nheACyaBAz3IPbjPiOwdCr955JKGftNi0=; b=OVIvGhAy2uiqOVJXj+fVSHQORqEyF/3DyOkrpugn0Zckg0OsUpMpnJwspZwGytw9uo oeG7L7Qqoq6313VZB2aSsvqbJz4YiG8uU/B/c426NKqf7j0+ShW4A2SXbo9xdTD3i4Zs 0s9PuwUNG6YdjE9pVNYO0QoyKYNkjFiRUiDJC0FMzvWizeS5gKk57gFtkHAtM6Q/dnlw iNsMUzy4EUGkRPQN3FUu14QKmdtgPFSwdbUQ9RWf0Db23ZVU76XEFh3Zj4kNRwVsL7As U/aW6Kn3YPBawChsUPZ0ei7IbVrFk0cROEjnryQIl1ZwUIRysANiGSKioS46sdgyYUej WoPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="gEk/56dy"; 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 gs19-20020a1709072d1300b00783d5a93880si14237860ejc.503.2022.10.19.08.13.08; Wed, 19 Oct 2022 08:13:36 -0700 (PDT) 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="gEk/56dy"; 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 S232209AbiJSPHc (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbiJSPFs (ORCPT ); Wed, 19 Oct 2022 11:05:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAA2205CC for ; Wed, 19 Oct 2022 07:59:28 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191378; 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=f12nNYu1o1nheACyaBAz3IPbjPiOwdCr955JKGftNi0=; b=gEk/56dyVdJxDt/J7kVgFStcKjvZrGcgIOwQYk0XwQKdK8FsV0Y9dvc9y2PrxlYjtuLQT3 fSJL3lf/BuDtIhc+l6cIXdtEsuXqSJu6EpaxJSdLt15yliOrYrRp1+h7ASkvcNnkIleiOK WZ+Tm++vLlUFSJX9OqsxsxRrd4s4tFKvj3VUqZdNFTfb3Xhi8xUPk8f1Hr6A5xGkJiRoR+ A2sCQpxxeuWpEagnAVMwC/rga5HRcHoOkPCaPZzrNI1r1Nzz5TeNQX3rrKHlEpNHJHjOfV JKp1j4/HoOOs0hPNpCf8W0nyoa5ouc48VUQum9WrHC4viYimonEL+j+iP2L95A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191378; 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=f12nNYu1o1nheACyaBAz3IPbjPiOwdCr955JKGftNi0=; b=Hy5IF74AngV6AgkVUBSfbWawZSbLHUumgqjJi1aW8Es4tyHbxXvp1fWUJHJOyfgmdOtGqL +/HMreGlQbQCBDAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 31/38] printk: register_console: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:53 +0206 Message-Id: <20221019145600.1282823-32-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129380124459195?= X-GMAIL-MSGID: =?utf-8?q?1747129380124459195?= Use srcu console list iteration for console list traversal. Now the traversal at the beginning of register_console() is safe. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 410ad9d5649c..809c43e596d8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3188,20 +3188,23 @@ void register_console(struct console *newcon) struct console *con; bool bootcon_enabled = false; bool realcon_enabled = false; + int cookie; int err; - for_each_console(con) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { if (WARN(con == newcon, "console '%s%d' already registered\n", - con->name, con->index)) + con->name, con->index)) { + console_srcu_read_unlock(cookie); return; - } + } - for_each_console(con) { if (con->flags & CON_BOOT) bootcon_enabled = true; else realcon_enabled = true; } + console_srcu_read_unlock(cookie); /* Do not register boot consoles when there already is a real one. */ if (newcon->flags & CON_BOOT && realcon_enabled) { From patchwork Wed Oct 19 14:55:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379814wrs; Wed, 19 Oct 2022 08:11:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67rDpDTnxhHPe8V1VZqoEi/tQupptKGz34r7vExRUy/u08HttyjslfLQkSOIj6iMffPPcl X-Received: by 2002:a17:907:7635:b0:78d:c5e9:3e57 with SMTP id jy21-20020a170907763500b0078dc5e93e57mr7278222ejc.204.1666192299030; Wed, 19 Oct 2022 08:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192299; cv=none; d=google.com; s=arc-20160816; b=Ay+iE/l0QWTcEmyGP2EYmlBUtb3QdmP8ik4yYMvmV0EEyIIPW10/3JfMBfmOcZT72g oKXrVuetB+Hk3RIfaLd+7vIv6eDUzQZT8E53o4QUg1dNq+GHKg0WO2ms3KuJ+umvRQyQ e1tUY8GDPigOekuUZKBOjj0pJYUXB7AilGeFzmUy4x3CmklYkMQbYVAbjP4umjEbIJA9 WJSnn+L2IE1lQ+hTw0RN0kaWnkWVDiJNB8hGf18Gei2IhjMdXr4Avg49brI7L0knsT2Z aCQ9gCs8jkyGqg9x/EC0dg5yisr6jgIOBzxg5ueMBe5Fb2ptuDNi/y5AGM23tROMuKSP ivng== 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=dEfLDywQMbLFMveMIU5ztmggdkM8VKhqRGZUba4knEA=; b=pXnWDq3zOrbn7lyn8TYXiPj9PWaIUFwjbBsq3BiSpJK430xvHJa+4XH4nD6vHfC/VZ hmTAVSrjd36cgfKtRaEy/ML2ORExh0qC+4lGa7z8+HohtN6CQBZK8TjCgPrZupCpdHBt PRWuP2OtIfXvEeOcie8IKHVzb+0WBjQeI4m/2Nztbvu8iKdUAlnYtf6rrQuAsNh5L7T0 r8Zrlz1+tbtdwyeQvyY/exn+qKlW7L6NrNitFv0bPB5ZOkShJlNJb/fK9ekuNWMofs9t FFWEUj4ZDlQLtnxg4MWcFbRQ3Jca9tUh35bQc3wiN3PFJkfyc7RC5J9kDe9EX0ug8XiL ZHdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tvGWDuIb; dkim=neutral (no key) header.i=@linutronix.de header.b=zJjK8oc9; 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 e11-20020a056402104b00b004587cd5a5bdsi12978648edu.81.2022.10.19.08.11.12; Wed, 19 Oct 2022 08:11:39 -0700 (PDT) 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=tvGWDuIb; dkim=neutral (no key) header.i=@linutronix.de header.b=zJjK8oc9; 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 S231775AbiJSPGZ (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbiJSPFj (ORCPT ); Wed, 19 Oct 2022 11:05:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9676F1C2EB3 for ; Wed, 19 Oct 2022 07:59:12 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191379; 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=dEfLDywQMbLFMveMIU5ztmggdkM8VKhqRGZUba4knEA=; b=tvGWDuIbnMg81nElIpNQcHDQap243WbjOFmLBBssheT3WAcSo/uy+6Y/V1xLaZOuvbqvoP HGWUcc6muabTL3JhrtCL2O+nHHlD1uN8YVPQtxkig8QS8ESpv/V3WRMZA7Rxl4IIndi7hD szwUUd+8jDai9nm38yOHM416UH1skAKg+0nBI9frWXFXAUAQs4OkB5nXnBEBkEVbgTC1Rk qZ92WfVER0K26YNlgAgm71hLsBMCs+JmDbBTQmx0vFv52LhECZBDo3JbTp3eTUIpFu0dzy 5cZYtV6xxBzm2eo129s+wAAZgFZr0dg9IA7FHp+XlWd3FtdHSpugj1GkLYE18g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191379; 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=dEfLDywQMbLFMveMIU5ztmggdkM8VKhqRGZUba4knEA=; b=zJjK8oc9MpyW+AN+CgjCFO34fO7H6UGzAb1JPwNkz17MJ2pO3wmfGFId0+ak7aOpZp8Q+5 uWrTfF0L395aPXBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 32/38] printk: __pr_flush: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:54 +0206 Message-Id: <20221019145600.1282823-33-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129256312228335?= X-GMAIL-MSGID: =?utf-8?q?1747129256312228335?= Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 809c43e596d8..2faa6e3e2fb8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3454,6 +3454,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre struct console *c; u64 last_diff = 0; u64 printk_seq; + int cookie; u64 diff; u64 seq; @@ -3464,9 +3465,15 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre for (;;) { diff = 0; + /* + * Hold the console_lock to guarantee safe access to + * console->seq and to prevent changes to @console_suspended + * until all consoles have been processed. + */ console_lock(); - for_each_console(c) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (con && con != c) continue; if (!console_is_usable(c)) @@ -3475,6 +3482,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre if (printk_seq < seq) diff += seq - printk_seq; } + console_srcu_read_unlock(cookie); /* * If consoles are suspended, it cannot be expected that they From patchwork Wed Oct 19 14:55:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379460wrs; Wed, 19 Oct 2022 08:10:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bme5J1XgtvcdOC10NxOA0mQdiawElb92R7PSOeSTqFNPYcaRac/DUS1DXvjsU9Wmtt1GN X-Received: by 2002:a17:907:3e06:b0:733:693:600e with SMTP id hp6-20020a1709073e0600b007330693600emr6924831ejc.410.1666192255466; Wed, 19 Oct 2022 08:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192255; cv=none; d=google.com; s=arc-20160816; b=FRygk/PipRSV40n1TqTriXrb7ZgCpmcpIkNZblrSK/Fi0yVvC/wX6tWsehXHKuykKE g87XrymFwKEG0qtARfh4znA/BJXOaI/15XhYGSfoP1nu3CDMWfbewsH1Z59YZK5AdTxn UQ1bXqvKNflcn5+e634XSwBAJy/EgSjoNhLWcgO9V29p0R7bAZTZ7Q4uDf9aa4JNHTQ+ y5yzE9dYR0sn/fzo0islsk805xQxsVHyOrvPf1sEWLd/xTMlDQ7SjFyZ2X3UvlKVDO0X xAScRxYcxIDUB0Rcee4x0DB4w47+asMDY9GbJValMkMxnmaLux9TBzLwNjHWDXjSoPqt BKpw== 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=BcRSHDvvNo4h9AdyzONtntflPRCM65zBDjJsA3cL8rk=; b=ECYmzND86+Cpq6OoWFH9IeSXulEcvnlmS/qvVsSJunisqwFZaL6+OIJ4lBtM/yehHI kv/hVP7O5mw1zepz7CxipACyOj/9sxDsnVvp1xknmAtT+/PAHp0SiVPaHHJrHEuWsfcO 7zwVXskFwxvSnsdqFgfeksNrtxxdij2Sbg6+AOwFZwEtHT5dB+UUtdl2lsCFEPwAyZDp dkMcu67rRv46VEQanwu8YOugM/ZWZ8DsTxaQVPwfYrLN5CKwH2KRcaWw0fpW1r1wN/NY 4os0b8EhxiDv8qYJlKR1tky00jzXBZAHT+I4qN29gZZENJMunr0m3ofbaAA0gd1aNMfZ 3I3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3AWz2y6+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=InuA5nej; 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 i20-20020a05640242d400b0045c93142111si18684563edc.70.2022.10.19.08.10.27; Wed, 19 Oct 2022 08:10:55 -0700 (PDT) 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=3AWz2y6+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=InuA5nej; 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 S231948AbiJSPHU (ORCPT + 99 others); Wed, 19 Oct 2022 11:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbiJSPFr (ORCPT ); Wed, 19 Oct 2022 11:05:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 259E42FFFA for ; Wed, 19 Oct 2022 07:59:28 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191379; 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=BcRSHDvvNo4h9AdyzONtntflPRCM65zBDjJsA3cL8rk=; b=3AWz2y6+1k39Qj6Orp5DwOJpZBtwPBMP63eraBDBEEUg437H+y+VYXgKoH9orU/SwQDGLU 06R/Lg+9+gV+G6DSMSlPyThKh8IWtZh/b43yUs60YI9x5Aq/QYZPclNqeSYqa8O2qovVRV 7/gu1pKhqmDsprIbI1+hsU5FoG0FOfzUURCDxKiHetLklfjLBP1LTxW2WvhJ9z4+zKWji3 tgjKytTz6ySvnqr15SPuktV4b5GI7pZo1dPB6vCZKbgEqk5+IaFkLzfG/AW5UjO0AD6gSi 5mb9w4Tsxx5XDz0L3BY0zgVL5qerQDYGxg22CjiNbu4slbsmj1kKOPNkR1S2lA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191379; 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=BcRSHDvvNo4h9AdyzONtntflPRCM65zBDjJsA3cL8rk=; b=InuA5nejuGJ/h2WMXNzVlmQY/B0egmLyfHHBCPaaVQ1w3jLH75R9dCp2uDasRu0WaqbXca /BZkfNms60ta+KBA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 33/38] printk: introduce console_list_lock Date: Wed, 19 Oct 2022 17:01:55 +0206 Message-Id: <20221019145600.1282823-34-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129210173930066?= X-GMAIL-MSGID: =?utf-8?q?1747129210173930066?= Currently there exist races in console_register(), where the types of registered consoles are checked (without holding the console_lock) and then after acquiring the console_lock, it is assumed that the list has not changed. Also, some code that performs console_unregister() make similar assumptions. Introduce a console_list_lock to provide full synchronization for any console list changes. The console_list_lock also provides synchronization for updates to console->flags. Note that one of the various responsibilities of the console_lock is also intended to provide this synchronization. Later changes will update call sites relying on the console_lock for this purpose. Once all call sites have been updated, the console_lock will be relieved of synchronizing console_list and console->flags updates. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek Signed-off-by: John Ogness --- include/linux/console.h | 20 ++++++++-- kernel/printk/printk.c | 82 +++++++++++++++++++++++++++++++++++------ 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 60195cd086dc..bf1e8136424a 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -159,8 +159,12 @@ struct console { }; #ifdef CONFIG_LOCKDEP +extern void lockdep_assert_console_list_lock_held(void); extern bool console_srcu_read_lock_is_held(void); #else +static inline void lockdep_assert_console_list_lock_held(void) +{ +} static inline bool console_srcu_read_lock_is_held(void) { return 1; @@ -170,6 +174,9 @@ static inline bool console_srcu_read_lock_is_held(void) extern int console_srcu_read_lock(void); extern void console_srcu_read_unlock(int cookie); +extern void console_list_lock(void) __acquires(console_mutex); +extern void console_list_unlock(void) __releases(console_mutex); + extern struct hlist_head console_list; /** @@ -206,10 +213,17 @@ static inline bool console_is_enabled(const struct console *con) hlist_for_each_entry_srcu(con, &console_list, node, \ console_srcu_read_lock_is_held()) -/* - * for_each_console() allows you to iterate on each console +/** + * for_each_console() - Iterator over registered consoles + * @con: struct console pointer used as loop cursor + * + * The console list and all struct console fields are immutable while + * iterating. + * + * Requires console_list_lock to be held. */ -#define for_each_console(con) \ +#define for_each_console(con) \ + lockdep_assert_console_list_lock_held(); \ hlist_for_each_entry(con, &console_list, node) extern int console_set_on_cmdline; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 2faa6e3e2fb8..3615ee6d68fd 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -78,6 +78,9 @@ EXPORT_SYMBOL(ignore_console_lock_warning); int oops_in_progress; EXPORT_SYMBOL(oops_in_progress); +/* console_mutex protects console_list and console->flags updates. */ +static DEFINE_MUTEX(console_mutex); + /* * console_sem protects console_list and console->flags updates, and also * provides serialization for access to the entire console driver system. @@ -104,6 +107,11 @@ static struct lockdep_map console_lock_dep_map = { .name = "console_lock" }; +void lockdep_assert_console_list_lock_held(void) +{ + lockdep_assert_held(&console_mutex); +} + bool console_srcu_read_lock_is_held(void) { return srcu_read_lock_held(&console_srcu); @@ -225,6 +233,40 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, } #endif /* CONFIG_PRINTK && CONFIG_SYSCTL */ +/** + * console_list_lock - Lock the console list + * + * For console list or console->flags updates + */ +void console_list_lock(void) +{ +#ifdef CONFIG_DEBUG_LOCK_ALLOC + /* + * In unregister_console(), synchronize_srcu() is called with the + * console_list_lock held. Therefore it is not allowed that the + * console_list_lock is taken with the srcu_lock held. + * + * Whether or not this context is in the read-side critical section + * can only be detected if the appropriate debug options are enabled. + */ + WARN_ON_ONCE(debug_lockdep_rcu_enabled() && + srcu_read_lock_held(&console_srcu)); +#endif + mutex_lock(&console_mutex); +} +EXPORT_SYMBOL(console_list_lock); + +/** + * console_list_unlock - Unlock the console list + * + * Counterpart to console_list_lock() + */ +void console_list_unlock(void) +{ + mutex_unlock(&console_mutex); +} +EXPORT_SYMBOL(console_list_unlock); + /** * console_srcu_read_lock - Register a new reader for the * SRCU-protected console list @@ -3055,9 +3097,11 @@ struct tty_driver *console_device(int *index) void console_stop(struct console *console) { __pr_flush(console, 1000, true); + console_list_lock(); console_lock(); console->flags &= ~CON_ENABLED; console_unlock(); + console_list_unlock(); /* Ensure that all SRCU list walks have completed */ synchronize_srcu(&console_srcu); @@ -3066,9 +3110,11 @@ EXPORT_SYMBOL(console_stop); void console_start(struct console *console) { + console_list_lock(); console_lock(); console->flags |= CON_ENABLED; console_unlock(); + console_list_unlock(); __pr_flush(console, 1000, true); } EXPORT_SYMBOL(console_start); @@ -3164,6 +3210,8 @@ static void try_enable_default_console(struct console *newcon) #define console_first() \ hlist_entry(console_list.first, struct console, node) +static int unregister_console_locked(struct console *console); + /* * The console driver calls this routine during kernel initialization * to register the console printing procedure with printk() and to @@ -3188,15 +3236,14 @@ void register_console(struct console *newcon) struct console *con; bool bootcon_enabled = false; bool realcon_enabled = false; - int cookie; int err; - cookie = console_srcu_read_lock(); - for_each_console_srcu(con) { + console_list_lock(); + + for_each_console(con) { if (WARN(con == newcon, "console '%s%d' already registered\n", con->name, con->index)) { - console_srcu_read_unlock(cookie); - return; + goto unlock; } if (con->flags & CON_BOOT) @@ -3204,13 +3251,12 @@ void register_console(struct console *newcon) else realcon_enabled = true; } - console_srcu_read_unlock(cookie); /* Do not register boot consoles when there already is a real one. */ if (newcon->flags & CON_BOOT && realcon_enabled) { pr_info("Too late to register bootconsole %s%d\n", newcon->name, newcon->index); - return; + goto unlock; } /* @@ -3241,7 +3287,7 @@ void register_console(struct console *newcon) /* printk() messages are not printed to the Braille console. */ if (err || newcon->flags & CON_BRL) - return; + goto unlock; /* * If we have a bootconsole, and are switching to a real console, @@ -3304,13 +3350,15 @@ void register_console(struct console *newcon) hlist_for_each_entry_safe(con, tmp, &console_list, node) { if (con->flags & CON_BOOT) - unregister_console(con); + unregister_console_locked(con); } } +unlock: + console_list_unlock(); } EXPORT_SYMBOL(register_console); -int unregister_console(struct console *console) +static int unregister_console_locked(struct console *console) { int res; @@ -3362,6 +3410,16 @@ int unregister_console(struct console *console) console_unlock(); return res; } + +int unregister_console(struct console *console) +{ + int res; + + console_list_lock(); + res = unregister_console_locked(console); + console_list_unlock(); + return res; +} EXPORT_SYMBOL(unregister_console); /* @@ -3414,6 +3472,7 @@ static int __init printk_late_init(void) struct console *con; int ret; + console_list_lock(); hlist_for_each_entry_safe(con, tmp, &console_list, node) { if (!(con->flags & CON_BOOT)) continue; @@ -3431,9 +3490,10 @@ static int __init printk_late_init(void) */ pr_warn("bootconsole [%s%d] uses init memory and must be disabled even before the real one is ready\n", con->name, con->index); - unregister_console(con); + unregister_console_locked(con); } } + console_list_unlock(); ret = cpuhp_setup_state_nocalls(CPUHP_PRINTK_DEAD, "printk:dead", NULL, console_cpu_notify); From patchwork Wed Oct 19 14:55:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379785wrs; Wed, 19 Oct 2022 08:11:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GyJH97zYH22nZJhku+yuoqb+FIP4r14+6Z6jQ4x4UP3Tu9ljDmV/S7EZfEFFPVcQzgmsw X-Received: by 2002:a05:6402:847:b0:45c:c716:4b76 with SMTP id b7-20020a056402084700b0045cc7164b76mr8015055edz.113.1666192285090; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192285; cv=none; d=google.com; s=arc-20160816; b=BY/poUL/jkqhaKH7eRdUPruAD3y+7VmVMOHgk5InQ2nt/NrtGFSVA8jgPgCPjCsRW2 LzTrJi/1XgtHb3U81xCiWpjoi6fZuD1A0GBkcII13v51q0wK0kekn/GcspzEAjAwAt3j JscfTz3m7kfRwNtjZBkuOpo0u5cPw1KQYiZXXyqmcaR7qpUuvM+FoB/G8JxgiBYLQ352 1u570VU+NgJTSgJLn+WraVu9RkvyqPg1a6g6Nrvk4qbfUWJ27wBkoA5WfDOi5C5+yRHg SC1EW7UPkk4Xz8MF0zfG/IcZ8iw8DT8AhMimDQF/bC4Z+T6WYNORmq6ZGTs1ZDInU5xq HknQ== 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=FdvxHOKwRIeI8BiM8k+rYwU/Yx30rZAhLXmKb87AiP8=; b=BFbTDFEVCNW95WQBtmN6S5VtKYZuOpopS6DceIv4QIY/ogmR4flZpyUZK9U4YlMYH5 0dRNG60H4KKSbptx3lHwHTfRhUPSSJysVvaAPWVnysW4oaYNdbd3jfOpN7GOJF8HqSmz LFGBQR/4BZdev3OPIiO9VDICEYXOvH2F18eoNZy1PaLd+xZ+WV5AdaB1x2zjErYEN2lK KKn8+OYxysAu0ri32V5X39DH3k1G4NqzRM10iWo+Ftl9z9CJK6Oxycl0hmucO/xrkhYO mIAr9Q6YBZ737YzAKIFul9AYSL+GDp2Y2QU13ZDRNMt7G9eqSN9VcPe17F13WhGE3Ej/ Q3Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="YJM/Q8Y/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8EnO9qCl; 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 ne6-20020a1709077b8600b007832270e889si13169350ejc.90.2022.10.19.08.10.59; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) 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="YJM/Q8Y/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8EnO9qCl; 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 S230285AbiJSPGb (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231172AbiJSPFj (ORCPT ); Wed, 19 Oct 2022 11:05:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09281125015; Wed, 19 Oct 2022 07:59:13 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191380; 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=FdvxHOKwRIeI8BiM8k+rYwU/Yx30rZAhLXmKb87AiP8=; b=YJM/Q8Y/iU41nYJhp3ruJ3GZbQPygcVKdQtdGfYKzTF62VPMx1mnPM9tcgyukJ54yaBxZA GVrkuBdRj36R50zyHRbByxcwzeIkJ2CitT346w2Db5zH5yWwwEieG+szD/pwmPecMyCI1h 0OEDEw9VNJtjb26YQe62EHk5Rwz/lbk5LQrNjCrzvDvUiIssEVgWHSJaoJO/87vO/A/kOf XaEI1oeCR6s/TkWDLLjt70+k/1a69wPsRy2nuUIWcbB/Vtekle1QbRVEcd04sjNyqVuA0D 1WVA1iDuqI9sMaCvV7EaPS+iAWUQOLFn2okif3uEEF9aGgVMzxDui9lC/dsqAA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191380; 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=FdvxHOKwRIeI8BiM8k+rYwU/Yx30rZAhLXmKb87AiP8=; b=8EnO9qClCf1jaZEbNBimixqghlBQ62awKnPSz1PmBmcugCl3Z+v0WMz2rs+IIgPUeCv/Ol Snw30DIMiYbGmfDw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk v2 34/38] serial: kgdboc: use console_list_lock instead of console_lock Date: Wed, 19 Oct 2022 17:01:56 +0206 Message-Id: <20221019145600.1282823-35-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129241524058360?= X-GMAIL-MSGID: =?utf-8?q?1747129241524058360?= kgdboc_earlycon_init() uses the console_lock to ensure that no consoles are unregistered until the kgdboc_earlycon is setup. The console_list_lock should be used instead because list synchronization repsponsibility will be removed from the console_lock in a later change. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/serial/kgdboc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 48000666789a..0d85596aebe2 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -547,13 +547,13 @@ static int __init kgdboc_earlycon_init(char *opt) */ /* - * Hold the console_lock to guarantee that no consoles are + * Hold the console_list_lock to guarantee that no consoles are * unregistered until the kgdboc_earlycon setup is complete. * Trapping the exit() callback relies on exit() not being * called until the trap is setup. This also allows safe * traversal of the console list. */ - console_lock(); + console_list_lock(); for_each_console(con) { if (con->write && con->read && (console_is_enabled(con) || (con->flags & CON_BOOT)) && @@ -595,7 +595,7 @@ static int __init kgdboc_earlycon_init(char *opt) } unlock: - console_unlock(); + console_list_unlock(); /* Non-zero means malformed option so we always return zero */ return 0; From patchwork Wed Oct 19 14:55:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379187wrs; Wed, 19 Oct 2022 08:10:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/U9FBkbXmHPsov2EbGu92ZMlvGZp/2W1RsvxaCgFMw9YC+wiGhWzdAdGzL83pXlHJY8Uv X-Received: by 2002:a17:907:628a:b0:781:bbff:1d42 with SMTP id nd10-20020a170907628a00b00781bbff1d42mr6976224ejc.375.1666192227934; Wed, 19 Oct 2022 08:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192227; cv=none; d=google.com; s=arc-20160816; b=hZ528hdeTHG/yOmN+kEd/lbd36T5k4oRBf0Oj/8qlNCzApbK5lwofwicRqqB0uTeBm 4T4hl714Fcgw7GCxbo6WsGAH6y8moGFYeEdy6wkWXKqIRJ5BO7J1nMnVBnX/TJdszFtq G5B0VFunraxFmAiaotSUUwNKIkUdIeP+eHOA2ZbuQ77bp3GG76q8boPx5QX65RlbUyND 04UmLWBQQ6m1thZiQs3m/pcU+115E/xAzNXD8YgH2gV3AsqUiI/WTfdPN8lRnP3zjqmU FOkac240ZjEkJAdHIqvm+QyPBaToPmEtlDFlphWMqQ2WSvtEntXhJb78OTM4kO32KM72 J2KQ== 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=4O5jxh5GAGfpdp5oJs484DSsKK6l20yyCIa5aoPwGXk=; b=PYZGNX0B72qQutyO9UY39PRXRZdXjB3XAL7RhkRrLKcSg9aBuC9Fa2KMmFHdslmc0B p2pHH0p5j7cWWKxdqFBCKxXixHjQWhwVVKQWto688zFXO0ATEW5L58oll60FrLp9XEtM y7HCB1XDQ9JCjR2JOcCJoBEPJwnJ791eB55mg3hHd1yMuZej6pLQtVr3wlTTjykxqktQ JDOSX1ectGg2JCeFHgAwpWTbvuaT6pSJUqml98qO9eGMMyRVZ7/k9R0cy1v7HYZ39A6b lv4cdtnnrL3TTnmvlCIuyQBcnJ1FO71hsX4D4O+5q32+yI1yneD3/PD/wgZwD0AaxmJr urDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iTFnKkvn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Fu+pjLGg; 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 gt31-20020a1709072d9f00b0078debc9d30fsi17682204ejc.45.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:27 -0700 (PDT) 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=iTFnKkvn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Fu+pjLGg; 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 S232087AbiJSPGr (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbiJSPFk (ORCPT ); Wed, 19 Oct 2022 11:05:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBC729359 for ; Wed, 19 Oct 2022 07:59:16 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191380; 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=4O5jxh5GAGfpdp5oJs484DSsKK6l20yyCIa5aoPwGXk=; b=iTFnKkvnbpZV48iaml8m+GkgSuO5UhuOPyuwAZtb2zPnRQi7Q9F4bM6+9lA4A7g8iLXRPd YskL9UUUkyQiWaD7JtvivltiLNH8BP8o6m91bP4hX2T8rN8aIfG2pRKSjDnwavHqzgJPPV nrYAxW/rTJ6goH7HYUGv9GT708RbC4YLBn8W9dJ8z3JyuVftTLtv+1ZS/5rmxKUb9ktAUm BgVLY8s9nkfmIpUG/QSKgxDcIcLYqhI4RlNOE8A1GA41IpZ+VNXZl9Gg4FBPnbWvrjYEqb U0yyXtmvo+SVOmto2TaiY3F5ePVRNqLXYpMZ3YduuR2WllgLWVcBt1SII0WNoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191380; 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=4O5jxh5GAGfpdp5oJs484DSsKK6l20yyCIa5aoPwGXk=; b=Fu+pjLGgV9HHXN5WM5d4ymQB19nzJZDTwV/1OFZhHc0jWJPZqGp6+7wJwb+s9hVvpKQ2+6 kYID/meOJJNW9SAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH printk v2 35/38] tty: tty_io: use console_list_lock for list synchronization Date: Wed, 19 Oct 2022 17:01:57 +0206 Message-Id: <20221019145600.1282823-36-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129181933947685?= X-GMAIL-MSGID: =?utf-8?q?1747129181933947685?= show_cons_active() uses the console_lock to gather information on registered consoles. It requires that no consoles are unregistered until it is finished. The console_list_lock should be used because list synchronization repsponsibility will be removed from the console_lock in a later change. Note, the console_lock is still needed to stop console printing. Signed-off-by: John Ogness Reviewed-by: Greg Kroah-Hartman Reviewed-by: Petr Mladek --- drivers/tty/tty_io.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 333579bfa335..46a0e3c5c3a5 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3527,14 +3527,12 @@ static ssize_t show_cons_active(struct device *dev, ssize_t count = 0; /* - * Hold the console_lock to guarantee that no consoles are + * Hold the console_list_lock to guarantee that no consoles are * unregistered until all console processing is complete. * This also allows safe traversal of the console list. - * - * Stop console printing because the device() callback may - * assume the console is not within its write() callback. */ - console_lock(); + console_list_lock(); + for_each_console(c) { if (!c->device) continue; @@ -3546,6 +3544,12 @@ static ssize_t show_cons_active(struct device *dev, if (i >= ARRAY_SIZE(cs)) break; } + + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ + console_lock(); while (i--) { int index = cs[i]->index; struct tty_driver *drv = cs[i]->device(cs[i], &index); @@ -3561,6 +3565,8 @@ static ssize_t show_cons_active(struct device *dev, } console_unlock(); + console_list_unlock(); + return count; } static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL); From patchwork Wed Oct 19 14:55:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379635wrs; Wed, 19 Oct 2022 08:11:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lrOG850aHSEvQHtVnk++k/boeyvY3GexBOAVtpmfFQzGxVeeIt30AubIgE7+4RiKvD7eT X-Received: by 2002:a17:907:a46:b0:782:1c1c:8141 with SMTP id be6-20020a1709070a4600b007821c1c8141mr7058606ejc.549.1666192278109; Wed, 19 Oct 2022 08:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192278; cv=none; d=google.com; s=arc-20160816; b=UdulkzV9Ir0ykJau31GHaQlfs/A2buHLTet1d50RIiWe/lw/WF++fy8I0D4dK9VZA4 DN6r2/PCzU77O8fWeF6zKk1YTUmizZYO/POd/WTetJw6TwDuUkoO4CEvKuchAl77qvlf XKfcFNhpXgsuUUzsnRFJmNAapVLhz2FLAUaIgSc/Gu485TsUN2bD3UNDPP6yUOV5jigp QBCD90sopF6GAH4Po5wURrJp+Q/4wguxX/254vTXOdoBbFQCv+81zlXLlKvGEneDPX1b qigrBXnBiDWRUdGKx8PHUrXeyE+2S0CXRfsghrfQA0jln56K7lY4Hssg+UEpF/UdGkd7 aItQ== 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=M9ps/+3zFTTMX/Xw+H343+FOn0pASHbTafsRYfPyD80=; b=iO1ncKxYdZsxO4V1UPJSvPq4KD3ccEpZ81gbj7j8RAyRAismWXcMyqlZScpjLPFp8A z0xnAjqh7YCwn8V/AQ1Sg6QJCDqkOt3m0REI08r3x4HIJW+Sj9B+3TfwBVUvDUt9SlJK E+Zg0OUXZu848En8Xsst/4bb1EItKept9IIjUL32cwZ0n8YrgXTP11k75FDWviEq/iUS UKDLovxJq7gs2HktIKxa1o2UJb8YAkYmNyjH27PWa/FXOnjIlHw55RjC2l0MLujQ/xbR rmE/HOFNo+cmxlchTh9VecBDP5sK1JuN12QsmvFmzYQSStdacL1LJXskdmNgYYIQBpVa cw7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xryRBIth; 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 d11-20020a50ea8b000000b0045cca8f9a1fsi6232452edo.558.2022.10.19.08.10.51; Wed, 19 Oct 2022 08:11:18 -0700 (PDT) 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=xryRBIth; 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 S232140AbiJSPII (ORCPT + 99 others); Wed, 19 Oct 2022 11:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbiJSPGi (ORCPT ); Wed, 19 Oct 2022 11:06:38 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C213F36798; Wed, 19 Oct 2022 07:59:31 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191381; 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=M9ps/+3zFTTMX/Xw+H343+FOn0pASHbTafsRYfPyD80=; b=xryRBIthFWhP4UrwlfzbLHB1wneSnBcBBrCWGbfzhFtyZZ62blHFAAWadbR3RfJ0xiS3D8 E8G/EiTVA2QAo78BFXu4HLdwD+wAF6JL8ZZPT3fT3XiPQ0U3QnQkiqFxYtRNWpb8fxr2Cx A/Cmed+jZKcC1QRl0fM0J5BhpF3Ep4COPsunR9DMwyMVrS6nOyn1FZdHgAvIlS9jd3c3/u DNATXphbwlgI1vTSZ6DZy++PAOL/yQeAkH6xkw/VIyWpUi46a/OKZkof+PQOokG1dN51E3 ScxR1SESvRXx3+MDvobD2S55zRzzj6vOpkbNnDYcWKvXBeaZ6jqGRdPZWw68+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191381; 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=M9ps/+3zFTTMX/Xw+H343+FOn0pASHbTafsRYfPyD80=; b=nK0TpZ0gm/hS4UwI6UaYUoHDooyjpXsBf4rDrK5NbkFeKSjWQqGLTzLJJFbqmldTgUwgZh deKrFqZ6DM/L2uDQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH printk v2 36/38] proc: consoles: use console_list_lock for list iteration Date: Wed, 19 Oct 2022 17:01:58 +0206 Message-Id: <20221019145600.1282823-37-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129234153487808?= X-GMAIL-MSGID: =?utf-8?q?1747129234153487808?= The console_lock is used in part to guarantee safe list iteration. The console_list_lock should be used because list synchronization repsponsibility will be removed from the console_lock in a later change. Note, the console_lock is still needed to stop console printing. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- fs/proc/consoles.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c index 32512b477605..77409b176569 100644 --- a/fs/proc/consoles.c +++ b/fs/proc/consoles.c @@ -33,7 +33,15 @@ static int show_console_dev(struct seq_file *m, void *v) if (con->device) { const struct tty_driver *driver; int index; + + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ + console_lock(); driver = con->device(con, &index); + console_unlock(); + if (driver) { dev = MKDEV(driver->major, driver->minor_start); dev += index; @@ -64,14 +72,11 @@ static void *c_start(struct seq_file *m, loff_t *pos) loff_t off = 0; /* - * Stop console printing because the device() callback may - * assume the console is not within its write() callback. - * - * Hold the console_lock to guarantee safe traversal of the + * Hold the console_list_lock to guarantee safe traversal of the * console list. SRCU cannot be used because there is no * place to store the SRCU cookie. */ - console_lock(); + console_list_lock(); for_each_console(con) if (off++ == *pos) break; @@ -89,7 +94,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos) static void c_stop(struct seq_file *m, void *v) { - console_unlock(); + console_list_unlock(); } static const struct seq_operations consoles_op = { From patchwork Wed Oct 19 14:55:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5638 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379023wrs; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4u6bWk51lJ1hDeDh1pk4P7LRvGcjjd7zHM3aiUUPZoxd32e7gUEsfYYI1hZP+gS4I7MYQJ X-Received: by 2002:a05:6402:1cc5:b0:453:ed3f:6a38 with SMTP id ds5-20020a0564021cc500b00453ed3f6a38mr7970399edb.346.1666192213167; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192213; cv=none; d=google.com; s=arc-20160816; b=F9LN0FtIw4WeB02/rv9Ami+R7s7zV5edyE0qcsOlU3hl20IpZVUfzwZWTBjj1ZMpXT S4D+G3A6Tkq7IsPyTAqBLV50T+bpGPFd3kGA8q1ZhNL41OgONxGcJWgEkgKRkLGBuNhO qUcIVk4ugxkCeJfoQzsbWtlzCG8ZiP/d/YTd00C2VQbbCaLVWWhwJj+TRKG2H/L80E72 //ZG2ye2nJO2cJjF8JOqVuj8mGBxzzp5X2cO3uw95AS2WyEVuynscaq6XdI58nIuaORj jU8W/8Y+p/AzR0qIUnZTSkrffnCWysqiFO3wGTsbSlo4pimsf1jMhE7RmnM1DSIYmvt4 P2Tg== 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=ERAmScBWw3AWOQd/N8KPYvjMNho4M2d8wqoVxvpkojg=; b=CgjugMSVRWuRNvpRhMPXfL97pAcKJgZaFG7SbH91dJLtN/RxhN+Fs3WuAJ6zsx7aGS faKwF4SmsnX2z3OvadJHo7JBXpnpyIZ/J3vBubO1f8BiC//zmRyVlSxhHQad8lmr9Aco Vtj94p05EnesAiG060Qft21umt9KpzAMtRssm58hs2RIW49eYFLrpCOJ8uygoICuvwpS N6bYU4XdZru9KazwdMMt/pgg8kP0+tQZ3TSD3I/4gJqcRdN6AAUNG29W978oHQRkYNTE MkvmPdKHN0jc0a9HRBG6XgtI2iyARtvlqW19vhIXHdNorCrDRMcA80FQtVC8t0GuzrMl sT3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p7EHFUdV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 p26-20020a170906a01a00b0078db89b2566si12796615ejy.699.2022.10.19.08.09.44; Wed, 19 Oct 2022 08:10:13 -0700 (PDT) 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=p7EHFUdV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S232124AbiJSPG6 (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbiJSPFn (ORCPT ); Wed, 19 Oct 2022 11:05:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C3D2DC6 for ; Wed, 19 Oct 2022 07:59:21 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191381; 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=ERAmScBWw3AWOQd/N8KPYvjMNho4M2d8wqoVxvpkojg=; b=p7EHFUdVULSPTa08I7V4W4rGuOGZwbKXMbpmy7FQ/hM/Akq2VHbWOybQyOPaIOQrMynit4 ej7WV/9P69E8eZBOhLDiLJlrtilFtFK9XGJgoWlTrZNjwAdU/JWjcQgAlEaOPb4G1nWl5b TReEvqMia7ozppHpRIsh6OEWPdoTOkcPeJH4N8SEI0A/MzxlshaDMF13LQKP1TnMI+ubx9 Xl4NboHNjl6nuEPXtwS+kozYdOGmAF+ePdeob47Ak0wL6PRzU1obyGe39bWtW3Iy7oJVyD Vkv8yDL44DmJ8w3tppP5p/BE8zRaOFrxQ6dZE4JLY+ict0Hs+OTjbOcit2hpwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191381; 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=ERAmScBWw3AWOQd/N8KPYvjMNho4M2d8wqoVxvpkojg=; b=XSBfRYfXfVmjl1gxZkSLwF2XwQJDPNi9TKXi2UryMFR1GEHWj2Cu4NTSvRskEHY/1hTm0t 8ZS0wYOq2I7A30BQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 37/38] printk: relieve console_lock of list synchronization duties Date: Wed, 19 Oct 2022 17:01:59 +0206 Message-Id: <20221019145600.1282823-38-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129166387648531?= X-GMAIL-MSGID: =?utf-8?q?1747129166387648531?= The console_list_lock provides synchronization for console list and console->flags updates. All call sites that were using the console_lock for this synchronization have either switched to use the console_list_lock or the SRCU list iterator. Remove console_lock usage for console list updates and console->flags updates. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3615ee6d68fd..840d581c4b23 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -82,8 +82,8 @@ EXPORT_SYMBOL(oops_in_progress); static DEFINE_MUTEX(console_mutex); /* - * console_sem protects console_list and console->flags updates, and also - * provides serialization for access to the entire console driver system. + * console_sem protects updates to console->seq and console_suspended, + * and also provides serialization for console printing. */ static DEFINE_SEMAPHORE(console_sem); HLIST_HEAD(console_list); @@ -2635,7 +2635,7 @@ static int console_cpu_notify(unsigned int cpu) * console_lock - lock the console system for exclusive use. * * Acquires a lock which guarantees that the caller has - * exclusive access to the console system and console_list. + * exclusive access to the console system. * * Can sleep, returns nothing. */ @@ -2655,7 +2655,7 @@ EXPORT_SYMBOL(console_lock); * console_trylock - try to lock the console system for exclusive use. * * Try to acquire a lock which guarantees that the caller has exclusive - * access to the console system and console_list. + * access to the console system. * * returns 1 on success, and 0 on failure to acquire the lock. */ @@ -2911,8 +2911,7 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove /** * console_unlock - unlock the console system * - * Releases the console_lock which the caller holds on the console system - * and the console driver list. + * Releases the console_lock which the caller holds on the console system. * * While the console_lock was held, console output may have been buffered * by printk(). If this is the case, console_unlock(); emits @@ -3098,9 +3097,7 @@ void console_stop(struct console *console) { __pr_flush(console, 1000, true); console_list_lock(); - console_lock(); console->flags &= ~CON_ENABLED; - console_unlock(); console_list_unlock(); /* Ensure that all SRCU list walks have completed */ @@ -3111,9 +3108,7 @@ EXPORT_SYMBOL(console_stop); void console_start(struct console *console) { console_list_lock(); - console_lock(); console->flags |= CON_ENABLED; - console_unlock(); console_list_unlock(); __pr_flush(console, 1000, true); } @@ -3315,7 +3310,6 @@ void register_console(struct console *newcon) * Put this console in the list - keep the * preferred driver at the head of the list. */ - console_lock(); if (hlist_empty(&console_list)) { /* Ensure CON_CONSDEV is always set for the head. */ newcon->flags |= CON_CONSDEV; @@ -3329,7 +3323,6 @@ void register_console(struct console *newcon) } else { hlist_add_behind_rcu(&newcon->node, console_list.first); } - console_unlock(); /* No need to synchronize SRCU here! */ @@ -3370,8 +3363,6 @@ static int unregister_console_locked(struct console *console) if (res > 0) return 0; - console_lock(); - /* Disable it unconditionally */ console->flags &= ~CON_ENABLED; @@ -3394,8 +3385,6 @@ static int unregister_console_locked(struct console *console) if (!hlist_empty(&console_list) && console->flags & CON_CONSDEV) console_first()->flags |= CON_CONSDEV; - console_unlock(); - /* Ensure that all SRCU list walks have completed */ synchronize_srcu(&console_srcu); From patchwork Wed Oct 19 14:56:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 5653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp379691wrs; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FImyeZUIteFBlrljKuSYx6xwCUwTuRKReC8dtP/FIeiZTYeBkZGrVy9KyLXMj4riEVVbf X-Received: by 2002:a17:907:701:b0:780:2c44:e4dd with SMTP id xb1-20020a170907070100b007802c44e4ddmr7358185ejb.589.1666192285086; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192285; cv=none; d=google.com; s=arc-20160816; b=ez7T1zp3oLBuzUi2RPbeuPbZGan5QnNCyKreNRgayVo3gx+Y/9e1j+YqhbkXSdy2P9 035WE3J2lp98USm/WcO/Ql3GDNtI2Lv901zDNHksB4y3ejY/kwgg1f7wEUpotJJAbX3a 17xbwaulB+zwFqr9r2mkAkEFZWYISJENJ97DmgIDFgfo/RZ1zkh1hnkeRuQpUwxM2ORO M1eA6ID7HhzabuoUv6F1YP2E1rsc8ezDTXeOvNDXkUB/BadSQU322WNTjfnk26CLGv9v MVmG4SfkyllmdIY3kMMEEuNJ4cIsy5hqactQls+uXPd7YWdnA5k7jQWSfE+B3XOKPYTu 1w3w== 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=aXcesGHiS9CJwBLB5AtQkJ+SjPh3MNkbA2I4bHFlwT4=; b=WCTeW+fkamCuGkaAZ5nnjNGCC3gnv46qxs8ZXAeopiPVkPHImKWNvaLwDgU7XqPVWy eUMTdm+ZQvnzsq5T+kHHAJsiJKrJKfM4F+4LzaMQx9ZcM1fVZbCkPMp/1yqugsPttsKF imeiLrKGvcIOxrqJ8TCgv79960dujPx7Qg/4ekap3LAQVZUrgim5NGSHZrPtSCtIK6wt 8RvOL7+3wdNnL29DItD/LEv9+lbZwEUvkP7jxKwT9a6V3GeYr6lpL0LV2thf0ffPuLTR HBZK/sF3z7+GhehBC5iHob6+rAH4/qElOYRzLqAxbSACpcqUfqecKU/5dVYFhIkcKU/d dgKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vyVdNsmD; 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 z20-20020aa7d414000000b0045915116d33si12757253edq.535.2022.10.19.08.10.59; Wed, 19 Oct 2022 08:11:25 -0700 (PDT) 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=vyVdNsmD; 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 S231542AbiJSPIM (ORCPT + 99 others); Wed, 19 Oct 2022 11:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbiJSPGi (ORCPT ); Wed, 19 Oct 2022 11:06:38 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A69479620; Wed, 19 Oct 2022 07:59:31 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191382; 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=aXcesGHiS9CJwBLB5AtQkJ+SjPh3MNkbA2I4bHFlwT4=; b=vyVdNsmDCOtZ1td7FZJE2kL0NFcmHJkDeb8tBWR6iDUAHMNtB/gaxUaCu7IOuYDjCtdTGf 7JMy3AFlQHUwJVxxWRF61DKsEUyqZRkxV7auxPl3IWWrfKeqXCbTFP1XCjq4+t36WbX9n3 Lk0u97wao4rNY5seMwaeTD9hMMmwwZAO7FNkBian35LLG7JI5kr+LIiauXac/JHyFLh0oS 0bab60tCRUjG95HHblokpeEUA2qyzG6Wp6FwAKRehYx7odX+BRLntV+unpa7brXAp90riX g0saBHF8isP/h2pPYkiVRR0qX2oN2XOyv2ogU5splu0VZKufFuAm+1ETP7yO7Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191382; 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=aXcesGHiS9CJwBLB5AtQkJ+SjPh3MNkbA2I4bHFlwT4=; b=3KenGGEQ+2eWZ5r+4AzHNAE//1dUZSpARbtG8UMeJGjl8XQGUV1nPPSymknxmfh1mJh3sK E+W71aY0Z0vk/3Bg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Helge Deller , Greg Kroah-Hartman , Javier Martinez Canillas , Thomas Zimmermann , Juergen Gross , Boris Ostrovsky , Tom Rix , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH printk v2 38/38] printk, xen: fbfront: create/use safe function for forcing preferred Date: Wed, 19 Oct 2022 17:02:00 +0206 Message-Id: <20221019145600.1282823-39-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129241099715685?= X-GMAIL-MSGID: =?utf-8?q?1747129241099715685?= With commit 9e124fe16ff2("xen: Enable console tty by default in domU if it's not a dummy") a hack was implemented to make sure that the tty console remains the console behind the /dev/console device. The main problem with the hack is that, after getting the console pointer to the tty console, it is assumed the pointer is still valid after releasing the console_sem. This assumption is incorrect and unsafe. Make the hack safe by introducing a new function console_force_preferred() to perform the full operation under the console_list_lock. Signed-off-by: John Ogness --- drivers/video/fbdev/xen-fbfront.c | 8 +--- include/linux/console.h | 1 + kernel/printk/printk.c | 69 +++++++++++++++++++------------ 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index 2552c853c6c2..aa362b25a60f 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c @@ -512,12 +512,8 @@ static void xenfb_make_preferred_console(void) } console_srcu_read_unlock(cookie); - if (c) { - unregister_console(c); - c->flags |= CON_CONSDEV; - c->flags &= ~CON_PRINTBUFFER; /* don't print again */ - register_console(c); - } + if (c) + console_force_preferred(c); } static int xenfb_resume(struct xenbus_device *dev) diff --git a/include/linux/console.h b/include/linux/console.h index bf1e8136424a..41378b00bbdd 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -235,6 +235,7 @@ enum con_flush_mode { }; extern int add_preferred_console(char *name, int idx, char *options); +extern void console_force_preferred(struct console *c); extern void register_console(struct console *); extern int unregister_console(struct console *); extern void console_lock(void); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 840d581c4b23..9a056a42b8d8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3207,38 +3207,17 @@ static void try_enable_default_console(struct console *newcon) static int unregister_console_locked(struct console *console); -/* - * The console driver calls this routine during kernel initialization - * to register the console printing procedure with printk() and to - * print any messages that were printed by the kernel before the - * console driver was initialized. - * - * This can happen pretty early during the boot process (because of - * early_printk) - sometimes before setup_arch() completes - be careful - * of what kernel features are used - they may not be initialised yet. - * - * There are two types of consoles - bootconsoles (early_printk) and - * "real" consoles (everything which is not a bootconsole) which are - * handled differently. - * - Any number of bootconsoles can be registered at any time. - * - As soon as a "real" console is registered, all bootconsoles - * will be unregistered automatically. - * - Once a "real" console is registered, any attempt to register a - * bootconsoles will be rejected - */ -void register_console(struct console *newcon) +static void register_console_locked(struct console *newcon) { struct console *con; bool bootcon_enabled = false; bool realcon_enabled = false; int err; - console_list_lock(); - for_each_console(con) { if (WARN(con == newcon, "console '%s%d' already registered\n", con->name, con->index)) { - goto unlock; + return; } if (con->flags & CON_BOOT) @@ -3251,7 +3230,7 @@ void register_console(struct console *newcon) if (newcon->flags & CON_BOOT && realcon_enabled) { pr_info("Too late to register bootconsole %s%d\n", newcon->name, newcon->index); - goto unlock; + return; } /* @@ -3282,7 +3261,7 @@ void register_console(struct console *newcon) /* printk() messages are not printed to the Braille console. */ if (err || newcon->flags & CON_BRL) - goto unlock; + return; /* * If we have a bootconsole, and are switching to a real console, @@ -3346,7 +3325,31 @@ void register_console(struct console *newcon) unregister_console_locked(con); } } -unlock: +} + +/* + * The console driver calls this routine during kernel initialization + * to register the console printing procedure with printk() and to + * print any messages that were printed by the kernel before the + * console driver was initialized. + * + * This can happen pretty early during the boot process (because of + * early_printk) - sometimes before setup_arch() completes - be careful + * of what kernel features are used - they may not be initialised yet. + * + * There are two types of consoles - bootconsoles (early_printk) and + * "real" consoles (everything which is not a bootconsole) which are + * handled differently. + * - Any number of bootconsoles can be registered at any time. + * - As soon as a "real" console is registered, all bootconsoles + * will be unregistered automatically. + * - Once a "real" console is registered, any attempt to register a + * bootconsoles will be rejected + */ +void register_console(struct console *newcon) +{ + console_list_lock(); + register_console_locked(newcon); console_list_unlock(); } EXPORT_SYMBOL(register_console); @@ -3411,6 +3414,20 @@ int unregister_console(struct console *console) } EXPORT_SYMBOL(unregister_console); +void console_force_preferred(struct console *c) +{ + console_list_lock(); + + if (unregister_console_locked(c) == 0) { + c->flags |= CON_CONSDEV; + c->flags &= ~CON_PRINTBUFFER; /* don't print again */ + register_console_locked(c); + } + + console_list_unlock(); +} +EXPORT_SYMBOL(console_force_preferred); + /* * Initialize the console device. This is called *early*, so * we can't necessarily depend on lots of kernel help here.