From 857c5229514affff639badafb10269b9e2e08fad Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 24 Sep 2021 18:12:45 +0200
Subject: [PATCH 031/158] x86/softirq: Disable softirq stacks on PREEMPT_RT

PREEMPT_RT preempts softirqs and the current implementation avoids
do_softirq_own_stack() and only uses __do_softirq().

Disable the unused softirqs stacks on PREEMPT_RT to safe some memory and
ensure that do_softirq_own_stack() is not used which is not expected.

[bigeasy: commit description.]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20210924161245.2357247-1-bigeasy@linutronix.de
---
 arch/x86/include/asm/irq_stack.h | 3 +++
 arch/x86/kernel/irq_32.c         | 2 ++
 2 files changed, 5 insertions(+)

Index: linux-5.15.19-rt29/arch/x86/include/asm/irq_stack.h
===================================================================
@ linux-5.15.19-rt29/arch/x86/include/asm/irq_stack.h:204 @
 			      IRQ_CONSTRAINTS, regs, vector);		\
 }
 
+#ifndef CONFIG_PREEMPT_RT
 /*
  * Macro to invoke __do_softirq on the irq stack. This is only called from
  * task context when bottom halves are about to be reenabled and soft
@ linux-5.15.19-rt29/arch/x86/include/asm/irq_stack.h:218 @
 	__this_cpu_write(hardirq_stack_inuse, false);			\
 }
 
+#endif
+
 #else /* CONFIG_X86_64 */
 /* System vector handlers always run on the stack they interrupted. */
 #define run_sysvec_on_irqstack_cond(func, regs)				\
Index: linux-5.15.19-rt29/arch/x86/kernel/irq_32.c
===================================================================
--- linux-5.15.19-rt29.orig/arch/x86/kernel/irq_32.c
+++ linux-5.15.19-rt29/arch/x86/kernel/irq_32.c
@ linux-5.15.19-rt29/arch/x86/include/asm/irq_stack.h:135 @ int irq_init_percpu_irqstack(unsigned in
 	return 0;
 }
 
+#ifndef CONFIG_PREEMPT_RT
 void do_softirq_own_stack(void)
 {
 	struct irq_stack *irqstk;
@ linux-5.15.19-rt29/arch/x86/include/asm/irq_stack.h:152 @ void do_softirq_own_stack(void)
 
 	call_on_stack(__do_softirq, isp);
 }
+#endif
 
 void __handle_irq(struct irq_desc *desc, struct pt_regs *regs)
 {