From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>, kernel <kernel@axis.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Rosin <peda@axentia.se>
Subject: Re: [PATCH] iio: buffer: Silence lock nesting splat
Date: Tue, 23 Aug 2022 10:12:33 +0200 [thread overview]
Message-ID: <YwSL8VD78u0ea0Qb@axis.com> (raw)
In-Reply-To: <ff2bc13c-f66f-03f3-fc01-c4f962f7b694@metafoo.de>
On Sat, Aug 20, 2022 at 01:08:28PM +0200, Lars-Peter Clausen wrote:
> There are two different approaches for this kind of nested locking. One
> is to use mutex_lock_nested(). This works if there is a strict
> hierarchy. The I2C framework for example has a function to determine the
> position of a I2C mux in the hierarchy and uses that for locking. See
> https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L1151.
>
> I'm not sure this directly translates to IIO since the
> consumers/producers don't have to be a in strict hierarchy. And if it
> is a complex graph it can be difficult to figure out the right level for
> mutex_lock_nested().
>
> The other method is to mark each mutex as its own class. lockdep does
> the lock checking based on the lock class and by default the same mutex
> of different instances is considered the same class to keep the resource
> requirements for the checker lower.
>
> Regmap for example does this. See
> https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regmap.c#L795.
>
> This could be a solution for IIO with the downside how the additional
> work for the checker. But as long as there are only a few IIO devices
> per system that should be OK. We could also only set the per device lock
> class if in kernel consumers are enabled.
The second method certainly sounds like a better fix, since it also
still warns if one actually takes the same iio_dev mutex twice. I'll
respin the patch. Thanks.
prev parent reply other threads:[~2022-08-23 8:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 8:08 [PATCH] iio: buffer: Silence lock nesting splat Vincent Whitchurch
2022-08-19 8:03 ` Andy Shevchenko
2022-08-20 11:08 ` Jonathan Cameron
2022-08-23 8:10 ` Vincent Whitchurch
2022-08-28 15:32 ` Jonathan Cameron
2022-09-01 7:04 ` Vincent Whitchurch
2022-08-20 11:06 ` Jonathan Cameron
2022-08-20 11:08 ` Lars-Peter Clausen
2022-08-23 8:12 ` Vincent Whitchurch [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=YwSL8VD78u0ea0Qb@axis.com \
--to=vincent.whitchurch@axis.com \
--cc=jic23@kernel.org \
--cc=kernel@axis.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
/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.