lkml.org 
[lkml]   [2017]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: Is there a race between __mod_timer() and del_timer()?
Date
David Howells <dhowells@redhat.com> wrote:

> I think it might just be best to put a note in the comments in __mod_timer().

How about the attached?

David
---
commit d538c734f9bf885292b88a81a06c5efee528d70d
Author: David Howells <dhowells@redhat.com>
Date: Wed Nov 8 10:20:27 2017 +0000

Add a comment into __mod_timer() noting a possible race with del_timer()

Add a comment into __mod_timer() noting a possible race with del_timer() in
which the 'common optimization' case could leave the timer unstarted if
del_timer() happens between the timer_pending() check and the timer
expiration check.

Signed-off-by: David Howells <dhowells@redhat.com>

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index f2674a056c26..e0ac4486529c 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -949,6 +949,9 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
* The downside of this optimization is that it can result in
* larger granularity than you would get from adding a new
* timer with this expiry.
+ *
+ * Note that if del_timer() happens whilst we're just here, we
+ * will return with the timer unstarted.
*/
if (timer->expires == expires)
return 1;
\
 
 \ /
  Last update: 2017-11-08 21:11    [W:0.617 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site