Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4361938rwe; Tue, 30 Aug 2022 08:49:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7puQ7aje6+I9CbbQ4ZsofvZZyWfa8vKd6te6bqerCu4oJTqzLXUoe1BqfLyYJR1oiqc5f8 X-Received: by 2002:a17:90b:35c5:b0:1fd:9087:6a70 with SMTP id nb5-20020a17090b35c500b001fd90876a70mr17340528pjb.158.1661874553685; Tue, 30 Aug 2022 08:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661874553; cv=none; d=google.com; s=arc-20160816; b=AW5bOVddaNL8XJ3+CvSfTDXW+IGhHCV7KJpSOYquECfhxkscAWUbeV5+uomfd4FuDE NGnD5OxAfYBs+aA8MY9leVo+23My3WBNDm2dhZFFslvOHlHjifgGmOiPIBCsr0renUeE DmCOOFabKn0vKAyy56OYUmNW6Xoi1adti8ZnnKghfcgXn5UNgepVB+Cx1drtnYvzpnc7 lgMWoNy5gxgA7ozbRUe2uizKtMovf6lBp4KFzxOwyKKv8omoSONmW1vANNnTgxFrrnZp 6PyHBulMlqXBCcRuG3pzpTiia9UFJ+kT3PylOL90bkidAr0uZu21O4K7quihQxxfQFH+ bljA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=hw1EJiwr4Al7TCfH8SB9V/gTFnExQ67cbO1DoH3A/6Q=; b=sT2xTLBxkx/GPyGYQlw+sPVMw3H0/sHSYAsYpk6KveXVz3/Jeifq7o4iOCUJFOLbmG xOqm38NbX4Ztvhhc7oFWmHuapyCQ8FqVaUmdMR72UDiv5vqio9bTwCjntO0X2numz7vW zqRkwFnKntYsBlPDP16nJhbU+FR+CpnYjhcim9UMrNoreq8AyyeDy4YHNPvwHszPXbqF F66rZv3EYl2GImkekOIk6txQ14cr2TSY6IOmlaDWuH8O2TO3vV+vRtmFmCsutVyqFuys S7D+gSwZU2arFfCuDPKf7I0fZWWVgLgii1N6GwFG2AiCnOci4Ffn5/O9WsYzvj2ew+WA Zkdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=i9RDRTll; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a056a00248400b00537f5ce9d9esi547112pfv.285.2022.08.30.08.48.51; Tue, 30 Aug 2022 08:49: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=@ffwll.ch header.s=google header.b=i9RDRTll; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbiH3OuQ (ORCPT + 99 others); Tue, 30 Aug 2022 10:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbiH3OuL (ORCPT ); Tue, 30 Aug 2022 10:50:11 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF3D1B795 for ; Tue, 30 Aug 2022 07:50:08 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id b16so6929895wru.7 for ; Tue, 30 Aug 2022 07:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=hw1EJiwr4Al7TCfH8SB9V/gTFnExQ67cbO1DoH3A/6Q=; b=i9RDRTllGAeTyupOXinyWn4xi9uMuo8hOBZb1u7BPZJI0mWVvCAnZZngKQec7WUR/u LZI150GiVdviCoWWQiUhcPslBdFM31/iCXrLduHiTrz9ne6r4a6BpmvKcpSkswTFh+eh PrJVi+po5hGMRgLE+vOzHKw8ac8G64mcS45yw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=hw1EJiwr4Al7TCfH8SB9V/gTFnExQ67cbO1DoH3A/6Q=; b=mw39ZIzDqONcOC+BZYaJFZMuN5r4m/uOdop91cfKK/PT2z5SEFC7ARvgDAa8fGH0d1 uLc7hBKAtEqoFbnLzCVfPvNvO4NqXLyK4Nj3sZf50xzdOHrB+O1rEWn8CNwN5+0WoJWw JVqMQ0d4O3zpdnouTsImdsrNpbEUvSS9arKiQnY4P16EBvmjHwQ4RezAnSD1/9GUGPgg q4+Zm+6Z6Z8hYuBtUCEA/CJuDY2DZLC9aT5fAjpCY5Z/7FXqP8EjND15ifAwtQpHdgyI Jnq+eVBpAkk5TG/YejTosHx02Fg0qYgZM/XqYxr9AkIR51tUBYkIIvV10s5LyxJ6+Dzc QFiw== X-Gm-Message-State: ACgBeo0St2gh2Mmeu9z5QAnebRarkS2cNS0KOoUuF6+JJOsMomn48XX+ sHNWbf2hkN6HBVlOnOE4i7ttR1CEPAiweLGP X-Received: by 2002:a5d:6b09:0:b0:225:37cf:fb8b with SMTP id v9-20020a5d6b09000000b0022537cffb8bmr9247069wrw.179.1661871007971; Tue, 30 Aug 2022 07:50:07 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l9-20020adfe9c9000000b0022586045c89sm10278212wrn.69.2022.08.30.07.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 07:50:07 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , Daniel Vetter , Daniel Vetter , Greg Kroah-Hartman , Jiri Slaby , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Tetsuo Handa , Xuezhi Zhang , Yangxi Xiang , nick black , Petr Mladek , Andrew Morton , Luis Chamberlain , "Guilherme G. Piccoli" , Marco Elver , John Ogness , Sebastian Andrzej Siewior , David Gow , tangmeng , Tiezhu Yang , Chris Wilson Subject: [PATCH] kernel/panic: Drop unblank_screen call Date: Tue, 30 Aug 2022 16:50:04 +0200 Message-Id: <20220830145004.430545-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 console_unblank() does this too (called in both places right after), and with a lot more confidence inspiring approach to locking. Reconstructing this story is very strange: In b61312d353da ("oops handling: ensure that any oops is flushed to the mtdoops console") it is claimed that a printk(" "); flushed out the console buffer, which was removed in e3e8a75d2acf ("[PATCH] Extract and use wake_up_klogd()"). In todays kernels this is done way earlier in console_flush_on_panic with some really nasty tricks. I didn't bother to fully reconstruct this all, least because the call to bust_spinlock(0); gets moved every few years, depending upon how the wind blows (or well, who screamed loudest about the various issue each call site caused). Before that commit the only calls to console_unblank() where in s390 arch code. The other side here is the console->unblank callback, which was introduced in 2.1.31 for the vt driver. Which predates the console_unblank() function by a lot, which was added (without users) in 2.4.14.3. So pretty much impossible to guess at any motivation here. Also afaict the vt driver is the only (and always was the only) console driver implementing the unblank callback, so no idea why a call to console_unblank() was added for the mtdooops driver - the action actually flushing out the console buffers is done from console_unlock() only. Note that as prep for the s390 users the locking was adjusted in 2.5.22 (I couldn't figure out how to properly reference the BK commit from the historical git trees) from a normal semaphore to a trylock. Note that a copy of the direct unblank_screen() call was added to panic() in c7c3f05e341a ("panic: avoid deadlocks in re-entrant console drivers"), which partially inlined the bust_spinlocks(0); call. Long story short, I have no idea why the direct call to unblank_screen survived for so long (the infrastructure to do it properly existed for years), nor why it wasn't removed when the console_unblank() call was finally added. But it makes a ton more sense to finally do that than not - it's just better encapsulation to go through the console functions instead of doing a direct call, so let's dare. Plus it really does not make much sense to call the only unblank implementation there is twice, once without, and once with appropriate locking. Signed-off-by: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Daniel Vetter Cc: "Ilpo Järvinen" Cc: Tetsuo Handa Cc: Xuezhi Zhang Cc: Yangxi Xiang Cc: nick black Cc: Petr Mladek Cc: Andrew Morton Cc: Luis Chamberlain Cc: "Guilherme G. Piccoli" Cc: Marco Elver Cc: John Ogness Cc: Sebastian Andrzej Siewior Cc: David Gow Cc: tangmeng Cc: Tiezhu Yang Cc: Chris Wilson --- drivers/tty/vt/vt.c | 3 ++- include/linux/vt_kern.h | 1 - kernel/panic.c | 3 --- lib/bust_spinlocks.c | 3 --- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index a6be32798fad..08498fcf080a 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -154,6 +154,7 @@ static void console_callback(struct work_struct *ignored); static void con_driver_unregister_callback(struct work_struct *ignored); static void blank_screen_t(struct timer_list *unused); static void set_palette(struct vc_data *vc); +static void unblank_screen(void); #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1) @@ -4450,7 +4451,7 @@ EXPORT_SYMBOL(do_unblank_screen); * call it with 1 as an argument and so force a mode restore... that may kill * X or at least garbage the screen but would also make the Oops visible... */ -void unblank_screen(void) +static void unblank_screen(void) { do_unblank_screen(0); } diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index b5ab452fca5b..c1f5aebef170 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -30,7 +30,6 @@ struct vc_data *vc_deallocate(unsigned int console); void reset_palette(struct vc_data *vc); void do_blank_screen(int entering_gfx); void do_unblank_screen(int leaving_gfx); -void unblank_screen(void); void poke_blanked_console(void); int con_font_op(struct vc_data *vc, struct console_font_op *op); int con_set_cmap(unsigned char __user *cmap); diff --git a/kernel/panic.c b/kernel/panic.c index 1fc3d98417d1..74a7b55851c4 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -330,9 +330,6 @@ void panic(const char *fmt, ...) if (_crash_kexec_post_notifiers) __crash_kexec(NULL); -#ifdef CONFIG_VT - unblank_screen(); -#endif console_unblank(); /* diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index 8be59f84eaea..bfd53972a4d8 100644 --- a/lib/bust_spinlocks.c +++ b/lib/bust_spinlocks.c @@ -22,9 +22,6 @@ void bust_spinlocks(int yes) if (yes) { ++oops_in_progress; } else { -#ifdef CONFIG_VT - unblank_screen(); -#endif console_unblank(); if (--oops_in_progress == 0) wake_up_klogd(); -- 2.37.2