Skip to content

Commit b1e155c

Browse files
npiggingregkh
authored andcommitted
powerpc/64: irq replay remove decrementer overflow check
[ Upstream commit 59d512e ] This is way to catch some cases of decrementer overflow, when the decrementer has underflowed an odd number of times, while MSR[EE] was disabled. With a typical small decrementer, a timer that fires when MSR[EE] is disabled will be "lost" if MSR[EE] remains disabled for between 4.3 and 8.6 seconds after the timer expires. In any case, the decrementer interrupt would be taken at 8.6 seconds and the timer would be found at that point. So this check is for catching extreme latency events, and it prevents those latencies from being a further few seconds long. It's not obvious this is a good tradeoff. This is already a watchdog magnitude event and that situation is not improved a significantly with this check. For large decrementers, it's useless. Therefore remove this check, which avoids a mftb when enabling hard disabled interrupts (e.g., when enabling after coming from hardware interrupt handlers). Perhaps more importantly, it also removes the clunky MSR[EE] vs PACA_IRQ_HARD_DIS incoherency in soft-interrupt replay which simplifies the code. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20201107014336.2337337-1-npiggin@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8b5b2b7 commit b1e155c

3 files changed

Lines changed: 8 additions & 56 deletions

File tree

‎arch/powerpc/kernel/irq.c‎

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ static inline notrace unsigned long get_irq_happened(void)
102102
return happened;
103103
}
104104

105-
static inline notrace int decrementer_check_overflow(void)
106-
{
107-
u64 now = get_tb();
108-
u64 *next_tb = this_cpu_ptr(&decrementers_next_tb);
109-
110-
return now >= *next_tb;
111-
}
112-
113105
#ifdef CONFIG_PPC_BOOK3E
114106

115107
/* This is called whenever we are re-enabling interrupts
@@ -142,35 +134,6 @@ notrace unsigned int __check_irq_replay(void)
142134
trace_hardirqs_on();
143135
trace_hardirqs_off();
144136

145-
/*
146-
* We are always hard disabled here, but PACA_IRQ_HARD_DIS may
147-
* not be set, which means interrupts have only just been hard
148-
* disabled as part of the local_irq_restore or interrupt return
149-
* code. In that case, skip the decrementr check becaus it's
150-
* expensive to read the TB.
151-
*
152-
* HARD_DIS then gets cleared here, but it's reconciled later.
153-
* Either local_irq_disable will replay the interrupt and that
154-
* will reconcile state like other hard interrupts. Or interrupt
155-
* retur will replay the interrupt and in that case it sets
156-
* PACA_IRQ_HARD_DIS by hand (see comments in entry_64.S).
157-
*/
158-
if (happened & PACA_IRQ_HARD_DIS) {
159-
local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
160-
161-
/*
162-
* We may have missed a decrementer interrupt if hard disabled.
163-
* Check the decrementer register in case we had a rollover
164-
* while hard disabled.
165-
*/
166-
if (!(happened & PACA_IRQ_DEC)) {
167-
if (decrementer_check_overflow()) {
168-
local_paca->irq_happened |= PACA_IRQ_DEC;
169-
happened |= PACA_IRQ_DEC;
170-
}
171-
}
172-
}
173-
174137
if (happened & PACA_IRQ_DEC) {
175138
local_paca->irq_happened &= ~PACA_IRQ_DEC;
176139
return 0x900;
@@ -186,6 +149,9 @@ notrace unsigned int __check_irq_replay(void)
186149
return 0x280;
187150
}
188151

152+
if (happened & PACA_IRQ_HARD_DIS)
153+
local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
154+
189155
/* There should be nothing left ! */
190156
BUG_ON(local_paca->irq_happened != 0);
191157

@@ -229,18 +195,6 @@ void replay_soft_interrupts(void)
229195
if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
230196
WARN_ON_ONCE(mfmsr() & MSR_EE);
231197

232-
if (happened & PACA_IRQ_HARD_DIS) {
233-
/*
234-
* We may have missed a decrementer interrupt if hard disabled.
235-
* Check the decrementer register in case we had a rollover
236-
* while hard disabled.
237-
*/
238-
if (!(happened & PACA_IRQ_DEC)) {
239-
if (decrementer_check_overflow())
240-
happened |= PACA_IRQ_DEC;
241-
}
242-
}
243-
244198
/*
245199
* Force the delivery of pending soft-disabled interrupts on PS3.
246200
* Any HV call will have this side effect.
@@ -345,6 +299,7 @@ notrace void arch_local_irq_restore(unsigned long mask)
345299
if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
346300
WARN_ON_ONCE(!(mfmsr() & MSR_EE));
347301
__hard_irq_disable();
302+
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
348303
} else {
349304
/*
350305
* We should already be hard disabled here. We had bugs

‎arch/powerpc/kernel/time.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,11 @@ void timer_interrupt(struct pt_regs *regs)
552552
struct pt_regs *old_regs;
553553
u64 now;
554554

555-
/* Some implementations of hotplug will get timer interrupts while
556-
* offline, just ignore these and we also need to set
557-
* decrementers_next_tb as MAX to make sure __check_irq_replay
558-
* don't replay timer interrupt when return, otherwise we'll trap
559-
* here infinitely :(
555+
/*
556+
* Some implementations of hotplug will get timer interrupts while
557+
* offline, just ignore these.
560558
*/
561559
if (unlikely(!cpu_online(smp_processor_id()))) {
562-
*next_tb = ~(u64)0;
563560
set_dec(decrementer_max);
564561
return;
565562
}

‎arch/powerpc/platforms/powernv/opal.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ int opal_hmi_exception_early2(struct pt_regs *regs)
731731
return 1;
732732
}
733733

734-
/* HMI exception handler called in virtual mode during check_irq_replay. */
734+
/* HMI exception handler called in virtual mode when irqs are next enabled. */
735735
int opal_handle_hmi_exception(struct pt_regs *regs)
736736
{
737737
/*

0 commit comments

Comments
 (0)