From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>, George Anzinger <george@mvista.com>,
john stultz <johnstul@us.ibm.com>,
Roman Zippel <zippel@linux-m68k.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [ANNOUNCE] 2.6.15-rc5-hrt2 - hrtimers based high resolution patches
Date: Tue, 17 Jan 2006 18:35:05 +0100 [thread overview]
Message-ID: <1137519305.17609.48.camel@localhost.localdomain> (raw)
In-Reply-To: <1136937547.6197.73.camel@localhost.localdomain>
On Tue, 2006-01-10 at 18:59 -0500, Steven Rostedt wrote:
> And this _is_ protected, but I just discovered that this does _not_
> protect against hrtimer_start!
>
> In hrtimer_start we have:
>
> base = lock_hrtimer_base(timer, &flags);
>
> /* Remove an active timer from the queue: */
> remove_hrtimer(timer, base);
>
> Which can be called after that spin_unlock_irq is done by the
> run_hrtimer_queue, and we will hit a bug (as I did). This is not an
> easy race to hit.
Right, but there should be actually no use case where this happens.
For now I prefer to add a
BUG_ON(base->curr_timer == timer);
into hrtimer_start to find the real reason.
> Here's an example of a race for this problem:
> In posix-timers.c: commen_timer_set:
>
> If we get preempted between hrtimer_try_to_cancel and
> hrtimer_restart.
>
> Then a new thread adds the timer back (by a threaded program).
I don't see how this should happen.
sys_timer_settime()
timr = lock_timer(timer_id, flag);
Now the k_itimer, which is the container of the hrtimer is locked.
common_timer_set()
if (hrtimer_try_to_cancel() < 0)
return TIMER_RETRY;
....
hrtimer_start();
return;
back in sys_timer_settime()
unlock_timer(timr);
So how gets this timer added back, when the container lock is held
across the complete operation ?
> Now the question is what's the right solution? Can hrtimer_start
> schedule? Probably not, maybe we should add something to check this and
> have hrtimer_start return -1 if it is running, and let who ever called
> it figure out what to do? Maybe have a hrtimer_cancel_start atomic
> operation? As well as a hrtimer_try_to_cancel_start?
The posix timer code does already the Right Thing, as it uses
hrtimer_try_to_cancel() and reacts on the return value. This is
necessary to prevent a dead lock with the k_itimer lock.
I try to reproduce this with your test program on my test boxes.
tglx
next prev parent reply other threads:[~2006-01-17 17:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-12 11:02 Thomas Gleixner
2005-12-12 13:56 ` Steven Rostedt
2005-12-13 21:05 ` Steven Rostedt
2005-12-14 8:40 ` Ingo Molnar
2005-12-14 8:43 ` Ingo Molnar
2005-12-14 13:48 ` Steven Rostedt
2005-12-14 14:01 ` Thomas Gleixner
2005-12-14 14:01 ` Steven Rostedt
2005-12-14 15:43 ` [PATCH -RT] Add softirq waitqueue for CONFIG_PREEMPT_SOFTIRQ (was: Re: [ANNOUNCE] 2.6.15-rc5-hrt2 ...) Steven Rostedt
2005-12-14 16:17 ` Daniel Walker
2005-12-20 13:28 ` Ingo Molnar
2005-12-14 14:04 ` [ANNOUNCE] 2.6.15-rc5-hrt2 - hrtimers based high resolution patches Steven Rostedt
2005-12-14 19:28 ` Steven Rostedt
2006-01-10 23:59 ` Steven Rostedt
2006-01-12 2:14 ` Steven Rostedt
2006-01-12 2:51 ` [PATCH RT] fix or hrtimers (was: [ANNOUNCE] 2.6.15-rc5-hrt2 - hrtimers based high resolution patches) Steven Rostedt
2006-01-12 11:10 ` Steven Rostedt
2006-01-17 17:35 ` Thomas Gleixner [this message]
2005-12-14 18:33 ` [ANNOUNCE] 2.6.15-rc5-hrt2 - hrtimers based high resolution patches Jeff Carr
2005-12-15 0:41 ` Jeff Carr
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=1137519305.17609.48.camel@localhost.localdomain \
--to=tglx@linutronix.de \
--cc=george@mvista.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=zippel@linux-m68k.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
Powered by JetHome