Skip to content

Commit f99c5bb

Browse files
Benjamin SegallKAGA-KOKO
authored andcommitted
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
1 parent 4441b97 commit f99c5bb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/time/posix-timers.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,10 @@ void exit_itimers(struct task_struct *tsk)
10991099
spin_unlock_irq(&tsk->sighand->siglock);
11001100

11011101
/* The timers are not longer accessible via tsk::signal */
1102-
while (!hlist_empty(&timers))
1102+
while (!hlist_empty(&timers)) {
11031103
itimer_delete(hlist_entry(timers.first, struct k_itimer, list));
1104+
cond_resched();
1105+
}
11041106

11051107
/*
11061108
* There should be no timers on the ignored list. itimer_delete() has

0 commit comments

Comments
 (0)