mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Doug Anderson <dianders@chromium.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, Stephen Boyd <swboyd@chromium.org>
Subject: Re: [PATCH v2 3/7] regulator/core: regulator_lock_nested: simplify nested locking
Date: Fri, 1 Sep 2023 00:41:32 +0200	[thread overview]
Message-ID: <ZPEXHIAMM4+MXaHD@qmqm.qmqm.pl> (raw)
In-Reply-To: <CAD=FV=Uzu=37nqGZYu4cU7fMMV2u+e8-GF1+izcvusOT+a1f=Q@mail.gmail.com>

On Wed, Aug 30, 2023 at 01:54:21PM -0700, Doug Anderson wrote:
> On Wed, Aug 30, 2023 at 10:35 AM Michał Mirosław
> <mirq-linux@rere.qmqm.pl> wrote:
> >
> > Simplify regulator locking by removing locking around locking.
> > rdev->ref check when unlocking is moved inside the critical section.
> >
> > This patch depends on commit 12235da8c80a ("kernel/locking: Add context
> > to ww_mutex_trylock()").
> >
> > Note: return -EALREADY is removed as no caller depends on it and in that
> > case the lock count is incremented anyway.
> >
> > Reviewed-by: Douglas Anderson <dianders@chromium.org>
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  drivers/regulator/core.c | 23 ++++++-----------------
> >  1 file changed, 6 insertions(+), 17 deletions(-)
> 
> Note that I didn't actually provide a Reviewed-by on this patch in v1.
> I was hoping for something in the commit message that explained why
> commit 12235da8c80a ("kernel/locking: Add context to
> ww_mutex_trylock()") meant that we didn't need the extra lock. You
> responded to the v1, but didn't add anything to the commit message
> about it.
> 
> Looking at your response to v1, I'm not sure it helps enlighten me on
> why adding the context removed the need for the extra lock. Can you
> add more words? Pretend I don't know anything about ww_mutex, which is
> not far from the truth since every time I look at ww_mutex I have to
> re-learn how it works. :-P Specifically, what would actually have been

Thanks for all your (and Stephen's) questions and comments! I had a bit
more of thinking and reading time about the W/W mutex and how it works.
It turns out I can remove some noise from this commit.

The commit 12235da8c80a dependency is due to text changes: the original
code would need a bit of reordering, all not much different than the
two previous patches.

If ww_mutex_lock() was able to return -EALREADY with NULL ww_ctx,
regulator_lock_nested() could be made even simpler.

Best Regards,
Michał Mirosław

  reply	other threads:[~2023-08-31 22:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 17:35 [PATCH v2 0/7] regulator: core: locking cleanups, part 1/inf Michał Mirosław
2023-08-30 17:35 ` [PATCH v2 1/7] regulator/core: regulator_lock_nested: remove `lock` Michał Mirosław
2023-08-30 17:35 ` [PATCH v2 2/7] regulator/core: regulator_lock_nested: skip extra lock for -EDEADLK Michał Mirosław
2023-08-30 17:35 ` [PATCH v2 3/7] regulator/core: regulator_lock_nested: simplify nested locking Michał Mirosław
2023-08-30 20:36   ` Stephen Boyd
2023-08-31 22:43     ` Michał Mirosław
2023-08-30 20:54   ` Doug Anderson
2023-08-31 22:41     ` Michał Mirosław [this message]
2023-08-30 17:35 ` [PATCH v2 5/7] regulator/core: regulator_lock_contended: wrap ww_mutex lock sequence restart Michał Mirosław
2023-08-30 20:21   ` Doug Anderson
2023-08-30 17:35 ` [PATCH v2 4/7] regulator/core: regulator_resolve_supply: remove gotos Michał Mirosław
2023-08-30 17:35 ` [PATCH v2 7/7] regulator/core: regulator_lock_two: remove duplicate locking code Michał Mirosław
2023-08-30 20:33   ` Doug Anderson
2023-08-30 17:35 ` [PATCH v2 6/7] regulator/core: regulator_lock_two: propagate error up Michał Mirosław
2023-08-30 20:32   ` Doug Anderson

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=ZPEXHIAMM4+MXaHD@qmqm.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swboyd@chromium.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®