Skip to content

Commit 1123d93

Browse files
Max AsbockKAGA-KOKO
Max Asbock
authored andcommitted
timerfd: Fix wakeup of processes when timer is cancelled on clock change
Currently processes waiting with poll on cancelable timerfd timers are not woken up when the timers are canceled. When the system time is set the clock_was_set() function calls timerfd_clock_was_set() to cancel and wake up processes waiting on potential cancelable timerfd timers. However the wake up currently has no effect because in the case of timerfd_read it is dependent on ctx->ticks not being 0. timerfd_poll also requires ctx->ticks being non zero. As a consequence processes waiting on cancelable timers only get woken up when the timers expire. This patch fixes this by incrementing ctx->ticks before calling wake_up. Signed-off-by: Max Asbock <[email protected]> Cc: [email protected] Cc: [email protected] Cc: johnstul <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 2c53b43 commit 1123d93

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/timerfd.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr)
6161

6262
/*
6363
* Called when the clock was set to cancel the timers in the cancel
64-
* list.
64+
* list. This will wake up processes waiting on these timers. The
65+
* wake-up requires ctx->ticks to be non zero, therefore we increment
66+
* it before calling wake_up_locked().
6567
*/
6668
void timerfd_clock_was_set(void)
6769
{
@@ -76,6 +78,7 @@ void timerfd_clock_was_set(void)
7678
spin_lock_irqsave(&ctx->wqh.lock, flags);
7779
if (ctx->moffs.tv64 != moffs.tv64) {
7880
ctx->moffs.tv64 = KTIME_MAX;
81+
ctx->ticks++;
7982
wake_up_locked(&ctx->wqh);
8083
}
8184
spin_unlock_irqrestore(&ctx->wqh.lock, flags);

0 commit comments

Comments
 (0)