Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] arm64: Avoid pointless schedule_preempt_irq() invocations
@ 2019-07-17  8:43 Thomas Gleixner
  2019-07-17  9:54 ` Valentin Schneider
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2019-07-17  8:43 UTC (permalink / raw)
  To: LAK; +Cc: Peter Zijlstra, Catalin Marinas, Will Deacon, LKML

When preempt_count is zero on return from interrupt then
schedule_preempt_irq() is invoked even if TIF_NEED_RESCHED is not set.

That does not make sense because schedule_preempt_irq() has to go through a
full __schedule() for nothing in that case.

Check TIF_NEED_RESCHED and invoke schedule_preempt_irq() only if set.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
Found while staring at some RT wrecakge in that area.
---
 arch/arm64/kernel/entry.S |    4 ++++
 1 file changed, 4 insertions(+)

--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -680,6 +680,10 @@ alternative_if ARM64_HAS_IRQ_PRIO_MASKIN
 	orr	x24, x24, x0
 alternative_else_nop_endif
 	cbnz	x24, 1f				// preempt count != 0 || NMI return path
+
+	ldr	x0, [tsk, #TSK_TI_FLAGS]        // get flags
+	tbz	x0, #TIF_NEED_RESCHED, 1f      	// needs rescheduling?
+
 	bl	preempt_schedule_irq		// irq en/disable is done inside
 1:
 #endif

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: Avoid pointless schedule_preempt_irq() invocations
  2019-07-17  8:43 [PATCH] arm64: Avoid pointless schedule_preempt_irq() invocations Thomas Gleixner
@ 2019-07-17  9:54 ` Valentin Schneider
  2019-07-17 10:04   ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Valentin Schneider @ 2019-07-17  9:54 UTC (permalink / raw)
  To: Thomas Gleixner, LAK; +Cc: Peter Zijlstra, Catalin Marinas, Will Deacon, LKML

On 17/07/2019 09:43, Thomas Gleixner wrote:
> When preempt_count is zero on return from interrupt then
> schedule_preempt_irq() is invoked even if TIF_NEED_RESCHED is not set.
> 
> That does not make sense because schedule_preempt_irq() has to go through a
> full __schedule() for nothing in that case.
> 
> Check TIF_NEED_RESCHED and invoke schedule_preempt_irq() only if set.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Don't we have NEED_RESCHED squashed into preempt count?

  396244692232 ("arm64: preempt: Provide our own implementation of asm/preempt.h")

So the existing check should cover that, unless I'm missing something?

> ---
> Found while staring at some RT wrecakge in that area.
> ---
>  arch/arm64/kernel/entry.S |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -680,6 +680,10 @@ alternative_if ARM64_HAS_IRQ_PRIO_MASKIN
>  	orr	x24, x24, x0
>  alternative_else_nop_endif
>  	cbnz	x24, 1f				// preempt count != 0 || NMI return path
> +
> +	ldr	x0, [tsk, #TSK_TI_FLAGS]        // get flags
> +	tbz	x0, #TIF_NEED_RESCHED, 1f      	// needs rescheduling?
> +
>  	bl	preempt_schedule_irq		// irq en/disable is done inside
>  1:
>  #endif
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: Avoid pointless schedule_preempt_irq() invocations
  2019-07-17  9:54 ` Valentin Schneider
@ 2019-07-17 10:04   ` Thomas Gleixner
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2019-07-17 10:04 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: Peter Zijlstra, Catalin Marinas, Will Deacon, LKML, LAK

On Wed, 17 Jul 2019, Valentin Schneider wrote:

> On 17/07/2019 09:43, Thomas Gleixner wrote:
> > When preempt_count is zero on return from interrupt then
> > schedule_preempt_irq() is invoked even if TIF_NEED_RESCHED is not set.
> > 
> > That does not make sense because schedule_preempt_irq() has to go through a
> > full __schedule() for nothing in that case.
> > 
> > Check TIF_NEED_RESCHED and invoke schedule_preempt_irq() only if set.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Don't we have NEED_RESCHED squashed into preempt count?
> 
>   396244692232 ("arm64: preempt: Provide our own implementation of asm/preempt.h")
> 
> So the existing check should cover that, unless I'm missing something?

Right. Ignore me.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17  8:43 [PATCH] arm64: Avoid pointless schedule_preempt_irq() invocations Thomas Gleixner
2019-07-17  9:54 ` Valentin Schneider
2019-07-17 10:04   ` Thomas Gleixner

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox