From: "Remy Bohmer" <linux@bohmer.net>
To: "Steven Rostedt" <rostedt@goodmis.org>
Cc: "Ingo Molnar" <mingo@elte.hu>,
"Thomas Gleixner" <tglx@linutronix.de>,
RT <linux-rt-users@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG on PREEMPT_RT, 2.6.23.1-rt5] in rt-mutex code and signals
Date: Sat, 17 Nov 2007 16:36:08 +0100 [thread overview]
Message-ID: <3efb10970711170736u469bbbc5p8c227ca2a12657dd@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0711170840130.4453@gandalf.stny.rr.com>
Hello Steven,
> It should print out warnings, do you have CONFIG_DEBUG_RT_MUTEXES set?
Nope, not yet... I will do that on Monday also. (On ARM I have as less
as debug options enabled per default, because it eats too much
CPU-power)
> > * PI should only take place if it is for 100% sure that the 'struct
> > semaphore' is used as a mutex. And this is only the case when it is
> > initialised with init_MUTEX().
>
> Well, we can't determine that with code ;-) Remember, there are still
> drivers out in the world that use semaphores as mutexes. So the PI
> on semaphores is really more of a compatibility issue.
Very strange, although there is now a real mutex in non-RT as in RT,
all semaphores are still converted to some
badly-implemented-recursive-but-not-recursive-callable-mutexes,
because the assumption is made that semaphores are intentionally
always used in the wrong way?!!
So, the code that is written nicely must be adapted to prevent
adaption of bad code?
I would expect a more logical solution like the introduction of raw_
types for the exceptions, just like what is done with spinlocks and so
on.
> > So, this is a regression if exactly the same driver is used in both
> > non-preempt-rt patched kernel and preempt-rt patched kernels.
>
> Not really. There are things that the preempt-rt kernels require. One, is
> that things that need to keep semaphores instead of using them as mutexes,
> they should be converted to compat_semaphores. Perhaps now that we have
> mutexes, we can remove the PI on semaphores, and out-of-tree drivers will
> need to make sure they don't use semaphores as mutexes anymore.
Up to this semaphore implementation the standard was always that a
driver written for a non-RT kernel should compile and work properly
without any adaption on a RT-kernel, until there are some specific
realtime requirements.
When it comes to semaphores this is thus completely not true.
And this is where the whole thing confused me completely.
> Yeah, that code is more of a hack to convert counting semaphores into
> mutexes.
Enough said...
> But semaphores still need to have owners, and they should not
> block on themselves. That may be where the bug is.
Or there should be a real recursive mutex implementation. But the need
for recursive mutexes is usually a sign for bad locking, and should
therefor be avoided.
> OK, I wont be able to work on this this weekend, but I'll try to get to it
> on Monday. A better example to show the bug you are looking for is simply
> create a mutex and create a thread that grabs that mutex and goes to
> sleep. Have your driver read grab that mutex with
> mutex_lock_interruptible. And if the signal code is broken with this, then
> you definitely got a point that the inerruptible code is broken.
I will work on an example like this on Monday.
> This will keep the semantics clean and not obfuscate it with the semaphore
> code.
I agree.
> I'll write up that example on Monday if you don't have the time.
I will make time ;-)
> Note, that the unloading of the module should wake up the thread that
> grabbed the mutex so it can release it.
Unloading of a module is not possible as long as there is still a
handle open to it. So, it should be safe without waking up the thread.
And returning from the read call and still have a mutex locked is not
nice either.
Thanks for the explanation. I will keep you informed on Monday.
Have a nice weekend !
Remy
next prev parent reply other threads:[~2007-11-17 15:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 15:51 Remy Bohmer
2007-11-16 20:20 ` Steven Rostedt
2007-11-16 23:02 ` Remy Bohmer
2007-11-16 23:37 ` Steven Rostedt
2007-11-17 11:44 ` Remy Bohmer
2007-11-17 14:08 ` Steven Rostedt
2007-11-17 15:06 ` Steven Rostedt
2007-11-17 15:36 ` Remy Bohmer [this message]
2007-11-19 12:55 ` Remy Bohmer
2007-11-19 13:54 ` Steven Rostedt
2007-11-17 16:22 ` Daniel Walker
2007-11-17 17:09 ` Remy Bohmer
2007-11-17 17:29 ` Daniel Walker
2007-11-17 17:46 ` Ingo Molnar
2007-11-17 17:55 ` Daniel Walker
2007-11-17 18:04 ` Ingo Molnar
2007-11-17 18:12 ` Daniel Walker
2007-11-18 12:33 ` Peter Zijlstra
2007-11-18 22:26 ` David Chinner
2007-11-17 22:49 ` Remy Bohmer
2007-11-19 7:25 ` Jon Masters
2007-11-19 15:31 ` Daniel Walker
2007-11-19 15:51 ` Remy Bohmer
2007-11-19 16:11 ` Daniel Walker
2007-11-20 16:43 ` Daniel Walker
2007-11-20 20:37 ` Ingo Molnar
2007-11-20 20:54 ` Daniel Walker
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=3efb10970711170736u469bbbc5p8c227ca2a12657dd@mail.gmail.com \
--to=linux@bohmer.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--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
all inboxes | Powered by JetHome®