OSDN Git Service

powerpc/64s: Fix lost pending interrupt due to race causing lost update to irq_happened
authorNicholas Piggin <npiggin@gmail.com>
Wed, 21 Mar 2018 02:22:28 +0000 (12:22 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 22 Mar 2018 21:41:40 +0000 (08:41 +1100)
commitff6781fd1bb404d8a551c02c35c70cec1da17ff1
treeec1957127a5678a7aae7ca1825e453fb1e8a1816
parente4b79900222b8cccd4da4a7a89581f0e1b764ed2
powerpc/64s: Fix lost pending interrupt due to race causing lost update to irq_happened

force_external_irq_replay() can be called in the do_IRQ path with
interrupts hard enabled and soft disabled if may_hard_irq_enable() set
MSR[EE]=1. It updates local_paca->irq_happened with a load, modify,
store sequence. If a maskable interrupt hits during this sequence, it
will go to the masked handler to be marked pending in irq_happened.
This update will be lost when the interrupt returns and the store
instruction executes. This can result in unpredictable latencies,
timeouts, lockups, etc.

Fix this by ensuring hard interrupts are disabled before modifying
irq_happened.

This could cause any maskable asynchronous interrupt to get lost, but
it was noticed on P9 SMP system doing RDMA NVMe target over 100GbE,
so very high external interrupt rate and high IPI rate. The hang was
bisected down to enabling doorbell interrupts for IPIs. These provided
an interrupt type that could run at high rates in the do_IRQ path,
stressing the race.

Fixes: 1d607bb3bd60 ("powerpc/irq: Add mechanism to force a replay of interrupts")
Cc: stable@vger.kernel.org # v4.8+
Reported-by: Carol L. Soto <clsoto@us.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/irq.c