From: Jimmie Mayfield <jimmie@sackheads.org>
To: linux-kernel@vger.kernel.org
Subject: Basic questions regarding del_timer_sync() and re-registering timers
Date: Mon, 14 Apr 2014 13:39:48 -0400 [thread overview]
Message-ID: <20140414173947.GA25057@sackheads.org> (raw)
Hi. The common wisdom when mixing del_timer_sync() with timer functions
that re-register themselves is that the caller must ensure that re-registration
does not happen.
>From timer.c:
* Synchronization rules: Callers must prevent restarting of the timer,
* otherwise this function is meaningless.
I'm curious if someone could briefly explain why?
The pseudo-code for del_timer_sync and try_to_del_timer_sync looks
something like this (ignoring the lock manipulation):
while (1) {
if (timer is not running) {
if timer is pending then detach it
break
}
else {
sleep
}
}
So that the loop continues to spin until the timer function is no longer
running at which point the kernel checks the pending list and removes it if
necessary.
Q: So given this construct, why is it imperative that the timer
function not re-register itself?
I could understand that restriction if the timer function might be running on
another CPU when the "if timer is pending then detach" step is executed but
it's not obvious to me how that's possible since base->lock is owned at
that point (not shown in the pseudocode)?
Can someone briefly point out what I've missed?
(while I am subscribed to LKML, please cc: me on replies so that they don't
get lost in the noise)
JM
--
Jimmie Mayfield
reply other threads:[~2014-04-14 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140414173947.GA25057@sackheads.org \
--to=jimmie@sackheads.org \
--cc=linux-kernel@vger.kernel.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®