Skip to contentSkip to conversation

irqchip/riscv-imsic: Start local sync timer on correct CPU

PATCH Applied Andrew Bresticker 5 participants 5 messages May 14, 2025 – Jun 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/riscv-imsic: Start local sync timer on correct CPU

When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.

Fixes 0f67911e821c ("irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector")
---
 drivers/irqchip/irq-riscv-imsic-state.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-riscv-imsic-state.c +5 -5
index bdf5cd2037f2..62f76950a113 100644
@@ -208,17 +208,17 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv)
 }
 
 #ifdef CONFIG_SMP
-static void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
 	lockdep_assert_held(&lpriv->lock);
 
 	if (!timer_pending(&lpriv->timer)) {
 		lpriv->timer.expires = jiffies + 1;
-		add_timer_on(&lpriv->timer, smp_processor_id());
+		add_timer_on(&lpriv->timer, cpu);
 	}
 }
 #else
-static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
 }
 #endif
@@ -233,7 +233,7 @@ void imsic_local_sync_all(bool force_all)
 	if (force_all)
 		bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1);
 	if (!__imsic_local_sync(lpriv))
-		__imsic_local_timer_start(lpriv);
+		__imsic_local_timer_start(lpriv, smp_processor_id());
 
 	raw_spin_unlock_irqrestore(&lpriv->lock, flags);
 }
@@ -278,7 +278,7 @@ static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu
 				return;
 		}
 
-		__imsic_local_timer_start(lpriv);
+		__imsic_local_timer_start(lpriv, cpu);
 	}
 }
 #else
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrew Bresticker

When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.

Fixes 0f67911e821c ("irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector")

My bad. Thanks for catching the issue.

Regards,
Anup

Quoted 50 lines
---
 drivers/irqchip/irq-riscv-imsic-state.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-riscv-imsic-state.c +5 -6
index bdf5cd2037f2..62f76950a113 100644
@@ -208,17 +208,17 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv)
 }
 
 #ifdef CONFIG_SMP
-static void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
        lockdep_assert_held(&lpriv->lock);
 
        if (!timer_pending(&lpriv->timer)) {
                lpriv->timer.expires = jiffies + 1;
-               add_timer_on(&lpriv->timer, smp_processor_id());
+               add_timer_on(&lpriv->timer, cpu);
        }
 }
 #else
-static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
 }
 #endif
@@ -233,7 +233,7 @@ void imsic_local_sync_all(bool force_all)
        if (force_all)
                bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1);
        if (!__imsic_local_sync(lpriv))
-               __imsic_local_timer_start(lpriv);
+               __imsic_local_timer_start(lpriv, smp_processor_id());
 
        raw_spin_unlock_irqrestore(&lpriv->lock, flags);
 }
@@ -278,7 +278,7 @@ static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu
                                return;
                }
 
-               __imsic_local_timer_start(lpriv);
+               __imsic_local_timer_start(lpriv, cpu);
        }
 }
 #else
--

2.43.0

#2 lore raw
In reply to Andrew Bresticker
The following commit has been merged into the irq/urgent branch of tip:

The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     08fb624802d8786253994d8ebdbbcdaa186f04f5
Gitweb:        https://git.kernel.org/tip/08fb624802d8786253994d8ebdbbcdaa186f04f5
Author:        Andrew Bresticker <[email protected]>
AuthorDate:    Wed, 14 May 2025 10:13:20 -07:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 15 May 2025 16:01:50 +02:00

irqchip/riscv-imsic: Start local sync timer on correct CPU

When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.

Fixes 0f67911e821c ("irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector")
---
 drivers/irqchip/irq-riscv-imsic-state.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-riscv-imsic-state.c +5 -5
index bdf5cd2..62f7695 100644
@@ -208,17 +208,17 @@ skip:
 }
 
 #ifdef CONFIG_SMP
-static void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
 	lockdep_assert_held(&lpriv->lock);
 
 	if (!timer_pending(&lpriv->timer)) {
 		lpriv->timer.expires = jiffies + 1;
-		add_timer_on(&lpriv->timer, smp_processor_id());
+		add_timer_on(&lpriv->timer, cpu);
 	}
 }
 #else
-static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv)
+static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv, unsigned int cpu)
 {
 }
 #endif
@@ -233,7 +233,7 @@ void imsic_local_sync_all(bool force_all)
 	if (force_all)
 		bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1);
 	if (!__imsic_local_sync(lpriv))
-		__imsic_local_timer_start(lpriv);
+		__imsic_local_timer_start(lpriv, smp_processor_id());
 
 	raw_spin_unlock_irqrestore(&lpriv->lock, flags);
 }
@@ -278,7 +278,7 @@ static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu
 				return;
 		}
 
-		__imsic_local_timer_start(lpriv);
+		__imsic_local_timer_start(lpriv, cpu);
 	}
 }
 #else
#3 lore raw
In reply to Andrew Bresticker
This patch was applied to riscv/linux.git (fixes) by Thomas Gleixner <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <[email protected]>:

Quoted 10 lines · On Wed, 14 May 2025 10:13:20 -0700 you wrote:

When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.

Fixes 0f67911e821c ("irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector")

[...]

Here is the summary with links:
- irqchip/riscv-imsic: Start local sync timer on correct CPU

    https://git.kernel.org/riscv/c/08fb624802d8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#4 lore raw
Quoted 4 lines · patchwork-bot

Hello:

This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <[email protected]>:

No. I never apply patches to the riscv tree :)

Quoted 10 lines · On Wed, 14 May 2025 10:13:20 -0700 you wrote:
Quoted 9 lines

When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.

Fixes 0f67911e821c ("irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector")
Quoted 7 lines
Quoted 1 line

[...]

Here is the summary with links:
- irqchip/riscv-imsic: Start local sync timer on correct CPU

    https://git.kernel.org/riscv/c/08fb624802d8

You are awesome, thank you!

That patch has been committed to the tip tree and is already upstream.

Can you fix your bot scripts please?