Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1921487rwb; Mon, 7 Nov 2022 07:15:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM4TtOC2fHbCUNXcFAMInkZC/c2LM5obVFShixAhmt9OMMPv/qzE2xQWVLGr0mE9SCEBjpux X-Received: by 2002:a05:6a00:a15:b0:56e:9b2b:60dd with SMTP id p21-20020a056a000a1500b0056e9b2b60ddmr16694323pfh.35.1667834104455; Mon, 07 Nov 2022 07:15:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667834104; cv=none; d=google.com; s=arc-20160816; b=HixMyXfRhQUBLL1mxJVjn9zRcyYsigetlCPgrdLrortDuLrcfkZNyxGubCLVgMFADQ I9OyY/UI0E/2/HiDp4JhpfOLf2NaUvPwj70eFhpR9IA0DowKoBjNFwD9bc2JCqQy9ptS YWljWZM+97b1d4SVl4iqNEYLvmd/DOvi9wJlgosdusxAQG8HZ2AZf9P4Z6Lu0tk7FksW 03X9uNMLlrsxF5oyBR4JmnzpgE+u0mtFEJz90zVj2iESVoXHOSmWsHEjnKxeL/WmW8CB G5UoxoXCTRkgNBz0DaSXPOKqgvcKXkXbbtj/wcsrruqYjQoTReJAXrl95cVrXJYR2biR I5CA== 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=a+dMckPSOTswrJAevuczzlxBoDdFUTF9ehHS/Am7BVc=; b=NUhRCrIRPcDIfghN3e2SVF4hDOMujNAi+U2/2cuRyvfrcvdAypbAHyZi/gbHi0Xc+p zgsCXxYi2BdGC4+T7c5LbDFz8as/Aooh3pJlXV0Fy1T8mShb1IKks05uiRVUMrznimzw WADW8Dufx9xEUUizQXrDVDy/XtEg0n4zl8M5G4x5e1cOfZsiWXGeb9oJhuZEWDlzfcvK TeA45y7aWYP6FNXwwlERo6uuVW96TUa85s1S0vy7nMavBVEsk/HohGD1YP0XbNJsOgkc aIxygDjtwHGnXG+lhvxMs6Rwhuiv2LvVJsi/CD4pvhonc71TnrSuDh7FNaJyiB0vo9Tb +qKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="p5Y/D/EI"; dkim=neutral (no key) header.i=@linutronix.de header.b=VHoFbIAs; 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 r14-20020a63440e000000b0046f45ab031esi8946983pga.600.2022.11.07.07.14.46; Mon, 07 Nov 2022 07:15:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="p5Y/D/EI"; dkim=neutral (no key) header.i=@linutronix.de header.b=VHoFbIAs; 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 S232174AbiKGORi (ORCPT + 93 others); Mon, 7 Nov 2022 09:17:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232158AbiKGOQu (ORCPT ); Mon, 7 Nov 2022 09:16:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886231D317 for ; Mon, 7 Nov 2022 06:16:49 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830608; 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=a+dMckPSOTswrJAevuczzlxBoDdFUTF9ehHS/Am7BVc=; b=p5Y/D/EInVPhXQh1fyzw62a7v7ilG2hBVvMEy5oz0pI0tKTHpq8rBapUnzJxc6CXViKuBM fjwYBUx8VvS36kgelTD/s5R30cFw80eGCepxLvc0xJU5zUw/pKEHUYt7Wf9Qc4lnpxgNua cuT4vnqNwbn21DFVQokA6zLmW5OCBYfALqXJCR9ePm0uZf9kXn8x0SZvh8c55kOMhSgsl7 zrI9rrsv4QrCsJKK0zEIGYtxTMQLvrHFb+T8azoBLyGutNmom45RkjqxZgeUblVhLz1982 URiRhxPP7CqjIGfTjAOCQWi+Xh5Medu17I/WeMzGxNS+IrTc+rb7Ld7diMkg/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830608; 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=a+dMckPSOTswrJAevuczzlxBoDdFUTF9ehHS/Am7BVc=; b=VHoFbIAsUVtwAr5/GMK+QqboXX/RIvDR8brYVDImSGAJFJ9Lh7qHt2gyxTyFPDqAPl8eZE b3TUGf+2XXXNFuDw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v3 17/40] printk: console_unblank: use srcu console list iterator Date: Mon, 7 Nov 2022 15:22:15 +0106 Message-Id: <20221107141638.3790965-18-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Note that this is a preparatory change for when console_lock no longer provides synchronization for the console list. Signed-off-by: John Ogness 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 49b9ba00eae8..c3191dc24742 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2952,10 +2952,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) @@ -2965,9 +2969,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