lkml.org 
[lkml]   [2017]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Is there a race between __mod_timer() and del_timer()?
On Wed, Nov 8, 2017 at 2:15 AM, David Howells <dhowells@redhat.com> wrote:
>
> (2) Set timer->expires to jiffies in del_timer() - but since there's nothing
> preventing the optimisation in __mod_timer() from occurring concurrently
> with del_timer(), this probably won't help.

Right. The "race" is fundamental, and not in the timer code, but in the user.

If somebody does "del_timer()" at the same time somebody else modifies
the timer, it's not clear which one will win. The timer going away is
basically just "somebody modified it, but then immediately afterwards
another user deleted it".

So the modification was successful, but the end result is that the
timer is deleted, so it obviously isn't started.

I'm not even sure it merits a comment in the timer code, because the
timer code seems to do the right thing. The problem is in whoever
modifies and deletes a timer at the same time. It's fundamentally not
well-defined: either operation might happen "last", so you may end up
with a timer active or not, based purely on timing and luck.

Linus

\
 
 \ /
  Last update: 2017-11-08 21:13    [W:0.047 / U:2.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site