From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Jiri Kosina <jikos@jikos.cz>, LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@openvz.org>,
Kirill Korotaev <dev@sw.ru>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] printk deadlocks if called with runqueue lock held
Date: Fri, 18 Jan 2008 09:30:20 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.1.00.0801180918110.2957@woody.linux-foundation.org> (raw)
In-Reply-To: <4790BDD1.40808@siemens.com>
On Fri, 18 Jan 2008, Jan Kiszka wrote:
> Steven Rostedt wrote:
> ...
> > @@ -978,7 +980,13 @@ void release_console_sem(void)
> > console_locked = 0;
> > up(&console_sem);
>
> Hmm, just looking at this fragment: Doesn't up() include the risk of
> running onto the runqueue lock as well?
In theory yes.
I suspect it would never ever be a problem in practice (the case we care
about is running with interrupts disabled, and we got it with
down_trylock()), so as this is only about essentially custon debug or oops
things anyway, it's probably not worth fixing.
That said, you're definitely right in theory.
But *IF* we want to fix the almost certainly purely theoretical problem,
it would be possible but fairly ugly.
We'd need to (a) make it a mutex rather than a semaphore (which is
definitely not the ugly part), and then - the ugly part - (b) expose a
whole new mutex interface: an enhanched version of "mutex_trylock()" that
*also* keeps the mutex spinlock locked, and then instead of using
"mutex_unlock()" we'd use a special "mutex_unlock_atomic()" that knows the
spinlock was held over the whole time.
So it would then use something like
if (mutex_trylock_atomic(..)) {
mutex_unlock_atomic(..);
}
and that would work out ok.
It's likely not that hard, and in fact this may be why "console_sem" was
never converted to a mutex: I think Ingo tried, but it didn't work right
with debugging enabled, and I can well imagine that it was all due to this
issue. But if we do those _atomic() versions, we'd probably fix that
problem.
So maybe the "ugly new interface" would actually be a cleanup in the long
run, by possibly fixing the fact that things just *happened* to work with
semaphores because they didn't do the fancy debug version..
Ingo?
Linus
next prev parent reply other threads:[~2008-01-18 17:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-18 1:04 Steven Rostedt
2008-01-18 1:19 ` Andrew Morton
2008-01-18 1:57 ` Steven Rostedt
2008-01-18 1:31 ` Linus Torvalds
2008-01-18 1:52 ` Steven Rostedt
2008-01-18 11:04 ` Jiri Kosina
2008-01-18 11:35 ` Steven Rostedt
2008-01-18 14:55 ` Jan Kiszka
2008-01-18 16:26 ` Steven Rostedt
2008-01-18 17:30 ` Linus Torvalds [this message]
2008-01-23 13:31 ` Pavel Machek
2008-01-23 18:36 ` Steven Rostedt
2008-01-24 9:00 ` Pavel Machek
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=alpine.LFD.1.00.0801180918110.2957@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=adobriyan@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=dev@sw.ru \
--cc=jan.kiszka@siemens.com \
--cc=jikos@jikos.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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®