Skip to contentSkip to conversation

v5.16.2-rt19

ANNOUNCE Sebastian Andrzej Siewior 1 participant 2 messages Jan 21, 2022

Subsystems (33)
lore
Share & tools
lore
#0 lore raw

Dear RT folks!

I'm pleased to announce the v5.16.2-rt19 patch set.

Changes since v5.16.2-rt18:

- Update the printk series. Patches by John Ogness.

- Redo the i2c patches introduced in the previous release to address other driver which look also broken.

Known issues
- netconsole triggers WARN.

- Valentin Schneider reported a few splats on ARM64, see
https://lkml.kernel.org/r/[email protected]

The delta patch against v5.16.2-rt18 is appended below and can be found here:

     https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/incr/patch-5.16.2-rt18-rt19.patch.xz

You can get this release via the git tree at:

    git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v5.16.2-rt19

The RT patch against v5.16.2 can be found here:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/older/patch-5.16.2-rt19.patch.xz

The split quilt queue is available at:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/older/patches-5.16.2-rt19.tar.xz

Sebastian

arch/arm/kernel/smp.c +2 -0
index bcf3222301c5e..cde5b6d8bac5d 100644
@@ -676,7 +676,9 @@ static void do_handle_IPI(int ipinr)
 		break;
 
 	case IPI_CPU_BACKTRACE:
+		printk_deferred_enter();
 		nmi_cpu_backtrace(get_irq_regs());
+		printk_deferred_exit();
 		break;
 
 	default:
arch/powerpc/include/asm/smp.h +0 -1
index 3d3c9ba50f442..007332a4a7325 100644
@@ -62,7 +62,6 @@ struct smp_ops_t {
 
 extern int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
 extern int smp_send_safe_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
-extern void smp_send_debugger_break_cpu(unsigned int cpu);
 extern void smp_send_debugger_break(void);
 extern void start_secondary_resume(void);
 extern void smp_generic_give_timebase(void);
arch/powerpc/kernel/kgdb.c +1 -9
index d57d374978627..bdee7262c080a 100644
@@ -120,19 +120,11 @@ int kgdb_skipexception(int exception, struct pt_regs *regs)
 
 static int kgdb_debugger_ipi(struct pt_regs *regs)
 {
-	int cpu = raw_smp_processor_id();
-
-	if (!kgdb_roundup_delay(cpu))
-		kgdb_nmicallback(cpu, regs);
+	kgdb_nmicallback(raw_smp_processor_id(), regs);
 	return 0;
 }
 
 #ifdef CONFIG_SMP
-void kgdb_roundup_cpu(unsigned int cpu)
-{
-	smp_send_debugger_break_cpu(cpu);
-}
-
 void kgdb_roundup_cpus(void)
 {
 	smp_send_debugger_break();
arch/powerpc/kernel/smp.c +0 -5
index 4ebf21908237c..c23ee842c4c33 100644
@@ -589,11 +589,6 @@ static void debugger_ipi_callback(struct pt_regs *regs)
 	debugger_ipi(regs);
 }
 
-void smp_send_debugger_break_cpu(unsigned int cpu)
-{
-	smp_send_nmi_ipi(cpu, debugger_ipi_callback, 1000000);
-}
-
 void smp_send_debugger_break(void)
 {
 	smp_send_nmi_ipi(NMI_IPI_ALL_OTHERS, debugger_ipi_callback, 1000000);
arch/powerpc/kexec/crash.c +3 -0
index d5359701f787f..22ceeeb705abd 100644
@@ -312,6 +312,9 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
 	unsigned int i;
 	int (*old_handler)(struct pt_regs *regs);
 
+	/* Avoid hardlocking with irresponsive CPU holding logbuf_lock */
+	printk_deferred_enter();
+
 	/*
 	 * This function is only called after the system
 	 * has panicked or is otherwise in a critical state.
arch/x86/kernel/dumpstack_32.c +1 -1
index 82cc3a7be6bd2..722fd712e1cf0 100644
@@ -141,7 +141,7 @@ int get_stack_info(unsigned long *stack, struct task_struct *task,
 	 */
 	if (visit_mask) {
 		if (*visit_mask & (1UL << info->type)) {
-			pr_warn_once("WARNING: stack recursion on stack type %d\n", info->type);
+			printk_deferred_once(KERN_WARNING "WARNING: stack recursion on stack type %d\n", info->type);
 			goto unknown;
 		}
 		*visit_mask |= 1UL << info->type;
arch/x86/kernel/dumpstack_64.c +1 -2
index 5f725b0ceb297..6c5defd6569a3 100644
@@ -207,8 +207,7 @@ int get_stack_info(unsigned long *stack, struct task_struct *task,
 	if (visit_mask) {
 		if (*visit_mask & (1UL << info->type)) {
 			if (task == current)
-				pr_warn_once("WARNING: stack recursion on stack type %d\n",
-					     info->type);
+				printk_deferred_once(KERN_WARNING "WARNING: stack recursion on stack type %d\n", info->type);
 			goto unknown;
 		}
 		*visit_mask |= 1UL << info->type;
arch/x86/kernel/i8259.c +2 -1
index 52af9a89ad478..15aefa3f3e18e 100644
@@ -207,7 +207,8 @@ static void mask_and_ack_8259A(struct irq_data *data)
 		 * lets ACK and report it. [once per IRQ]
 		 */
 		if (!(spurious_irq_mask & irqmask)) {
-			printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
+			printk_deferred(KERN_DEBUG
+			       "spurious 8259A interrupt: IRQ%d.\n", irq);
 			spurious_irq_mask |= irqmask;
 		}
 		atomic_inc(&irq_err_count);
arch/x86/kernel/kgdb.c +3 -6
index 37bd37cdf2b60..3a43a2dee6581 100644
@@ -502,12 +502,9 @@ static int kgdb_nmi_handler(unsigned int cmd, struct pt_regs *regs)
 		if (atomic_read(&kgdb_active) != -1) {
 			/* KGDB CPU roundup */
 			cpu = raw_smp_processor_id();
-
-			if (!kgdb_roundup_delay(cpu)) {
-				kgdb_nmicallback(cpu, regs);
-				set_bit(cpu, was_in_debug_nmi);
-				touch_nmi_watchdog();
-			}
+			kgdb_nmicallback(cpu, regs);
+			set_bit(cpu, was_in_debug_nmi);
+			touch_nmi_watchdog();
 
 			return NMI_HANDLED;
 		}
arch/x86/kernel/unwind_frame.c +9 -7
index 06080d9546e53..8e1c50c86e5db 100644
@@ -41,9 +41,9 @@ static void unwind_dump(struct unwind_state *state)
 
 	dumped_before = true;
 
-	printk("unwind stack type:%d next_sp:%p mask:0x%lx graph_idx:%d\n",
-	       state->stack_info.type, state->stack_info.next_sp,
-	       state->stack_mask, state->graph_idx);
+	printk_deferred("unwind stack type:%d next_sp:%p mask:0x%lx graph_idx:%d\n",
+			state->stack_info.type, state->stack_info.next_sp,
+			state->stack_mask, state->graph_idx);
 
 	for (sp = PTR_ALIGN(state->orig_sp, sizeof(long)); sp;
 	     sp = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
@@ -59,11 +59,13 @@ static void unwind_dump(struct unwind_state *state)
 
 			if (zero) {
 				if (!prev_zero)
-					printk("%p: %0*x ...\n", sp, BITS_PER_LONG/4, 0);
+					printk_deferred("%p: %0*x ...\n",
+							sp, BITS_PER_LONG/4, 0);
 				continue;
 			}
 
-			printk("%p: %0*lx (%pB)\n", sp, BITS_PER_LONG/4, word, (void *)word);
+			printk_deferred("%p: %0*lx (%pB)\n",
+					sp, BITS_PER_LONG/4, word, (void *)word);
 		}
 	}
 }
@@ -339,13 +341,13 @@ bool unwind_next_frame(struct unwind_state *state)
 		goto the_end;
 
 	if (state->regs) {
-		pr_warn_once(
+		printk_deferred_once(KERN_WARNING
 			"WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n",
 			state->regs, state->task->comm,
 			state->task->pid, next_bp);
 		unwind_dump(state);
 	} else {
-		pr_warn_once(
+		printk_deferred_once(KERN_WARNING
 			"WARNING: kernel stack frame pointer at %p in %s:%d has bad value %p\n",
 			state->bp, state->task->comm,
 			state->task->pid, next_bp);
arch/x86/kernel/unwind_orc.c +1 -1
index 9cf5bd20e48af..2de3c8c5eba9f 100644
@@ -9,7 +9,7 @@
 #include <asm/orc_lookup.h>
 
 #define orc_warn(fmt, ...) \
-	pr_warn_once("WARNING: " fmt, ##__VA_ARGS__)
+	printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
 
 #define orc_warn_current(args...)					\
 ({									\
drivers/char/random.c +3 -2
index d15f58be924e0..4b93ca6ecef94 100644
@@ -1566,8 +1566,9 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
 	print_once = true;
 #endif
 	if (__ratelimit(&unseeded_warning))
-		pr_notice("random: %s called from %pS with crng_init=%d\n",
-			  func_name, caller, crng_init);
+		printk_deferred(KERN_NOTICE "random: %s called from %pS "
+				"with crng_init=%d\n", func_name, caller,
+				crng_init);
 }
 
 /*
drivers/i2c/busses/i2c-cht-wc.c +2 -9
index 1cf68f85b2e11..8ccf0c928bb44 100644
@@ -99,15 +99,8 @@ static irqreturn_t cht_wc_i2c_adap_thread_handler(int id, void *data)
 	 * interrupt handler as well, so running the client irq handler from
 	 * this thread will cause things to lock up.
 	 */
-	if (reg & CHT_WC_EXTCHGRIRQ_CLIENT_IRQ) {
-		/*
-		 * generic_handle_irq expects local IRQs to be disabled
-		 * as normally it is called from interrupt context.
-		 */
-		local_irq_disable();
-		generic_handle_irq(adap->client_irq);
-		local_irq_enable();
-	}
+	if (reg & CHT_WC_EXTCHGRIRQ_CLIENT_IRQ)
+		generic_handle_irq_safe(adap->client_irq);
 
 	return IRQ_HANDLED;
 }
drivers/i2c/busses/i2c-rcar.c +3 -1
index 37e7bf4c14cea..fc13511f4562c 100644
@@ -1025,6 +1025,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	struct rcar_i2c_priv *priv;
 	struct i2c_adapter *adap;
 	struct device *dev = &pdev->dev;
+	unsigned long irqflags = 0;
 	irqreturn_t (*irqhandler)(int irq, void *ptr) = rcar_i2c_gen3_irq;
 	int ret;
 
@@ -1075,6 +1076,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
 
 	if (priv->devtype < I2C_RCAR_GEN3) {
+		irqflags |= IRQF_NO_THREAD;
 		irqhandler = rcar_i2c_gen2_irq;
 	}
 
@@ -1100,7 +1102,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto out_pm_disable;
 	priv->irq = ret;
-	ret = devm_request_irq(dev, priv->irq, irqhandler, 0, dev_name(dev), priv);
+	ret = devm_request_irq(dev, priv->irq, irqhandler, irqflags, dev_name(dev), priv);
 	if (ret < 0) {
 		dev_err(dev, "cannot get irq %d\n", priv->irq);
 		goto out_pm_disable;
drivers/i2c/i2c-core-base.c +1 -4
index 30e93651d5b6b..698f3e928fcf7 100644
@@ -1423,10 +1423,7 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr)
 	if (irq <= 0)
 		return -ENXIO;
 
-	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
-		generic_handle_irq(irq);
-	else
-		handle_nested_irq(irq);
+	generic_handle_irq_safe(irq);
 
 	return 0;
 }
drivers/mfd/ezx-pcap.c +1 -3
index 70fa18b04ad2b..b14d3f98e1ebd 100644
@@ -193,13 +193,11 @@ static void pcap_isr_work(struct work_struct *work)
 		ezx_pcap_write(pcap, PCAP_REG_MSR, isr | msr);
 		ezx_pcap_write(pcap, PCAP_REG_ISR, isr);
 
-		local_irq_disable();
 		service = isr & ~msr;
 		for (irq = pcap->irq_base; service; service >>= 1, irq++) {
 			if (service & 1)
-				generic_handle_irq(irq);
+				generic_handle_irq_safe(irq);
 		}
-		local_irq_enable();
 		ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr);
 	} while (gpio_get_value(pdata->gpio));
 }
drivers/misc/hi6421v600-irq.c +3 -3
index 1c763796cf1fa..caa3de37698b0 100644
@@ -117,8 +117,8 @@ static irqreturn_t hi6421v600_irq_handler(int irq, void *__priv)
 			 * If both powerkey down and up IRQs are received,
 			 * handle them at the right order
 			 */
-			generic_handle_irq(priv->irqs[POWERKEY_DOWN]);
-			generic_handle_irq(priv->irqs[POWERKEY_UP]);
+			generic_handle_irq_safe(priv->irqs[POWERKEY_DOWN]);
+			generic_handle_irq_safe(priv->irqs[POWERKEY_UP]);
 			pending &= ~HISI_IRQ_POWERKEY_UP_DOWN;
 		}
 
@@ -126,7 +126,7 @@ static irqreturn_t hi6421v600_irq_handler(int irq, void *__priv)
 			continue;
 
 		for_each_set_bit(offset, &pending, BITS_PER_BYTE) {
-			generic_handle_irq(priv->irqs[offset + i * BITS_PER_BYTE]);
+			generic_handle_irq_safe(priv->irqs[offset + i * BITS_PER_BYTE]);
 		}
 	}
 
drivers/net/usb/lan78xx.c +2 -5
index 075f8abde5cd7..6cf28f6881906 100644
@@ -1367,11 +1367,8 @@ static void lan78xx_status(struct lan78xx_net *dev, struct urb *urb)
 		netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata);
 		lan78xx_defer_kevent(dev, EVENT_LINK_RESET);
 
-		if (dev->domain_data.phyirq > 0) {
-			local_irq_disable();
-			generic_handle_irq(dev->domain_data.phyirq);
-			local_irq_enable();
-		}
+		if (dev->domain_data.phyirq > 0)
+			generic_handle_irq_safe(dev->domain_data.phyirq);
 	} else {
 		netdev_warn(dev->net,
 			    "unexpected interrupt: 0x%08x\n", intdata);
drivers/staging/greybus/gpio.c +1 -4
index 7e6347fe93f99..8a7cf1d0e9688 100644
@@ -391,10 +391,7 @@ static int gb_gpio_request_handler(struct gb_operation *op)
 		return -EINVAL;
 	}
 
-	local_irq_disable();
-	ret = generic_handle_irq(irq);
-	local_irq_enable();
-
+	ret = generic_handle_irq_safe(irq);
 	if (ret)
 		dev_err(dev, "failed to invoke irq handler\n");
 
drivers/tty/serial/8250/8250.h +4 -4
index 2321d02e9b7a9..7b1a88934d6ff 100644
@@ -142,12 +142,12 @@ static inline void serial8250_set_IER(struct uart_8250_port *up,
 	is_console = uart_console(port);
 
 	if (is_console)
-		console_atomic_lock(flags);
+		printk_cpu_sync_get_irqsave(flags);
 
 	serial_out(up, UART_IER, ier);
 
 	if (is_console)
-		console_atomic_unlock(flags);
+		printk_cpu_sync_put_irqrestore(flags);
 }
 
 static inline unsigned char serial8250_clear_IER(struct uart_8250_port *up)
@@ -164,13 +164,13 @@ static inline unsigned char serial8250_clear_IER(struct uart_8250_port *up)
 		clearval = UART_IER_UUE;
 
 	if (is_console)
-		console_atomic_lock(flags);
+		printk_cpu_sync_get_irqsave(flags);
 
 	prior = serial_port_in(port, UART_IER);
 	serial_port_out(port, UART_IER, clearval);
 
 	if (is_console)
-		console_atomic_unlock(flags);
+		printk_cpu_sync_put_irqrestore(flags);
 
 	return prior;
 }
drivers/tty/serial/8250/8250_fsl.c +2 -2
index ea06cb67cf58f..d9b651290e1c7 100644
@@ -63,10 +63,10 @@ int fsl8250_handle_irq(struct uart_port *port)
 		is_console = uart_console(port);
 
 		if (is_console)
-			console_atomic_lock(flags);
+			printk_cpu_sync_get_irqsave(flags);
 		up->ier = port->serial_in(port, UART_IER);
 		if (is_console)
-			console_atomic_unlock(flags);
+			printk_cpu_sync_put_irqrestore(flags);
 
 		if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) {
 			port->ops->stop_rx(port);
drivers/tty/serial/8250/8250_ingenic.c +2 -2
index 8122645ab05c9..061d8e4072c65 100644
@@ -171,10 +171,10 @@ static void ingenic_uart_serial_out(struct uart_port *p, int offset, int value)
 		 */
 		is_console = uart_console(p);
 		if (is_console)
-			console_atomic_lock(flags);
+			printk_cpu_sync_get_irqsave(flags);
 		ier = p->serial_in(p, UART_IER);
 		if (is_console)
-			console_atomic_unlock(flags);
+			printk_cpu_sync_put_irqrestore(flags);
 
 		if (ier & UART_IER_MSI)
 			value |= UART_MCR_MDCE | UART_MCR_FCM;
drivers/tty/serial/8250/8250_mtk.c +4 -4
index 9af18b5d8296f..e5032e5abd8ea 100644
@@ -226,13 +226,13 @@ static void mtk8250_disable_intrs(struct uart_8250_port *up, int mask)
 	is_console = uart_console(port);
 
 	if (is_console)
-		console_atomic_lock(flags);
+		printk_cpu_sync_get_irqsave(flags);
 
 	ier = serial_in(up, UART_IER);
 	serial_out(up, UART_IER, ier & (~mask));
 
 	if (is_console)
-		console_atomic_unlock(flags);
+		printk_cpu_sync_put_irqrestore(flags);
 }
 
 static void mtk8250_enable_intrs(struct uart_8250_port *up, int mask)
@@ -242,13 +242,13 @@ static void mtk8250_enable_intrs(struct uart_8250_port *up, int mask)
 	unsigned int ier;
 
 	if (uart_console(port))
-		console_atomic_lock(flags);
+		printk_cpu_sync_get_irqsave(flags);
 
 	ier = serial_in(up, UART_IER);
 	serial_out(up, UART_IER, ier | mask);
 
 	if (uart_console(port))
-		console_atomic_unlock(flags);
+		printk_cpu_sync_put_irqrestore(flags);
 }
 
 static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
drivers/tty/serial/8250/8250_port.c +4 -4
index e57282bad6ea1..49883a0a58a5b 100644
@@ -3304,9 +3304,9 @@ static void serial8250_console_putchar(struct uart_port *port, int ch)
 
 	wait_for_xmitr(up, UART_LSR_THRE);
 
-	console_atomic_lock(flags);
+	printk_cpu_sync_get_irqsave(flags);
 	serial8250_console_putchar_locked(port, ch);
-	console_atomic_unlock(flags);
+	printk_cpu_sync_put_irqrestore(flags);
 }
 
 /*
@@ -3337,7 +3337,7 @@ void serial8250_console_write_atomic(struct uart_8250_port *up,
 	unsigned long flags;
 	unsigned int ier;
 
-	console_atomic_lock(flags);
+	printk_cpu_sync_get_irqsave(flags);
 
 	touch_nmi_watchdog();
 
@@ -3353,7 +3353,7 @@ void serial8250_console_write_atomic(struct uart_8250_port *up,
 	wait_for_xmitr(up, BOTH_EMPTY);
 	serial8250_set_IER(up, ier);
 
-	console_atomic_unlock(flags);
+	printk_cpu_sync_put_irqrestore(flags);
 }
 
 /*
drivers/tty/serial/8250/Kconfig +1 -0
index 8cd11aa63ed57..9b6695bdafc98 100644
@@ -9,6 +9,7 @@ config SERIAL_8250
 	depends on !S390
 	select SERIAL_CORE
 	select SERIAL_MCTRL_GPIO if GPIOLIB
+	select HAVE_ATOMIC_CONSOLE
 	help
 	  This selects whether you want to include the driver for the standard
 	  serial ports.  The standard answer is Y.  People who might say N
drivers/tty/vt/vt.c +1 -1
index 7359c3e80d63e..ab4712cc93270 100644
@@ -3161,7 +3161,7 @@ static struct console vt_console_driver = {
 	.write		= vt_console_print,
 	.device		= vt_console_device,
 	.unblank	= unblank_screen,
-	.flags		= CON_PRINTBUFFER,
+	.flags		= CON_PRINTBUFFER|CON_MIGHT_SLEEP,
 	.index		= -1,
 };
 #endif
include/linux/console.h +34 -18

85 lines not on this page · raw message

include/linux/irqdesc.h +1 -0
index 93d270ca0c567..a77584593f7d1 100644
@@ -160,6 +160,7 @@ static inline void generic_handle_irq_desc(struct irq_desc *desc)
 
 int handle_irq_desc(struct irq_desc *desc);
 int generic_handle_irq(unsigned int irq);
+int generic_handle_irq_safe(unsigned int irq);
 
 #ifdef CONFIG_IRQ_DOMAIN
 /*
include/linux/kgdb.h +0 -3
index 9bca0d98db5a1..258cdde8d356b 100644
@@ -212,8 +212,6 @@ extern void kgdb_call_nmi_hook(void *ignored);
  */
 extern void kgdb_roundup_cpus(void);
 
-extern void kgdb_roundup_cpu(unsigned int cpu);
-
 /**
  *	kgdb_arch_set_pc - Generic call back to the program counter
  *	@regs: Current &struct pt_regs.
@@ -367,6 +365,5 @@ extern void kgdb_free_init_mem(void);
 #define dbg_late_init()
 static inline void kgdb_panic(const char *msg) {}
 static inline void kgdb_free_init_mem(void) { }
-static inline void kgdb_roundup_cpu(unsigned int cpu) {}
 #endif /* ! CONFIG_KGDB */
 #endif /* _KGDB_H_ */
include/linux/printk.h +56 -49

163 lines not on this page · raw message

include/linux/suspend.h +8 -2
index 79b6933ef8a03..8af13ba60c7e4 100644
@@ -550,17 +550,23 @@ static inline void unlock_system_sleep(void) {}
 #ifdef CONFIG_PM_SLEEP_DEBUG
 extern bool pm_print_times_enabled;
 extern bool pm_debug_messages_on;
-extern __printf(1, 2) void pm_pr_dbg(const char *fmt, ...);
+extern __printf(2, 3) void __pm_pr_dbg(bool defer, const char *fmt, ...);
 #else
 #define pm_print_times_enabled	(false)
 #define pm_debug_messages_on	(false)
 
 #include <linux/printk.h>
 
-#define pm_pr_dbg(fmt, ...) \
+#define __pm_pr_dbg(defer, fmt, ...) \
 	no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
 #endif
 
+#define pm_pr_dbg(fmt, ...) \
+	__pm_pr_dbg(false, fmt, ##__VA_ARGS__)
+
+#define pm_deferred_pr_dbg(fmt, ...) \
+	__pm_pr_dbg(true, fmt, ##__VA_ARGS__)
+
 #ifdef CONFIG_PM_AUTOSLEEP
 
 /* kernel/power/autosleep.c */
init/Kconfig +4 -0
index 4b7bac10c72d3..732dbb61ec7e2 100644
@@ -1542,6 +1542,10 @@ config PRINTK
 	  very difficult to diagnose system problems, saying N here is
 	  strongly discouraged.
 
+config HAVE_ATOMIC_CONSOLE
+	bool
+	default n
+
 config BUG
 	bool "BUG() support" if EXPERT
 	default y
kernel/debug/debug_core.c +19 -26

61 lines not on this page · raw message

kernel/debug/kdb/kdb_io.c +12 -6
index 539a2f0dc89d9..6735ac36b7187 100644
@@ -559,17 +559,23 @@ static void kdb_msg_write(const char *msg, int msg_len)
 		cp++;
 	}
 
-	/* mirror output on atomic consoles */
 	for_each_console(c) {
 		if (!(c->flags & CON_ENABLED))
 			continue;
 		if (c == dbg_io_ops->cons)
 			continue;
-
-		if (!c->write_atomic)
-			continue;
-		c->write_atomic(c, msg, msg_len);
-
+		/*
+		 * Set oops_in_progress to encourage the console drivers to
+		 * disregard their internal spin locks: in the current calling
+		 * context the risk of deadlock is a bigger problem than risks
+		 * due to re-entering the console driver. We operate directly on
+		 * oops_in_progress rather than using bust_spinlocks() because
+		 * the calls bust_spinlocks() makes on exit are not appropriate
+		 * for this calling context.
+		 */
+		++oops_in_progress;
+		c->write(c, msg, msg_len);
+		--oops_in_progress;
 		touch_nmi_watchdog();
 	}
 }
kernel/irq/irqdesc.c +21 -0
index 2267e6527db3c..97223df2f460e 100644
@@ -662,6 +662,27 @@ int generic_handle_irq(unsigned int irq)
 }
 EXPORT_SYMBOL_GPL(generic_handle_irq);
 
+/**
+ * generic_handle_irq_safe - Invoke the handler for a particular irq
+ * @irq:	The irq number to handle
+ *
+ * Returns:	0 on success, or -EINVAL if conversion has failed
+ *
+ * This function must be called either from an IRQ context with irq regs
+ * initialized or with care from any context.
+ */
+int generic_handle_irq_safe(unsigned int irq)
+{
+	unsigned long flags;
+	int ret;
+
+	local_irq_save(flags);
+	ret = handle_irq_desc(irq_to_desc(irq));
+	local_irq_restore(flags);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(generic_handle_irq_safe);
+
 #ifdef CONFIG_IRQ_DOMAIN
 /**
  * generic_handle_domain_irq - Invoke the handler for a HW irq belonging
kernel/panic.c +16 -18
index f4c7c77595bd2..556665ef11522 100644
@@ -178,28 +178,12 @@ static void panic_print_sys_info(void)
 void panic(const char *fmt, ...)
 {
 	static char buf[1024];
-	va_list args2;
 	va_list args;
 	long i, i_next = 0, len;
 	int state = 0;
 	int old_cpu, this_cpu;
 	bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
 
-	console_verbose();
-	pr_emerg("Kernel panic - not syncing:\n");
-	va_start(args2, fmt);
-	va_copy(args, args2);
-	vprintk(fmt, args2);
-	va_end(args2);
-#ifdef CONFIG_DEBUG_BUGVERBOSE
-	/*
-	 * Avoid nested stack-dumping if a panic occurs during oops processing
-	 */
-	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
-		dump_stack();
-#endif
-	pr_flush(1000, true);
-
 	/*
 	 * Disable local interrupts. This will prevent panic_smp_self_stop
 	 * from deadlocking the first cpu that invokes the panic, since
@@ -230,13 +214,23 @@ void panic(const char *fmt, ...)
 	if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu)
 		panic_smp_self_stop();
 
-	bust_spinlocks(1);
+	console_verbose();
+	va_start(args, fmt);
 	len = vscnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 
 	if (len && buf[len - 1] == '\n')
 		buf[len - 1] = '\0';
 
+	pr_emerg("Kernel panic - not syncing: %s\n", buf);
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+	/*
+	 * Avoid nested stack-dumping if a panic occurs during oops processing
+	 */
+	if (!test_taint(TAINT_DIE) && oops_in_progress <= 1)
+		dump_stack();
+#endif
+
 	/*
 	 * If kgdb is enabled, give it a chance to run before we stop all
 	 * the other CPUs or else we won't be able to debug processes left
@@ -244,6 +238,11 @@ void panic(const char *fmt, ...)
 	 */
 	kgdb_panic(buf);
 
+	/* Use atomic consoles to dump the kernel log. */
+	console_flush_on_panic(CONSOLE_ATOMIC_FLUSH_PENDING);
+
+	bust_spinlocks(1);
+
 	/*
 	 * If we have crashed and we have a crash kernel loaded let it handle
 	 * everything else.
@@ -541,7 +540,6 @@ void oops_enter(void)
 static void print_oops_end_marker(void)
 {
 	pr_warn("---[ end trace %016llx ]---\n", 0ULL);
-	pr_flush(1000, true);
 }
 
 /*
kernel/power/main.c +7 -3
index eaa725ca079cb..44169f3081fdc 100644
@@ -543,13 +543,14 @@ static int __init pm_debug_messages_setup(char *str)
 __setup("pm_debug_messages", pm_debug_messages_setup);
 
 /**
- * pm_pr_dbg - Print a suspend debug message to the kernel log.
+ * __pm_pr_dbg - Print a suspend debug message to the kernel log.
+ * @defer: Whether or not to use printk_deferred() to print the message.
  * @fmt: Message format.
  *
  * The message will be emitted if enabled through the pm_debug_messages
  * sysfs attribute.
  */
-void pm_pr_dbg(const char *fmt, ...)
+void __pm_pr_dbg(bool defer, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -562,7 +563,10 @@ void pm_pr_dbg(const char *fmt, ...)
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	printk(KERN_DEBUG "PM: %pV", &vaf);
+	if (defer)
+		printk_deferred(KERN_DEBUG "PM: %pV", &vaf);
+	else
+		printk(KERN_DEBUG "PM: %pV", &vaf);
 
 	va_end(args);
 }
kernel/printk/Makefile +1 -0
index bc6b856a0ff41..d118739874c0d 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-y	= printk.o
+obj-$(CONFIG_PRINTK)	+= printk_safe.o
 obj-$(CONFIG_A11Y_BRAILLE_CONSOLE)	+= braille.o
 obj-$(CONFIG_PRINTK)	+= printk_ringbuffer.o
 obj-$(CONFIG_PRINTK_INDEX)	+= index.o
kernel/printk/internal.h +36 -0
index de8ab059dd961..9f3ed2fdb7211 100644
@@ -2,6 +2,7 @@
 /*
  * internal.h - printk internal definitions
  */
+#include <linux/percpu.h>
 
 #ifdef CONFIG_PRINTK
 
@@ -11,6 +12,41 @@ enum printk_info_flags {
 	LOG_CONT	= 8,	/* text is a fragment of a continuation line */
 };
 
+__printf(4, 0)
+int vprintk_store(int facility, int level,
+		  const struct dev_printk_info *dev_info,
+		  const char *fmt, va_list args);
+
+__printf(1, 0) int vprintk_default(const char *fmt, va_list args);
+__printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
+
+bool printk_percpu_data_ready(void);
+
+#define printk_safe_enter_irqsave(flags)	\
+	do {					\
+		local_irq_save(flags);		\
+		__printk_safe_enter();		\
+	} while (0)
+
+#define printk_safe_exit_irqrestore(flags)	\
+	do {					\
+		__printk_safe_exit();		\
+		local_irq_restore(flags);	\
+	} while (0)
+
+void defer_console_output(void);
+
 u16 printk_parse_prefix(const char *text, int *level,
 			enum printk_info_flags *flags);
+#else
+
+/*
+ * In !PRINTK builds we still export console_sem
+ * semaphore and some of console functions (console_unlock()/etc.), so
+ * printk-safe must preserve the existing local IRQ guarantees.
+ */
+#define printk_safe_enter_irqsave(flags) local_irq_save(flags)
+#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
+
+static inline bool printk_percpu_data_ready(void) { return false; }
 #endif /* CONFIG_PRINTK */
kernel/printk/printk.c +1144 -539

2,039 lines not on this page · raw message

kernel/printk/printk_safe.c new file +52 -0

52 lines not on this page · raw message

kernel/sched/core.c +5 -4
index c36ba56de8f75..04165fa6ff25a 100644

Lines of this file are not shown. View the raw message.

kernel/sched/deadline.c +1 -1
index 65d4cc198e44c..d2c072b0ef01f 100644

Lines of this file are not shown. View the raw message.

kernel/sched/psi.c +7 -7
index ab54b2012469f..1652f2bb54b79 100644

Lines of this file are not shown. View the raw message.

kernel/sched/rt.c +1 -1
index 7a5948eeb57b9..b48baaba2fc2e 100644

Lines of this file are not shown. View the raw message.

kernel/sched/stats.h +1 -1
index 429182f6e7b0f..cfb0893a83d45 100644

Lines of this file are not shown. View the raw message.

kernel/time/clockevents.c +6 -3
index 00fc43605c6b1..003ccf338d201 100644

Lines of this file are not shown. View the raw message.

kernel/time/ntp.c +9 -5
index 829d7797811fb..406dccb79c2b6 100644

Lines of this file are not shown. View the raw message.

kernel/time/timekeeping.c +15 -15
index 5714e8b281eeb..dcdcb85121e40 100644

Lines of this file are not shown. View the raw message.

kernel/time/timekeeping_debug.c +1 -1
index 149cc4b08d8eb..b73e8850e58d9 100644

Lines of this file are not shown. View the raw message.

kernel/workqueue.c +4 -0
index 51bbd54a0485d..c55004cbf48ee 100644

Lines of this file are not shown. View the raw message.

lib/bug.c +0 -1
index 03a87df69ed23..45a0584f65417 100644

Lines of this file are not shown. View the raw message.

lib/dump_stack.c +2 -2
index 6e8ae42c7e273..83471e81501a7 100644

Lines of this file are not shown. View the raw message.

lib/nmi_backtrace.c +2 -2
index 06410209197ae..d01aec6ae15c8 100644

Lines of this file are not shown. View the raw message.

lib/ratelimit.c +3 -1
index 524cf65dce53c..e01a93f46f833 100644

Lines of this file are not shown. View the raw message.

localversion-rt +1 -1
index 9e7cd66d9f44f..483ad771f201a 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 14 lines · To Thomas Gleixner

Dear RT folks!

I'm pleased to announce the v5.16.2-rt19 patch set.

Changes since v5.16.2-rt18:

- Update the printk series. Patches by John Ogness.

- Redo the i2c patches introduced in the previous release to address other driver which look also broken.

Known issues
- netconsole triggers WARN.

Quoted 6 lines

- Valentin Schneider reported a few splats on ARM64, see
https://lkml.kernel.org/r/[email protected]

The delta patch against v5.16.2-rt18 is appended below and can be found here:

     https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/incr/patch-5.16.2-rt18-rt19.patch.xz

The diff got too big and and the announcement didn't make it to the list. Here is the mail without the incremental diff which can been viewed at
https://git.kernel.org/rt/linux-rt-devel/d/v5.16.2-rt19/v5.16.2-rt18

Quoted 11 lines

You can get this release via the git tree at:

    git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v5.16.2-rt19

The RT patch against v5.16.2 can be found here:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/older/patch-5.16.2-rt19.patch.xz

The split quilt queue is available at:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.16/older/patches-5.16.2-rt19.tar.xz

Sebastian