Re: [GIT pull] locking/urgent for v5.10-rc6

From: Peter Zijlstra
Date: Tue Dec 01 2020 - 13:16:09 EST


On Tue, Dec 01, 2020 at 03:55:19PM +0100, Peter Zijlstra wrote:
> On Tue, Dec 01, 2020 at 06:46:44AM -0800, Paul E. McKenney wrote:
>
> > > So after having talked to Sven a bit, the thing that is happening, is
> > > that this is the one place where we take interrupts with RCU being
> > > disabled. Normally RCU is watching and all is well, except during idle.
> >
> > Isn't interrupt entry supposed to invoke rcu_irq_enter() at some point?
> > Or did this fall victim to recent optimizations?
>
> It does, but the problem is that s390 is still using

I might've been too quick there, I can't actually seem to find where
s390 does rcu_irq_enter()/exit().

Also, I'm thinking the below might just about solve the current problem.
The next problem would then be it calling TRACE_IRQS_ON after it did
rcu_irq_exit()... :/


---
diff --git a/arch/s390/include/asm/irq.h b/arch/s390/include/asm/irq.h
index 9f75d67b8c20..24d3dd482df7 100644
--- a/arch/s390/include/asm/irq.h
+++ b/arch/s390/include/asm/irq.h
@@ -113,6 +113,8 @@ void irq_subclass_unregister(enum irq_subclass subclass);

#define irq_canonicalize(irq) (irq)

+extern __visible void ext_do_IRQ(struct pt_regs *regs, unsigned long vector);
+
#endif /* __ASSEMBLY__ */

#endif /* _ASM_IRQ_H */
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 26bb0603c5a1..b8e89b685038 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -976,16 +976,10 @@ ENTRY(ext_int_handler)
xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
jo .Lio_restore
-#if IS_ENABLED(CONFIG_TRACE_IRQFLAGS)
- tmhh %r8,0x300
- jz 1f
- TRACE_IRQS_OFF
-1:
-#endif
xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
lgr %r2,%r11 # pass pointer to pt_regs
lghi %r3,EXT_INTERRUPT
- brasl %r14,do_IRQ
+ brasl %r14,ext_do_IRQ
j .Lio_return
ENDPROC(ext_int_handler)

diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 3514420f0259..f4a29114e9fd 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -329,3 +329,23 @@ void irq_subclass_unregister(enum irq_subclass subclass)
spin_unlock(&irq_subclass_lock);
}
EXPORT_SYMBOL(irq_subclass_unregister);
+
+noinstr void ext_do_IRQ(struct pt_regs *regs, unsigned long vector)
+{
+ bool rcu = false;
+
+ lockdep_hardirqs_off(CALLER_ADDR0);
+ if (!IS_ENABLED(CONFIG_TINY_RCU) && is_idle_task(current)) {
+ rcu_irq_enter();
+ rcu = true;
+ }
+ /* instrumentation_begin(); */
+
+ trace_hardirqs_off_finish();
+
+ do_IRQ(regs, vector);
+
+ /* instrumentation_end(); */
+ if (rcu)
+ rcu_irq_exit();
+}