From: Jiri Bohac <jbohac@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: tglx@linutronix.de, mhocko@suse.cz
Subject: running hrtimer_start on an already active hrtimer?
Date: Tue, 5 May 2015 15:30:54 +0200 [thread overview]
Message-ID: <20150505133054.GA20643@midget.suse.cz> (raw)
Hi,
I came across a strange bug (in a very old kernel) that triggers
the
BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
in __run_hrtimer().
The code runs hrtimer_start() on an already started hrtimer.
Looking at the description of hrtimer_start() it looks
like something that is allowed:
/**
* hrtimer_start - (re)start an hrtimer on the current CPU
...
* Returns:
* 0 on success
* 1 when the timer was active
Is this really supposed to work?
I think it's not immune to this race condition:
CPU0 CPU1
__run_hrtimer()
__remove_hrtimer(...HRTIMER_STATE_CALLBACK)
//clears HRTIMER_STATE_ENQUEUED
...
raw_spin_unlock(&cpu_base->lock);
restart = fn(timer);
hrtimer_start()
__hrtimer_start_range_ns()
//remove_hrtimer() does nothing because
// HRTIMER_STATE_ENQUEUED is not set
enqueue_hrtimer()
raw_spin_lock(&cpu_base->lock);
...
BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
// state has HRTIMER_STATE_ENQUEUED set
Should __hrtimer_start_range_ns() do something like
hrtimer_cancel - i.e. explicitly check for ...
HRTIMER_STATE_CALLBACK?
Thanks,
--
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ
next reply other threads:[~2015-05-05 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 13:30 Jiri Bohac [this message]
2015-05-05 15:11 ` running hrtimer_start on an already active hrtimer? Thomas Gleixner
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=20150505133054.GA20643@midget.suse.cz \
--to=jbohac@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=tglx@linutronix.de \
/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