diff options
author | Benjamin Segall <bsegall@google.com> | 2025-02-14 14:12:20 -0800 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2025-02-18 10:12:49 +0100 |
commit | f99c5bb396b8d1424ed229d1ffa6f596e3b9c36b (patch) | |
tree | 0828a646a83c6bda57b3a35f0d96283051ff0224 /kernel/time/posix-timers.c | |
parent | 4441b976dfeff0d3579e8da3c0283300c618a553 (diff) |
posix-timers: Invoke cond_resched() during exit_itimers()
exit_itimers() loops through every timer in the process to delete it. This
requires taking the system-wide hash_lock for each of these timers, and
contends with other processes trying to create or delete timers.
When a process creates hundreds of thousands of timers, and then exits
while other processes contend with it, this can trigger softlockups on
CONFIG_PREEMPT=n.
Add a cond_resched() invocation into the loop to allow the system to make
progress.
Signed-off-by: Ben Segall <bsegall@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/xm2634gg2n23.fsf@google.com
Diffstat (limited to 'kernel/time/posix-timers.c')
-rw-r--r-- | kernel/time/posix-timers.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 1b675aee99a9..44ba7db07e90 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -1099,8 +1099,10 @@ void exit_itimers(struct task_struct *tsk) spin_unlock_irq(&tsk->sighand->siglock); /* The timers are not longer accessible via tsk::signal */ - while (!hlist_empty(&timers)) + while (!hlist_empty(&timers)) { itimer_delete(hlist_entry(timers.first, struct k_itimer, list)); + cond_resched(); + } /* * There should be no timers on the ignored list. itimer_delete() has |