[patch V2 02/17] posix-timers: Add cond_resched() to posix_timer_add() search loop

Thomas Gleixner posted 17 patches 2 months, 1 week ago
There is a newer version of this series
[patch V2 02/17] posix-timers: Add cond_resched() to posix_timer_add() search loop
Posted by Thomas Gleixner 2 months, 1 week ago
From: Eric Dumazet <edumazet@google.com>

With a large number of POSIX timers the search for a valid ID might cause a
soft lockup on PREEMPT_NONE/VOLUNTARY kernels.

Add cond_resched() to the loop to prevent that.

[ tglx: Split out from Eric's series ]

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250214135911.2037402-2-edumazet@google.com
---
 kernel/time/posix-timers.c |    1 +
 1 file changed, 1 insertion(+)

--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -144,6 +144,7 @@ static int posix_timer_add(struct k_itim
 			return id;
 		}
 		spin_unlock(&hash_lock);
+		cond_resched();
 	}
 	/* POSIX return code when no timer ID could be allocated */
 	return -EAGAIN;
Re: [patch V2 02/17] posix-timers: Add cond_resched() to posix_timer_add() search loop
Posted by Frederic Weisbecker 2 months ago
Le Sun, Mar 02, 2025 at 08:36:46PM +0100, Thomas Gleixner a écrit :
> From: Eric Dumazet <edumazet@google.com>
> 
> With a large number of POSIX timers the search for a valid ID might cause a
> soft lockup on PREEMPT_NONE/VOLUNTARY kernels.
> 
> Add cond_resched() to the loop to prevent that.
> 
> [ tglx: Split out from Eric's series ]
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Link: https://lore.kernel.org/all/20250214135911.2037402-2-edumazet@google.com

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>