Re: [RFC] powerpc: handle simultanneous interrupts at once

From: Benjamin Herrenschmidt
Date: Mon Mar 13 2017 - 19:43:50 EST


On Fri, 2017-03-10 at 12:11 +0100, Christophe Leroy wrote:
> It often happens to have simultanneous interrupts, for instance
> when having double Ethernet attachment. With the current
> implementation, we suffer the cost of kernel entry/exit for each
> interrupt.
>
> This patch introduces a loop in __do_irq() to handle all interrupts
> at once before returning.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
> ---
> Âarch/powerpc/include/asm/hw_irq.h |ÂÂ6 ++++++
> Âarch/powerpc/kernel/irq.cÂÂÂÂÂÂÂÂÂ| 22 +++++++++++++++-------
> Â2 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/hw_irq.h
> b/arch/powerpc/include/asm/hw_irq.h
> index eba60416536e..d69ae5846955 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -123,6 +123,11 @@ static inline void may_hard_irq_enable(void)
> Â __hard_irq_enable();
> Â}
> Â
> +static inline void may_hard_irq_disable(void)
> +{
> + __hard_irq_disable();
> +}
> +
> Âstatic inline bool arch_irq_disabled_regs(struct pt_regs *regs)
> Â{
> Â return !regs->softe;
> @@ -204,6 +209,7 @@ static inline bool arch_irq_disabled_regs(struct
> pt_regs *regs)
> Â}
> Â
> Âstatic inline void may_hard_irq_enable(void) { }
> +static inline void may_hard_irq_disable(void) { }
> Â
> Â#endif /* CONFIG_PPC64 */
> Â
> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
> index a018f5cae899..28aca510c166 100644
> --- a/arch/powerpc/kernel/irq.c
> +++ b/arch/powerpc/kernel/irq.c
> @@ -515,14 +515,22 @@ void __do_irq(struct pt_regs *regs)
> Â Â*/
> Â irq = ppc_md.get_irq();
> Â
> - /* We can hard enable interrupts now to allow perf
> interrupts */
> - may_hard_irq_enable();
> + do {
> + /* We can hard enable interrupts now to allow perf
> interrupts */
> + may_hard_irq_enable();
> +
> + /* And finally process it */
> + if (unlikely(!irq))
> + __this_cpu_inc(irq_stat.spurious_irqs);
> + else
> + generic_handle_irq(irq);
> +
> + may_hard_irq_disable();

Not sure the above is that useful. If another interrupt is pending,
on ppc64 at least, you will have got it right at may_hard_irq_enable()
which would have caused a hard-disable for you anyway.

> - /* And finally process it */
> - if (unlikely(!irq))
> - __this_cpu_inc(irq_stat.spurious_irqs);
> - else
> - generic_handle_irq(irq);
> + irq = ppc_md.get_irq();
> + } while (irq);
> +
> + may_hard_irq_enable();
> Â
> Â trace_irq_exit(regs);
> Â