]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
posix-timers: Add cond_resched() to posix_timer_add() search loop
authorEric Dumazet <edumazet@google.com>
Sat, 8 Mar 2025 16:48:17 +0000 (17:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:41:59 +0000 (14:41 +0200)
[ Upstream commit 5f2909c6cd13564a07ae692a95457f52295c4f22 ]

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>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250214135911.2037402-2-edumazet@google.com
Link: https://lore.kernel.org/all/20250308155623.635612865@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/time/posix-timers.c

index b924f0f096fa4495e3fd1f0c8a3e02ab4eb1ccb2..7534069f6033345e4b1dd8f21834a4e6011a63d2 100644 (file)
@@ -118,6 +118,7 @@ static int posix_timer_add(struct k_itimer *timer)
                        return id;
                }
                spin_unlock(&hash_lock);
+               cond_resched();
        }
        /* POSIX return code when no timer ID could be allocated */
        return -EAGAIN;