All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] powerpc: handle simultanneous interrupts at once
@ 2017-03-10 11:11 Christophe Leroy
  2017-03-13 23:42 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2017-03-10 11:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, Scott Wood
  Cc: linux-kernel, linuxppc-dev

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@c-s.fr>
---
 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();
 
-	/* 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);
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] powerpc: handle simultanneous interrupts at once
  2017-03-10 11:11 [RFC] powerpc: handle simultanneous interrupts at once Christophe Leroy
@ 2017-03-13 23:42 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2017-03-13 23:42 UTC (permalink / raw)
  To: Christophe Leroy, Paul Mackerras, Michael Ellerman, Scott Wood
  Cc: linux-kernel, linuxppc-dev

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@c-s.fr>
> ---
>  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);
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-13 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 11:11 [RFC] powerpc: handle simultanneous interrupts at once Christophe Leroy
2017-03-13 23:42 ` Benjamin Herrenschmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.