Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2422849pxy; Tue, 3 Aug 2021 06:14:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrKQrOXOZvJuWy/v92HnLe5oTYdaxMr+vxRGrWFUxb3jPyppWLYN/L671CPOxhmGyTxb3P X-Received: by 2002:a7b:c350:: with SMTP id l16mr4325839wmj.151.1627996496377; Tue, 03 Aug 2021 06:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627996496; cv=none; d=google.com; s=arc-20160816; b=LclBjiEQ+uacDBFoz87eaDWqLvzw4mXZViL9SLr+edTEiOdIEhxEgYkZPxJl5UfD1u Qfi8cEH8vHuB0xnNQsadmI9DauHZ7iob9fdBRP1QORTGZ5gWSqtaPCWQEIoOifvzTN5d n9HoDbToNIyhcHssVAshRRzv5vJPcURn3EpI6B0zgmmdL3xTWRWkv9aBoc7FxLe3YCND iTWpIBR07axbuj6PrW2Y+HOj+8P0WcxuOSFodpIVdZRPlYW5iTRsD3vOZbHOi08xC1eS bGu9j2uZDkRJ5S9igmNIyHk7AwkiHqiFqzPPwrkxsTpziBsLCCvAQcVpGs8IfPCkauxH f7mg== 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:dkim-signature:dkim-signature:from; bh=zratP/d2dqbzr5A3KZPCTDEa+UpOjiFaTT3D2EIH/Pg=; b=DhkMTy/HP03y6Ng8E6ud4Gcn3SmuKSboIon1eJ0vp1IyQEiKCGLsRVhGZBicAAazu3 cR+L3DzJ4vSIUlgRGg2NcnLYz7lRPqgzfl1PZtyMM9ykuOuniNGlBnMqOCP+pHxO7Q/y DzlTCFNDf/2eUIAud/TuxSRdDNekS4mcPBUb+1+5p31NlbA+mm+j/RRwrNzMVOBb87IG 7izFpmwAOoem6R9Sc5sZcw0JyS6vgeyzmO+9Isg8OcXbMgATXE7bzqgUUnVWkA9zFqaQ w251OHgU34MSr/mPYRBDsOsTo7KyzGZepDRXPBSPZiHh/jDE/B1no0JG0yVJhWm7UVXo 38WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zk5sPz0A; dkim=neutral (no key) header.i=@linutronix.de header.b=eiwsN3XD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ke5si13847900ejc.8.2021.08.03.06.14.33; Tue, 03 Aug 2021 06:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zk5sPz0A; dkim=neutral (no key) header.i=@linutronix.de header.b=eiwsN3XD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236195AbhHCNNQ (ORCPT + 99 others); Tue, 3 Aug 2021 09:13:16 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56050 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235954AbhHCNNP (ORCPT ); Tue, 3 Aug 2021 09:13:15 -0400 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1627996383; 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; bh=zratP/d2dqbzr5A3KZPCTDEa+UpOjiFaTT3D2EIH/Pg=; b=zk5sPz0A/N68QiMZNa4XnUH53XQGAkBgxmMF9RdDFSoOGdHXqC//ofK9o10vkQtIIgxpxy o3gzfJIWcGuD/7CJSo5P2+b6eNhxoNOxZol539AjZC3laI2y9WkzZGJ7p/8XuGC/SI6py5 6Mpztfu+HxmsRcOTqIZJcFq3yrOVV08E2vhgrY8or5Z3uRGykD2IiT/TXmzbGy4LL+sBHS cGTPp1pxVnfmrDUBXMNIf7pO9xGKJUUaHa3+Iftq3TyMFoNPnqWV077wktj4wMXkILY+0N qrvzjb5E1n/5VK5Jn8gch/Yneaa2fDy8JybmbeFc/b2DSqzfflXIeOBn73Azfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1627996383; 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; bh=zratP/d2dqbzr5A3KZPCTDEa+UpOjiFaTT3D2EIH/Pg=; b=eiwsN3XDO7gIOKIO/tyPKCl9YBM/K+0P9ejFJ1AFeHJgY6RpWMpxmcaTC14bbaMpVCrVQI kAWF+aftd/6aNtAw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrew Morton , Peter Zijlstra , "Paul E. McKenney" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Jason Wessel , Daniel Thompson , Douglas Anderson , Srikar Dronamraju , "Gautham R. Shenoy" , Chengyang Fan , Christophe Leroy , Bhaskar Chowdhury , Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , "Gustavo A. R. Silva" , linuxppc-dev@lists.ozlabs.org, kgdb-bugreport@lists.sourceforge.net, Greg Kroah-Hartman , Masahiro Yamada , Nick Desaulniers , Andy Shevchenko , Tetsuo Handa , Vitor Massaru Iha , Sedat Dilek , Changbin Du , Sumit Garg , Cengiz Can , Jiri Slaby , Paul Cercueil , Matthias Brugger , Andrew Jeffery , Christophe JAILLET , kuldip dwivedi , Wang Qing , Andrij Abyzov , Johan Hovold , Eddie Huang , Claire Chang , Hsin-Yi Wang , Zhang Qilong , "Maciej W. Rozycki" , Guenter Roeck , Sergey Senozhatsky , Serge Semin , Al Cooper , linux-serial@vger.kernel.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH printk v1 00/10] printk: introduce atomic consoles and sync mode Date: Tue, 3 Aug 2021 15:18:51 +0206 Message-Id: <20210803131301.5588-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This is the next part of our printk-rework effort (points 3 and 4 of the LPC 2019 summary [0]). Here the concept of "atomic consoles" is introduced through a new (optional) write_atomic() callback for console drivers. This callback must be implemented as an NMI-safe variant of the write() callback, meaning that it can function from any context without relying on questionable tactics such as ignoring locking and also without relying on the synchronization of console semaphore. As an example of how such an atomic console can look like, this series implements write_atomic() for the 8250 UART driver. This series also introduces a new console printing mode called "sync mode" that is only activated when the kernel is about to end (such as panic, oops, shutdown, reboot). Sync mode can only be activated if atomic consoles are available. A system without registered atomic consoles will be unaffected by this series. When in sync mode, the console printing behavior becomes: - only consoles implementing write_atomic() will be called - printing occurs within vprintk_store() instead of console_unlock(), since the console semaphore is irrelevant for atomic consoles For systems that have registered atomic consoles, this series improves the reliability of seeing crash messages by using new locking techniques rather than "ignoring locks and hoping for the best". In particular, atomic consoles rely on the CPU-reentrant spinlock (i.e. the printk cpulock) for synchronizing console output. John Ogness [0] https://lore.kernel.org/lkml/87k1acz5rx.fsf@linutronix.de/ John Ogness (10): printk: relocate printk cpulock functions printk: rename printk cpulock API and always disable interrupts kgdb: delay roundup if holding printk cpulock printk: relocate printk_delay() printk: call boot_delay_msec() in printk_delay() printk: use seqcount_latch for console_seq console: add write_atomic interface printk: introduce kernel sync mode kdb: if available, only use atomic consoles for output mirroring serial: 8250: implement write_atomic arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/kernel/kgdb.c | 10 +- arch/powerpc/kernel/smp.c | 5 + arch/x86/kernel/kgdb.c | 9 +- drivers/tty/serial/8250/8250.h | 47 ++- drivers/tty/serial/8250/8250_core.c | 17 +- drivers/tty/serial/8250/8250_fsl.c | 9 + drivers/tty/serial/8250/8250_ingenic.c | 7 + drivers/tty/serial/8250/8250_mtk.c | 29 +- drivers/tty/serial/8250/8250_port.c | 92 ++-- drivers/tty/serial/8250/Kconfig | 1 + include/linux/console.h | 32 ++ include/linux/kgdb.h | 3 + include/linux/printk.h | 57 +-- include/linux/serial_8250.h | 5 + kernel/debug/debug_core.c | 45 +- kernel/debug/kdb/kdb_io.c | 16 + kernel/printk/printk.c | 554 +++++++++++++++++-------- lib/Kconfig.debug | 3 + lib/dump_stack.c | 4 +- lib/nmi_backtrace.c | 4 +- 21 files changed, 684 insertions(+), 266 deletions(-) base-commit: 23d8adcf8022b9483605531d8985f5b77533cb3a -- 2.20.1