Message ID | 20221019145600.1282823-29-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;samuel.l.nystrom@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Wed, 19 Oct 2022 07:59:11 -0700 (PDT) From: John Ogness <john.ogness@linutronix.de> 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 <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> 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?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Oct. 19, 2022, 2:55 p.m. UTC
Use srcu console list iteration for console list traversal.
Document why the console_lock is still necessary.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/printk.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
Comments
On Wed 2022-10-19 17:01:50, John Ogness wrote: > Use srcu console list iteration for console list traversal. > > Document why the console_lock is still necessary. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> See a note below. > --- 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. From some reason, I believe this even without more details. I expect that unbank() would need to refresh the screen and use similar code as the write() callback. It is different than the device() callback where the dependency is less obvious. Best Regards, Petr > + * > + * 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)
On Wed 2022-10-19 17:01:50, John Ogness wrote: > Use srcu console list iteration for console list traversal. > > Document why the console_lock is still necessary. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
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)