Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1876206lqb; Sun, 26 May 2024 23:38:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWawCkZw72VsJn2e0QbhQw4o/IScrB4JJ9+7hNgWbFw5txTHnySePe39U+hPdjvW2UEWHrsM1j3eHKxQcwX97PxGZqBWKIWUPhGc3KzqQ== X-Google-Smtp-Source: AGHT+IFP7tOnZIjDhyi/KnSvO2kXLgPBzYf502YdXXAQsv4sG9AJRvLo/90QoLiJzfM4VZbZkXYn X-Received: by 2002:a05:6358:3211:b0:196:c48b:cb2d with SMTP id e5c5f4694b2df-197e566da71mr715217755d.27.1716791919586; Sun, 26 May 2024 23:38:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716791919; cv=pass; d=google.com; s=arc-20160816; b=ZvQpeN7WNyyXLeMea2S4MZzu58ry2tF4/+XIdWYHzpzU3qBryZainKrYrUWxenaltL ypIyMNp5FL+ExcsfVXO6nfqwIK6E+Z+7Ok+qbS1hPj/J4101dRQVv4DVTI+bnfqWwe4/ BOkw4a4oWZDd/CEJhA1WJpXFS/yOLs7zYps5LWojPImKoO6clsgHx+WfErPalWNu3arW 7y1YVLK7ox0zWrjCES8lr1EBCn3Y0+0y/k4Ydbgeuw80z9koEnMgyyyTHqbOKlCr4CcL OeJmIzVcf0aicIozlyF8PlZLtQ/DJWVHCM9m7D91REbESu3FVZ2/Z98/lf0+svbPTXHT O6OQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :dkim-signature:dkim-signature:from; bh=AnQvw5hbKGPn5hbjOpZYiGZWbU7Q2jFjvPJ2T+zTaAs=; fh=Jwn4cjyRFzN0eop2FXBX6T+6q1wVpNoCIjKrxNlpA8Q=; b=rphq8lbyHX5HePXMUcGO53ltVc16Sd1gMpvkikkVgGbfy1ALCS3fZaC72sEv7tbZMZ Az23rDqcoDLbXbEDxJUli71y4omUGUzgHf+pxg6xIyXpGU/K3+KiPDhCUz7eKZQPn1/o XXsGoM+4rTYfWglO1p6q4GtUCuzEsf+co+BnHA/PXb6t0ueFGPb5+5qYPYpaNpwBJYhs vL3GAaXjpGpy4JlZBzOkqVEs585roIC6xlGF24TcyXOYfa+jfdWye6ZK3X9nW6Isf8tV Gu/PQaq8dVGCs6lnk2PwFzjdFoZGRFzOfQ7ZCm/IxISZIIOLdKonJwugPz7WHnaF2xlm q8zA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bgsDt2AV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-682288e65a2si5727814a12.447.2024.05.26.23.38.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 23:38:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bgsDt2AV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-190076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2EE4E281328 for ; Mon, 27 May 2024 06:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7AF817C8D; Mon, 27 May 2024 06:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bgsDt2AV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Nzrh18+g" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5FBB2030B; Mon, 27 May 2024 06:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791900; cv=none; b=LlDVSEh5FdDKd4eVvSHKRpzhX135ZnQ6+PHb5xSU72x/OlYiJo6Lz4njCUfb26GsQY307GxieMIVpDKdrVFSaNIOZcr85peSF9676GZVZx9MKd0CLzzBjQ08cHV5pudfOe63xC5Ismgm82HWACBFpvZUlZQABBZH+FgK0t1EtNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791900; c=relaxed/simple; bh=HAyKOh+NXTadzGoMJcYVzr6NcwccoLiWOrt7fHRczrU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=iE/8koUpyqhwS1TdfMVkO9msHTt/f8nq5Uqps90OfSkMmyhmpVpmiEpqAdItpxJ+vcNR3oleUeMxteA9R92EMnobM/iE5HxOy5giw38/qA4mT698ueBk/58rEgAcbBRnChiCDtLGdcONX6jdS6KdEsu7itWm3BpT58RF5lFz0Sk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bgsDt2AV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Nzrh18+g; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716791896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AnQvw5hbKGPn5hbjOpZYiGZWbU7Q2jFjvPJ2T+zTaAs=; b=bgsDt2AVFR9ZN6vU2R2BMA2SE44w8iH215AjE26rORTHWntjLadAaajvkQzQjvEz7Vrjc9 0H/x2AsgefwmRmsfmuNFiaAJ88Bp1MeREOHXPTroQdvLoO4Dlzgf1SMekOoj310DWhC11a jEUxQ7RqYcjox2mgbB29rpCyWB6E7DYG+T/q64SFbvSle3xcDhAzsLATZd81WCMkdurQPH nijiHwp3aV1fCkwUpIKZXZF9+x0YbyNoZFsPYIXhVTdfLVVDCo9NRQkv5yRQKqi8+CB2Tv MBawCdz+/NIHRvYZ8meucLv6WLcPWKUhGskYAppQkH3KVjdVtdTIbne2FjucTw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716791896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AnQvw5hbKGPn5hbjOpZYiGZWbU7Q2jFjvPJ2T+zTaAs=; b=Nzrh18+gGFfABUMUXKLvVSYmeHG/Yd23orl7BtSdGKuLXKDjQ8udE+DHKMfZ/ZxtnBu0Lj fMqi4uwH7LWWecDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Miguel Ojeda , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, Russell King , Tony Lindgren , Andy Shevchenko , Florian Fainelli , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , Linus Walleij , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Fabio Estevam , Lino Sanfilippo , Christophe JAILLET , Arnd Bergmann , Andrew Morton , Uros Bizjak , Lukas Wunner , Kefeng Wang , Ingo Molnar , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , rcu@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long Subject: [PATCH printk v6 00/30] wire up write_atomic() printing Date: Mon, 27 May 2024 08:43:19 +0206 Message-Id: <20240527063749.391035-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, This is v6 of a series to wire up the nbcon consoles so that they actually perform printing using their write_atomic() callback. v5 is here [0]. For information about the motivation of the atomic consoles, please read the cover letter of v1 [1]. The main focus of this series: - For nbcon consoles, always call write_atomic() directly from printk() caller context for the panic CPU. - For nbcon consoles, call write_atomic() when unlocking the console lock. - Only perform the console lock/unlock dance if legacy or boot consoles are registered. - For legacy consoles, if nbcon consoles are registered, do not attempt to print from printk() caller context for the panic CPU until nbcon consoles have had a chance to print the most significant messages. - Mark emergency sections. In these sections printk() calls will only store the messages. Upon exiting the emergency section, nbcon consoles are flushed directly. If legacy consoles cannot be flushed safely, an irq_work is triggered to do the legacy console flushing. This series does _not_ include threaded printing or nbcon drivers. Those features will be added in separate follow-up series. Note: With this series, a system with _only_ nbcon consoles registered will not perform console printing unless the console lock or nbcon port lock are used or on panic. This is on purpose. When nbcon kthreads are introduced, they will fill the gaps. The changes since v5: - In struct console, rename @nbcon_driver_ctxt to @nbcon_device_ctxt. - Rename nbcon_driver_try_acquire() to nbcon_device_try_acquire(). - Rename nbcon_driver_release() to nbcon_device_release(). - Implement a helper function is_printk_deferred() for use in nbcon_cpu_emergency_exit(), nbcon_cpu_emergency_flush(), vprintk(). - In nbcon_cpu_emergency_exit(), for legacy consoles, try to flush directly if safe. If legacy flushing directly was successful, do not trigger the irq_work. - In nbcon_cpu_emergency_exit(), do not decrement @cpu_emergency_nesting if it is zero (and WARN_ON_ONCE in this case). - For register_console() and unregister_console_locked(), use a local variable @use_device_lock to track if locking is used so that the compiler knows that the lock and unlock match. - For synchronize_rcu_expedited_wait(), move the nbcon_cpu_emergency_flush() after dump_cpu_task(). - Refactor nbcon_atomic_flush_pending_con() as suggested by pmladek. No functional change. - Update various comments as suggested by pmladek. - In nbcon_device_try_acquire(), add missing kerneldoc for the return value. John Ogness [0] https://lore.kernel.org/lkml/20240502213839.376636-1-john.ogness@linutronix.de [1] https://lore.kernel.org/lkml/20230302195618.156940-1-john.ogness@linutronix.de John Ogness (25): printk: Add notation to console_srcu locking printk: nbcon: Remove return value for write_atomic() printk: nbcon: Add detailed doc for write_atomic() printk: nbcon: Add callbacks to synchronize with driver printk: nbcon: Use driver synchronization while (un)registering serial: core: Provide low-level functions to lock port serial: core: Introduce wrapper to set @uart_port->cons console: Improve console_srcu_read_flags() comments nbcon: Add API to acquire context for non-printing operations serial: core: Implement processing in port->lock wrapper printk: nbcon: Do not rely on proxy headers printk: nbcon: Fix kerneldoc for enums printk: Make console_is_usable() available to nbcon printk: Let console_is_usable() handle nbcon printk: Add @flags argument for console_is_usable() printk: nbcon: Add helper to assign priority based on CPU state printk: Track registered boot consoles printk: nbcon: Use nbcon consoles in console_flush_all() printk: nbcon: Add unsafe flushing on panic printk: Avoid console_lock dance if no legacy or boot consoles printk: Track nbcon consoles printk: Coordinate direct printing in panic panic: Mark emergency section in oops rcu: Mark emergency sections in rcu stalls lockdep: Mark emergency sections in lockdep splats Petr Mladek (1): printk: Properly deal with nbcon consoles on seq init Sebastian Andrzej Siewior (1): printk: Check printk_deferred_enter()/_exit() usage Thomas Gleixner (3): printk: nbcon: Provide function to flush using write_atomic() printk: nbcon: Implement emergency sections panic: Mark emergency section in warn drivers/tty/serial/8250/8250_core.c | 6 +- drivers/tty/serial/amba-pl011.c | 2 +- drivers/tty/serial/serial_core.c | 16 +- include/linux/console.h | 116 ++++++- include/linux/printk.h | 33 +- include/linux/serial_core.h | 117 ++++++- kernel/locking/lockdep.c | 84 ++++- kernel/panic.c | 9 + kernel/printk/internal.h | 73 +++- kernel/printk/nbcon.c | 506 +++++++++++++++++++++++++++- kernel/printk/printk.c | 307 +++++++++++++---- kernel/printk/printk_ringbuffer.h | 2 + kernel/printk/printk_safe.c | 23 +- kernel/rcu/tree_exp.h | 9 + kernel/rcu/tree_stall.h | 11 + 15 files changed, 1181 insertions(+), 133 deletions(-) base-commit: 596ffa476e201ecbf7ea024f1b59d4f28e91060c -- 2.39.2