Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp527508qtb; Wed, 19 Oct 2022 08:09:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7IcMSmCJbgQPymzJSM9xptDyAC4X+Bauhjn4P07P5wrOg1zVYAM/NOxhmnCVySGygUwA4G X-Received: by 2002:a17:907:3f0c:b0:78e:2090:6924 with SMTP id hq12-20020a1709073f0c00b0078e20906924mr7345795ejc.332.1666192162677; Wed, 19 Oct 2022 08:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192162; cv=none; d=google.com; s=arc-20160816; b=hHHEVym3Z1qmu12KB+7bgB5idJmk9240n2KFVjaYt0fkPS0r+10jV1IjgqgCdOAIap X5IBDVwOXWhL6M1yq8NyrxwNEuauab1bL+hWq1Wmm9rxrtvqdcpNbBzP+0bB1VyTJeUH 5WabmrXddhCEQqI4K5unRVSEX8bY/YZwj5zOnDUudNaUVzZ2odaewt8p2cXRQaFpXYoy MhSSxo1oDabLFvfDTGY6xPbWe84pVOamypFj3LsebtVsQw0OEw+LC8poCm/AETO0/zWg kUSIkewNgINYSFHz8A6NFiZSVkxe760HUbZz8PWinZ4F6mdQQ4ngbwl414N3aL8eizaO y6nw== 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 Return-Path: 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.08.55; Wed, 19 Oct 2022 08:09:22 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 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) -- 2.30.2