From: David Howells <dhowells@redhat.com>
To: tglx@linutronix.de
Cc: dhowells@redhat.com, torvalds@linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Is there a race between __mod_timer() and del_timer()?
Date: Wed, 08 Nov 2017 10:15:41 +0000 [thread overview]
Message-ID: <20750.1510136141@warthog.procyon.org.uk> (raw)
Is there a race between the optimisation for networking code in __mod_timer()
and del_timer() - or, at least, a race that matters?
Consider:
CPU A CPU B
=============================== ===============================
[timer X is active]
==>__mod_timer(X)
if (timer_pending(timer))
[Take the true path]
-- IRQ -- ==>del_timer(X)
<==
if (timer->expires == expires)
[Take the true path]
<==return 1
[timer X is not active]
There's no locking to prevent this, but __mod_timer() returns without
restarting the timer. I'm not sure this is a problem exactly, however, since
del_timer() *was* issued, and could've deleted the timer after __mod_timer()
returned.
A couple of possible alleviations:
(1) Recheck timer_pending() before returning from __mod_timer().
(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.
I think it might just be best to put a note in the comments in __mod_timer().
Thoughts?
David
next reply other threads:[~2017-11-08 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 10:15 David Howells [this message]
2017-11-08 10:23 ` David Howells
2017-11-08 10:40 ` Thomas Gleixner
2017-11-08 16:26 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20750.1510136141@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®