public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: Peter Rosin <peda@axentia.se>,
	linux-kernel@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Philippe Ombredanne <pombredanne@nexb.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-i2c@vger.kernel.org, Peter Chang <dpf@google.com>,
	Deepa Dinamani <deepadinamani@google.com>,
	John Sperbeck <jsperbeck@google.com>
Subject: Re: [PATCH v3 1/2] rtmutex: allow specifying a subclass for nested locking
Date: Mon, 28 May 2018 09:17:51 +0200	[thread overview]
Message-ID: <20180528071751.GT12180@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180528051936.GA205298@joelaf.mtv.corp.google.com>

On Sun, May 27, 2018 at 10:19:36PM -0700, Joel Fernandes wrote:

> > +static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass)
> > +{
> > +	might_sleep();
> > +
> > +	mutex_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
> > +	rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock);
> > +}
> > +
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > +/**
> > + * rt_mutex_lock_nested - lock a rt_mutex
> 
> This ifdef seems consistent with other nested locking primitives, but its
> kind of confusing.
> 
> The Kconfig.debug for DEBUG_LOCK_ALLOC says:
> 
> config DEBUG_LOCK_ALLOC
> 	bool "Lock debugging: detect incorrect freeing of live locks"
> 	[...]
> 	help
> 	 This feature will check whether any held lock (spinlock, rwlock,
> 	 mutex or rwsem) is incorrectly freed by the kernel, via any of the
> 	 memory-freeing routines (kfree(), kmem_cache_free(), free_pages(),
> 	 vfree(), etc.), whether a live lock is incorrectly reinitialized via
> 	 spin_lock_init()/mutex_init()/etc., or whether there is any lock
> 	 held during task exit.
> 
> Shouldn't this ideally be ifdef'd under PROVE_LOCKING for this and other
> locking primitives? Any idea what's the reason? I know PROVE_LOCKING selects
> DEBUG_LOCK_ALLOC but still..

No, the reason is that DEBUG_LOCK_ALLOC needs the lockdep hooks to know
which locks are held, so it can warn when we try and free a held one.
PROVE_LOCKING builds upon that.

The the locking primitives should key off of DEBUG_LOCK_ALLOC for
introducing the hooks.

  reply	other threads:[~2018-05-28  7:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAFNjLiXZk3Zigfpy9Hj2uY92sPGB7msUxoZHf6pFDOWSuBwkBA@mail.gmail.com>
2018-05-24  7:32 ` Problem: lockdep warning with nested instances of i2c-mux Peter Rosin
2018-05-24  7:32   ` [PATCH 1/2] rtmutex: allow specifying a subclass for nested locking Peter Rosin
2018-05-26  8:23     ` kbuild test robot
2018-05-26  8:23     ` kbuild test robot
2018-05-26  9:26     ` kbuild test robot
2018-05-24  7:32   ` [PATCH 2/2] i2c: mux: annotate the nested rt_mutex usage Peter Rosin
2018-05-26 10:11     ` kbuild test robot
2018-05-24  8:46 ` [PATCH v2 0/2] Re: Problem: lockdep warning with nested instances of i2c-mux Peter Rosin
2018-05-24  8:46   ` [PATCH v2 1/2] rtmutex: allow specifying a subclass for nested locking Peter Rosin
2018-05-24  8:46   ` [PATCH v2 2/2] i2c: mux: annotate the nested rt_mutex usage Peter Rosin
2018-05-24 13:52 ` [PATCH v3 0/2] Re: Problem: lockdep warning with nested instances of i2c-mux Peter Rosin
2018-05-24 13:52   ` [PATCH v3 1/2] rtmutex: allow specifying a subclass for nested locking Peter Rosin
2018-05-28  5:19     ` Joel Fernandes
2018-05-28  7:17       ` Peter Zijlstra [this message]
2018-05-28 20:51         ` Joel Fernandes
2018-05-24 13:52   ` [PATCH v3 2/2] i2c: mux: annotate the nested rt_mutex usage Peter Rosin
2018-05-24 18:21   ` [PATCH v3 0/2] Re: Problem: lockdep warning with nested instances of i2c-mux John Sperbeck

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=20180528071751.GT12180@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dave@stgolabs.net \
    --cc=deepadinamani@google.com \
    --cc=dpf@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joel@joelfernandes.org \
    --cc=jsperbeck@google.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peda@axentia.se \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    --cc=wsa@the-dreams.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