From patchwork Thu Jul 15 19:33:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 12380811 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_Le_Go?= =?utf-8?q?ater?= , 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: , 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