From patchwork Mon Nov 7 14:16:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 16440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2078542wru; Mon, 7 Nov 2022 06:20:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM5Il1whCMAVR9sNBEOOLS2UttHUdhpBEZZtkTbB/DB/vzNIRIz1jpTdZQ67CECm+0oPc9yc X-Received: by 2002:a17:902:f685:b0:186:fa9c:2fdc with SMTP id l5-20020a170902f68500b00186fa9c2fdcmr51077898plg.25.1667830843868; Mon, 07 Nov 2022 06:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830843; cv=none; d=google.com; s=arc-20160816; b=prJ3mORMOWhRnGxDfir/eAaqSm4eUMtBcyPSLzDm4i9CJEstWpumWMLhclkz2pEPPb Bof3wyf7CX3hxDMUtJpWWMK8O9R8NSwZBIxuaPS1m1d0bjW3hQY3cGpY9TyzvV7FyfbO y8E3aRxPToMuRYryu72p1Yk5wxxq/m8GtP2UslkmbVZbyGfPe/2U6/WrlciJvPXCrDX3 r+N6UEmDIRIKVWDdBjeCCdbwq3VJUDw07IE++VlpkY4VtIcaOrSI8ceiP2vITwhSPn+v ZVXOXIte/y2Lsp1ztv/N6S0271Te/uufKyQMHnoCIKe8PoWLNmsMX98jjyBqw/T4qacM dWIg== 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; 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 q19-20020a635053000000b0044b817adee1si10321439pgl.78.2022.11.07.06.20.27; Mon, 07 Nov 2022 06:20:43 -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; 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 + 99 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 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?1748847394536976848?= X-GMAIL-MSGID: =?utf-8?q?1748847394536976848?= 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)