All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: tglx@linutronix.de, jsperbeck@google.com,
	linux-kernel@vger.kernel.org, wsa@the-dreams.de,
	mingo@kernel.org, dave@stgolabs.net, dpf@google.com,
	pombredanne@nexb.com, deepadinamani@google.com,
	peterz@infradead.org, gregkh@linuxfoundation.org,
	will.deacon@arm.com, torvalds@linux-foundation.org,
	hpa@zytor.com, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:locking/urgent] i2c/mux, locking/core: Annotate the nested rt_mutex usage
Date: Mon, 30 Jul 2018 18:09:40 +0200	[thread overview]
Message-ID: <0bb2d26f-3d1a-fcb8-8fc4-9123a2d5a30d@axentia.se> (raw)
In-Reply-To: <tip-7b94ea50514d1a0dc94f02723b603c27bc0ea597@git.kernel.org>

On 2018-07-25 16:19, tip-bot for Peter Rosin wrote:
> Commit-ID:  7b94ea50514d1a0dc94f02723b603c27bc0ea597
> Gitweb:     https://git.kernel.org/tip/7b94ea50514d1a0dc94f02723b603c27bc0ea597
> Author:     Peter Rosin <peda@axentia.se>
> AuthorDate: Fri, 20 Jul 2018 10:39:14 +0200
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Wed, 25 Jul 2018 11:22:20 +0200
> 
> i2c/mux, locking/core: Annotate the nested rt_mutex usage

Hi!

I'm a bit curious as to why the subject line was changed on this patch?

(it was "[PATCH v4 2/2] i2c: mux: annotate the nested rt_mutex usage")

I thought the subject as I wrote it was just perfect. Was it so bad that it
had to be edited?

The patch has no impact on "locking/core" so where is that coming from?
The "i2c/mux" prefix is not in tune with the tradition of previous commits
to drivers/i2c/i2c-mux.c ...

    i2c: mux: improve error message for failed symlink
    i2c: mux: only print failure message on error
    i2c: mux: provide more info on failure in i2c_mux_add_adapter
    i2c: add missing of_node_put in i2c_mux_del_adapters
    i2c: move locking operations to their own struct
    Merge branch 'i2c-mux-dt-3' of https://github.com/peda-r/i2c-mux into i2c/for-4.9
    i2c: mux: add support for 'i2c-mux', 'i2c-arb' and 'i2c-gate' DT subnodes
    i2c: add i2c_trylock_bus wrapper, use it
    i2c: mux: relax locking of the top i2c adapter during mux-locked muxing
    i2c: muxes always lock the parent adapter
    i2c: mux: drop old unused i2c-mux api
    i2c: mux: add common data for every i2c-mux instance
    i2c: i2c-mux: sort includes
    i2c: add ACPI support for I2C mux ports
    i2c: mux: Use __i2c_transfer() instead of calling parent's master_xfer()
    i2c: use parent adapter quirks in mux
    i2c: mux: use proper dev when removing "channel-X" symlinks
    i2c: mux: create "channel-n" symlinks for child segments in the mux device
    i2c: mux: create symlink to actual mux device
    ...

... and my subject followed the canonical subject format as described in
section 14 of Documentation/process/submitting-patches.rst ...

    Subject: [PATCH 001/123] subsystem: summary phrase

... I.e. I don't see why you insist on starting the summary phrase of the
subject with a capitalized "Annotate". As I have understood it, the summary
phrase is not a sentence (or it should end with a period).

Three "bad" decisions on one line is a bit much, I think. I don't care deeply,
though (but apparently it bugs me enough to write this, and the reason for that
is probably that one will get abundant feedback on such syntax during review
that it is a pest to then have all that hard-learned "experience" eradicated
on what seems like a whim). Anyway, as I said, the change sparked my curiosity...

And I want *answers* :-)

Cheers,
Peter

> 
> If an i2c topology has instances of nested muxes, then a lockdep splat
> is produced when when i2c_parent_lock_bus() is called.  Here is an
> example:
> 
>   ============================================
>   WARNING: possible recursive locking detected
>   --------------------------------------------
>   insmod/68159 is trying to acquire lock:
>     (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
> 
>   but task is already holding lock:
>     (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
> 
>   other info that might help us debug this:
>     Possible unsafe locking scenario:
> 
>           CPU0
>           ----
>      lock(i2c_register_adapter#2);
>      lock(i2c_register_adapter#2);
> 
>     *** DEADLOCK ***
> 
>     May be due to missing lock nesting notation
> 
>   1 lock held by insmod/68159:
>     #0:  (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
> 
>   stack backtrace:
>   CPU: 13 PID: 68159 Comm: insmod Tainted: G           O
>   Call Trace:
>     dump_stack+0x67/0x98
>     __lock_acquire+0x162e/0x1780
>     lock_acquire+0xba/0x200
>     rt_mutex_lock+0x44/0x60
>     i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
>     i2c_parent_lock_bus+0x3e/0x50 [i2c_mux]
>     i2c_smbus_xfer+0xf0/0x700
>     i2c_smbus_read_byte+0x42/0x70
>     my2c_init+0xa2/0x1000 [my2c]
>     do_one_initcall+0x51/0x192
>     do_init_module+0x62/0x216
>     load_module+0x20f9/0x2b50
>     SYSC_init_module+0x19a/0x1c0
>     SyS_init_module+0xe/0x10
>     do_syscall_64+0x6c/0x1a0
>     entry_SYSCALL_64_after_hwframe+0x42/0xb7
> 
> Reported-by: John Sperbeck <jsperbeck@google.com>
> Tested-by: John Sperbeck <jsperbeck@google.com>
> Signed-off-by: Peter Rosin <peda@axentia.se>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Cc: Deepa Dinamani <deepadinamani@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Chang <dpf@google.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Link: http://lkml.kernel.org/r/20180720083914.1950-3-peda@axentia.se
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  drivers/i2c/i2c-core-base.c | 2 +-
>  drivers/i2c/i2c-mux.c       | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 301285c54603..15c95aaa484c 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -624,7 +624,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
>  static void i2c_adapter_lock_bus(struct i2c_adapter *adapter,
>  				 unsigned int flags)
>  {
> -	rt_mutex_lock(&adapter->bus_lock);
> +	rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
>  }
>  
>  /**
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 300ab4b672e4..29646aa6132e 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -144,7 +144,7 @@ static void i2c_mux_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
>  	struct i2c_mux_priv *priv = adapter->algo_data;
>  	struct i2c_adapter *parent = priv->muxc->parent;
>  
> -	rt_mutex_lock(&parent->mux_lock);
> +	rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
>  	if (!(flags & I2C_LOCK_ROOT_ADAPTER))
>  		return;
>  	i2c_lock_bus(parent, flags);
> @@ -181,7 +181,7 @@ static void i2c_parent_lock_bus(struct i2c_adapter *adapter,
>  	struct i2c_mux_priv *priv = adapter->algo_data;
>  	struct i2c_adapter *parent = priv->muxc->parent;
>  
> -	rt_mutex_lock(&parent->mux_lock);
> +	rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
>  	i2c_lock_bus(parent, flags);
>  }
>  
> 


  reply	other threads:[~2018-07-30 16:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20  8:39 [PATCH v4 0/2] Fix lockdep warning with nested instances of i2c-mux Peter Rosin
2018-07-20  8:39 ` [PATCH v4 1/2] rtmutex: allow specifying a subclass for nested locking Peter Rosin
2018-07-25 14:18   ` [tip:locking/urgent] locking/rtmutex: Allow " tip-bot for Peter Rosin
2018-09-10 23:27   ` [PATCH v4 1/2] rtmutex: allow " Steven Rostedt
2018-09-11  0:58     ` Peter Rosin
2018-07-20  8:39 ` [PATCH v4 2/2] i2c: mux: annotate the nested rt_mutex usage Peter Rosin
2018-07-25 14:19   ` [tip:locking/urgent] i2c/mux, locking/core: Annotate " tip-bot for Peter Rosin
2018-07-30 16:09     ` Peter Rosin [this message]
2018-07-30 17:17       ` Ingo Molnar

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=0bb2d26f-3d1a-fcb8-8fc4-9123a2d5a30d@axentia.se \
    --to=peda@axentia.se \
    --cc=dave@stgolabs.net \
    --cc=deepadinamani@google.com \
    --cc=dpf@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jsperbeck@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.