From: Peter Zijlstra <peterz@infradead.org>
To: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rt_mutex: correctly initialize lockdep in rt_mutex_init_proxy_locked
Date: Mon, 12 Jun 2017 14:34:43 +0200 [thread overview]
Message-ID: <20170612123443.ddpij6zws6jydfdj@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20170611145122.j3oxf6nsswc5okr7@sasha-lappy>
On Sun, Jun 11, 2017 at 02:51:09PM +0000, Levin, Alexander (Sasha Levin) wrote:
> On Sat, Jun 10, 2017 at 04:02:12PM +0200, Peter Zijlstra wrote:
> > On Sat, Jun 10, 2017 at 02:48:04AM +0000, Levin, Alexander (Sasha Levin) wrote:
> > > lockdep can't deal with NULL name or key, and doesn't do anything
> > > with the lock when that happens.
> >
> > Not doing anything is 'right', the proxy stuff won't be lockdep tracked
> > anyway. But yeah, the first thing is a wee bit of a problem, for it will
> > trigger DEBUG_LOCKS_WARN_ON() and fully kill lockdep.
>
> But don't we want pi_state->pi_mutex tracked by lockdep?
Nope, we can't. That pi_mutex is owned by userspace and not all
operations upon it are visible to the kernel. That is, a userspace
thread can (conceptually) acquire the lock without the kernel ever
knowing.
We typically only create the pi_state when there's contention, at which
point we create the pi_mutex as owned by someone else (hence proxy).
Also, we 'obviously' hold the thing over the return to userspace, which
is something lockdep very much doesn't like.
> > Yeah, no need to do that; all we really need here is something like:
> >
> > ---
> > kernel/locking/rtmutex-debug.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/locking/rtmutex-debug.c b/kernel/locking/rtmutex-debug.c
> > index ac35e648b0e5..8dc647dc4b4b 100644
> > --- a/kernel/locking/rtmutex-debug.c
> > +++ b/kernel/locking/rtmutex-debug.c
> > @@ -175,7 +175,8 @@ void debug_rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_cl
> > lock->name = name;
> >
> > #ifdef CONFIG_DEBUG_LOCK_ALLOC
> > - lockdep_init_map(&lock->dep_map, name, key, 0);
> > + if (name && key)
> > + lockdep_init_map(&lock->dep_map, name, key, 0);
> > #endif
> > }
>
> I didn't want to do that because in later calls on that mutex we
> will end up going into lockdep code, and I didn't think that doing
> that without calling lockdep_init_map() initially was safe.
So futex has its own private rt_mutex implementation and interface, none
of which include lockdep hooks. So not initializing the field for that
case should not be a problem.
prev parent reply other threads:[~2017-06-12 12:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-10 2:48 Levin, Alexander (Sasha Levin)
2017-06-10 14:02 ` Peter Zijlstra
2017-06-11 14:51 ` Levin, Alexander (Sasha Levin)
2017-06-12 12:34 ` Peter Zijlstra [this message]
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=20170612123443.ddpij6zws6jydfdj@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=alexander.levin@verizon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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®