From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28475C636C8 for ; Thu, 15 Jul 2021 19:54:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D8B261167 for ; Thu, 15 Jul 2021 19:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244248AbhGOT5U (ORCPT ); Thu, 15 Jul 2021 15:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347251AbhGOTwK (ORCPT ); Thu, 15 Jul 2021 15:52:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19651C06175F for ; Thu, 15 Jul 2021 12:34:03 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=H1Slcp5vR+s/qOKCOLfC9pox8PNkKoEZX8fxv9qmyD7nwiZLomLYup9Pb9FSsmnOQ+EPaJ Du1FIb9sBZPE8VTu1nJNL595Me3c0MZJjKkbHZrnXnF/9WNVx8xFDvTpj33GISk1s/v7Pm 0xjM1na3FCAQFwxtGR9n+pmqGKbPqyn1XcKlFopRInV3uT9P8psg1163D7eL1MzzQJQxF9 w5QYbOw3ajycAn9+z/aP9ORfvcr5gmQb9+b6REqz40z5gGn1ngTCuCBm8GzwrMKDYg5iQZ rvR6PNLVTwDg/7QK+YkTZ146g7FBStWXWMKo7L5tx9lYhzmJU99uLYpyoeLtQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=KhW3dN8MQmFGfyVll3Bd6RO29BZ6Hgev3jn4REDVIC0SszHesjcDnMLQfy1uO9iz382/CP tmAaxQ5nCOpMAaAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Eric Biederman , Nicholas Piggin , Christophe Leroy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Morton , Kees Cook , Tiezhu Yang , Alexey Kardashevskiy , Yue Hu , linuxppc-dev@lists.ozlabs.org, kexec@lists.infradead.org, Russell King , Ingo Molnar , Marc Zyngier , Valentin Schneider , Geert Uytterhoeven , Mike Rapoport , "Wolfram Sang (Renesas)" , Anshuman Khandual , Xiongwei Song , Frederic Weisbecker , Peter Zijlstra , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nick Terrell , Vipin Sharma , Rasmus Villemoes , Daniel Borkmann , Vlastimil Babka , linux-arm-kernel@lists.infradead.org Subject: [PATCH printk v4 0/6] printk: remove safe buffers Date: Thu, 15 Jul 2021 21:39:53 +0206 Message-Id: <20210715193359.25946-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, Here is v4 of a series to remove the safe buffers. v3 can be found here [0]. The safe buffers are no longer needed because messages can be stored directly into the log buffer from any context. However, the safe buffers also provided a form of recursion protection. For that reason, explicit recursion protection is implemented for this series. The safe buffers also implicitly provided serialization between multiple CPUs executing in NMI context. This was particularly necessary for the nmi_backtrace() output. This serializiation is now preserved by using the printk cpulock. With the removal of the safe buffers, there is no need for extra NMI enter/exit tracking. So this is also removed (which includes removing the config option CONFIG_PRINTK_NMI). And finally, there are a few places in the kernel that need to specify code blocks where all printk calls are to be deferred printing. Previously the NMI tracking API was being (mis)used for this purpose. This series introduces an official and explicit interface for such cases. (Note that all deferred printing will be removed anyway, once printing kthreads are introduced.) Changes since v3: - Remove safe context tracking in vprintk(). - Add safe context tracking for @console_owner usage since that is also a component of the printing code. - Refactor syslog_print() so that it is easier to understand and follow the locking logic. - Introduce printk_deferred_enter/exit functions to be used by code that needs to specify code block where all printk calls are to be deferred printing. John Ogness [0] https://lore.kernel.org/lkml/20210624111148.5190-1-john.ogness@linutronix.de John Ogness (6): lib/nmi_backtrace: explicitly serialize banner and regs printk: track/limit recursion printk: remove safe buffers printk: remove NMI tracking printk: convert @syslog_lock to mutex printk: syslog: close window between wait and read arch/arm/kernel/smp.c | 4 +- arch/powerpc/kernel/traps.c | 1 - arch/powerpc/kernel/watchdog.c | 5 - arch/powerpc/kexec/crash.c | 2 +- include/linux/hardirq.h | 2 - include/linux/printk.h | 41 ++-- init/Kconfig | 5 - kernel/kexec_core.c | 1 - kernel/panic.c | 3 - kernel/printk/internal.h | 25 --- kernel/printk/printk.c | 268 ++++++++++++++---------- kernel/printk/printk_safe.c | 364 +-------------------------------- kernel/trace/trace.c | 4 +- lib/nmi_backtrace.c | 13 +- 14 files changed, 194 insertions(+), 544 deletions(-) base-commit: 70333dec446292cd896cd051d2ebd6808b328949 -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2630EC636C9 for ; Thu, 15 Jul 2021 19:34:42 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F0CC610C7 for ; Thu, 15 Jul 2021 19:34:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F0CC610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GQl1q5jmBz3bhl for ; Fri, 16 Jul 2021 05:34:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=H1Slcp5v; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=KhW3dN8M; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linutronix.de (client-ip=2a0a:51c0:0:12e:550::1; helo=galois.linutronix.de; envelope-from=john.ogness@linutronix.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=H1Slcp5v; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=KhW3dN8M; dkim-atps=neutral Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GQl1G1w8Gz2yNw for ; Fri, 16 Jul 2021 05:34:10 +1000 (AEST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=H1Slcp5vR+s/qOKCOLfC9pox8PNkKoEZX8fxv9qmyD7nwiZLomLYup9Pb9FSsmnOQ+EPaJ Du1FIb9sBZPE8VTu1nJNL595Me3c0MZJjKkbHZrnXnF/9WNVx8xFDvTpj33GISk1s/v7Pm 0xjM1na3FCAQFwxtGR9n+pmqGKbPqyn1XcKlFopRInV3uT9P8psg1163D7eL1MzzQJQxF9 w5QYbOw3ajycAn9+z/aP9ORfvcr5gmQb9+b6REqz40z5gGn1ngTCuCBm8GzwrMKDYg5iQZ rvR6PNLVTwDg/7QK+YkTZ146g7FBStWXWMKo7L5tx9lYhzmJU99uLYpyoeLtQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=KhW3dN8MQmFGfyVll3Bd6RO29BZ6Hgev3jn4REDVIC0SszHesjcDnMLQfy1uO9iz382/CP tmAaxQ5nCOpMAaAg== To: Petr Mladek Subject: [PATCH printk v4 0/6] printk: remove safe buffers Date: Thu, 15 Jul 2021 21:39:53 +0206 Message-Id: <20210715193359.25946-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Rasmus Villemoes , "Wolfram Sang \(Renesas\)" , Paul Mackerras , Tiezhu Yang , Daniel Borkmann , Marc Zyngier , Masahiro Yamada , Russell King , Peter Zijlstra , Yue Hu , Ingo Molnar , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, Valentin Schneider , Kees Cook , "Paul E. McKenney" , Anshuman Khandual , Vipin Sharma , Frederic Weisbecker , Nicholas Piggin , Nathan Chancellor , Nick Terrell , Steven Rostedt , Thomas Gleixner , Vlastimil Babka , Nick Desaulniers , Xiongwei Song , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky , Eric Biederman , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Mike Rapoport , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi, Here is v4 of a series to remove the safe buffers. v3 can be found here [0]. The safe buffers are no longer needed because messages can be stored directly into the log buffer from any context. However, the safe buffers also provided a form of recursion protection. For that reason, explicit recursion protection is implemented for this series. The safe buffers also implicitly provided serialization between multiple CPUs executing in NMI context. This was particularly necessary for the nmi_backtrace() output. This serializiation is now preserved by using the printk cpulock. With the removal of the safe buffers, there is no need for extra NMI enter/exit tracking. So this is also removed (which includes removing the config option CONFIG_PRINTK_NMI). And finally, there are a few places in the kernel that need to specify code blocks where all printk calls are to be deferred printing. Previously the NMI tracking API was being (mis)used for this purpose. This series introduces an official and explicit interface for such cases. (Note that all deferred printing will be removed anyway, once printing kthreads are introduced.) Changes since v3: - Remove safe context tracking in vprintk(). - Add safe context tracking for @console_owner usage since that is also a component of the printing code. - Refactor syslog_print() so that it is easier to understand and follow the locking logic. - Introduce printk_deferred_enter/exit functions to be used by code that needs to specify code block where all printk calls are to be deferred printing. John Ogness [0] https://lore.kernel.org/lkml/20210624111148.5190-1-john.ogness@linutronix.de John Ogness (6): lib/nmi_backtrace: explicitly serialize banner and regs printk: track/limit recursion printk: remove safe buffers printk: remove NMI tracking printk: convert @syslog_lock to mutex printk: syslog: close window between wait and read arch/arm/kernel/smp.c | 4 +- arch/powerpc/kernel/traps.c | 1 - arch/powerpc/kernel/watchdog.c | 5 - arch/powerpc/kexec/crash.c | 2 +- include/linux/hardirq.h | 2 - include/linux/printk.h | 41 ++-- init/Kconfig | 5 - kernel/kexec_core.c | 1 - kernel/panic.c | 3 - kernel/printk/internal.h | 25 --- kernel/printk/printk.c | 268 ++++++++++++++---------- kernel/printk/printk_safe.c | 364 +-------------------------------- kernel/trace/trace.c | 4 +- lib/nmi_backtrace.c | 13 +- 14 files changed, 194 insertions(+), 544 deletions(-) base-commit: 70333dec446292cd896cd051d2ebd6808b328949 -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FE0DC636C9 for ; Thu, 15 Jul 2021 19:35:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DE426120A for ; Thu, 15 Jul 2021 19:35:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE426120A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=thMLksPfpRCLwBnoojEayca8Ij5IdLJJDITp38Jpa1I=; b=AuspNGrH1n3xi6 8ZN7zQrXV3FlU956FxMyvm9ZFfqIE23vNcwSVPPGsQmKkdcCJrv+3yZuBrX73O3FA/k8yYmvfOLxX zmYfPLddCkf1NNv7lo2fMWZzAEp6IRxCdrv3uIHfzsjoar8OoQmARjfJr9nFErzteW+V9+oeVIYT9 NOiy+1Oo11MuYa27Hi6iADVZUnZ8IZeKNVEYq5OqRqnfJivAzOyznmW7kJRN8+hJq28bwaoai9Hb/ qkXbJRTh0l4MVoWh5AmKh2vs7tMHF+ywYfisBfFRsiWkksVuRRTaYfnnsGkNf9U7DatMEXf3QIoWB pItBGYCNvCgamX5vd81w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m477j-002AvQ-JB; Thu, 15 Jul 2021 19:34:19 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m477e-002Al3-6o; Thu, 15 Jul 2021 19:34:16 +0000 From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=H1Slcp5vR+s/qOKCOLfC9pox8PNkKoEZX8fxv9qmyD7nwiZLomLYup9Pb9FSsmnOQ+EPaJ Du1FIb9sBZPE8VTu1nJNL595Me3c0MZJjKkbHZrnXnF/9WNVx8xFDvTpj33GISk1s/v7Pm 0xjM1na3FCAQFwxtGR9n+pmqGKbPqyn1XcKlFopRInV3uT9P8psg1163D7eL1MzzQJQxF9 w5QYbOw3ajycAn9+z/aP9ORfvcr5gmQb9+b6REqz40z5gGn1ngTCuCBm8GzwrMKDYg5iQZ rvR6PNLVTwDg/7QK+YkTZ146g7FBStWXWMKo7L5tx9lYhzmJU99uLYpyoeLtQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1626377641; 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=AlYsQuWcV07ceFNksYMnBsP5kyWUBQUeoD8kaOeX8A4=; b=KhW3dN8MQmFGfyVll3Bd6RO29BZ6Hgev3jn4REDVIC0SszHesjcDnMLQfy1uO9iz382/CP tmAaxQ5nCOpMAaAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Eric Biederman , Nicholas Piggin , Christophe Leroy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Morton , Kees Cook , Tiezhu Yang , Alexey Kardashevskiy , Yue Hu , linuxppc-dev@lists.ozlabs.org, kexec@lists.infradead.org, Russell King , Ingo Molnar , Marc Zyngier , Valentin Schneider , Geert Uytterhoeven , Mike Rapoport , "Wolfram Sang (Renesas)" , Anshuman Khandual , Xiongwei Song , Frederic Weisbecker , Peter Zijlstra , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nick Terrell , Vipin Sharma , Rasmus Villemoes , Daniel Borkmann , Vlastimil Babka , linux-arm-kernel@lists.infradead.org Subject: [PATCH printk v4 0/6] printk: remove safe buffers Date: Thu, 15 Jul 2021 21:39:53 +0206 Message-Id: <20210715193359.25946-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210715_123414_661068_37134A42 X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Here is v4 of a series to remove the safe buffers. v3 can be found here [0]. The safe buffers are no longer needed because messages can be stored directly into the log buffer from any context. However, the safe buffers also provided a form of recursion protection. For that reason, explicit recursion protection is implemented for this series. The safe buffers also implicitly provided serialization between multiple CPUs executing in NMI context. This was particularly necessary for the nmi_backtrace() output. This serializiation is now preserved by using the printk cpulock. With the removal of the safe buffers, there is no need for extra NMI enter/exit tracking. So this is also removed (which includes removing the config option CONFIG_PRINTK_NMI). And finally, there are a few places in the kernel that need to specify code blocks where all printk calls are to be deferred printing. Previously the NMI tracking API was being (mis)used for this purpose. This series introduces an official and explicit interface for such cases. (Note that all deferred printing will be removed anyway, once printing kthreads are introduced.) Changes since v3: - Remove safe context tracking in vprintk(). - Add safe context tracking for @console_owner usage since that is also a component of the printing code. - Refactor syslog_print() so that it is easier to understand and follow the locking logic. - Introduce printk_deferred_enter/exit functions to be used by code that needs to specify code block where all printk calls are to be deferred printing. John Ogness [0] https://lore.kernel.org/lkml/20210624111148.5190-1-john.ogness@linutronix.de John Ogness (6): lib/nmi_backtrace: explicitly serialize banner and regs printk: track/limit recursion printk: remove safe buffers printk: remove NMI tracking printk: convert @syslog_lock to mutex printk: syslog: close window between wait and read arch/arm/kernel/smp.c | 4 +- arch/powerpc/kernel/traps.c | 1 - arch/powerpc/kernel/watchdog.c | 5 - arch/powerpc/kexec/crash.c | 2 +- include/linux/hardirq.h | 2 - include/linux/printk.h | 41 ++-- init/Kconfig | 5 - kernel/kexec_core.c | 1 - kernel/panic.c | 3 - kernel/printk/internal.h | 25 --- kernel/printk/printk.c | 268 ++++++++++++++---------- kernel/printk/printk_safe.c | 364 +-------------------------------- kernel/trace/trace.c | 4 +- lib/nmi_backtrace.c | 13 +- 14 files changed, 194 insertions(+), 544 deletions(-) base-commit: 70333dec446292cd896cd051d2ebd6808b328949 -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: John Ogness Subject: [PATCH printk v4 0/6] printk: remove safe buffers Date: Thu, 15 Jul 2021 21:39:53 +0206 Message-Id: <20210715193359.25946-1-john.ogness@linutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Eric Biederman , Nicholas Piggin , Christophe Leroy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Andrew Morton , Kees Cook , Tiezhu Yang , Alexey Kardashevskiy , Yue Hu , linuxppc-dev@lists.ozlabs.org, kexec@lists.infradead.org, Russell King , Ingo Molnar , Marc Zyngier , Valentin Schneider , Geert Uytterhoeven , Mike Rapoport , "Wolfram Sang (Renesas)" , Anshuman Khandual , Xiongwei Song , Frederic Weisbecker , Peter Zijlstra , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nick Terrell , Vipin Sharma , Rasmus Villemoes , Daniel Borkmann , Vlastimil Babka , linux-arm-kernel@lists.infradead.org Hi, Here is v4 of a series to remove the safe buffers. v3 can be found here [0]. The safe buffers are no longer needed because messages can be stored directly into the log buffer from any context. However, the safe buffers also provided a form of recursion protection. For that reason, explicit recursion protection is implemented for this series. The safe buffers also implicitly provided serialization between multiple CPUs executing in NMI context. This was particularly necessary for the nmi_backtrace() output. This serializiation is now preserved by using the printk cpulock. With the removal of the safe buffers, there is no need for extra NMI enter/exit tracking. So this is also removed (which includes removing the config option CONFIG_PRINTK_NMI). And finally, there are a few places in the kernel that need to specify code blocks where all printk calls are to be deferred printing. Previously the NMI tracking API was being (mis)used for this purpose. This series introduces an official and explicit interface for such cases. (Note that all deferred printing will be removed anyway, once printing kthreads are introduced.) Changes since v3: - Remove safe context tracking in vprintk(). - Add safe context tracking for @console_owner usage since that is also a component of the printing code. - Refactor syslog_print() so that it is easier to understand and follow the locking logic. - Introduce printk_deferred_enter/exit functions to be used by code that needs to specify code block where all printk calls are to be deferred printing. John Ogness [0] https://lore.kernel.org/lkml/20210624111148.5190-1-john.ogness@linutronix.de John Ogness (6): lib/nmi_backtrace: explicitly serialize banner and regs printk: track/limit recursion printk: remove safe buffers printk: remove NMI tracking printk: convert @syslog_lock to mutex printk: syslog: close window between wait and read arch/arm/kernel/smp.c | 4 +- arch/powerpc/kernel/traps.c | 1 - arch/powerpc/kernel/watchdog.c | 5 - arch/powerpc/kexec/crash.c | 2 +- include/linux/hardirq.h | 2 - include/linux/printk.h | 41 ++-- init/Kconfig | 5 - kernel/kexec_core.c | 1 - kernel/panic.c | 3 - kernel/printk/internal.h | 25 --- kernel/printk/printk.c | 268 ++++++++++++++---------- kernel/printk/printk_safe.c | 364 +-------------------------------- kernel/trace/trace.c | 4 +- lib/nmi_backtrace.c | 13 +- 14 files changed, 194 insertions(+), 544 deletions(-) base-commit: 70333dec446292cd896cd051d2ebd6808b328949 -- 2.20.1 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec