Re: [PATCH] regulator: userspace-consumer: Use atomic operation

From: Zev Weiss
Date: Thu Aug 24 2023 - 15:33:21 EST


On Thu, Aug 24, 2023 at 09:55:41AM PDT, Mark Brown wrote:
On Thu, Aug 24, 2023 at 04:34:05PM +0530, Naresh Solanki wrote:
On Wed, 23 Aug 2023 at 20:41, Mark Brown <broonie@xxxxxxxxxx> wrote:
> On Wed, Aug 23, 2023 at 04:15:57PM +0200, Naresh Solanki wrote:

> > Replace mutexes with atomic operations.

> Why? Generally atomics are more complicated and hard to understand and
> get right.

Since the operations involved here are simple & short & can be managed by
atomic operation.

Unless there's a strong positive reason to specifically use atomics it
seems better to avoid them, like I say they're full of landmines with
unexpeted behaviours and therefore something that sets off alarm bells
about needing careful study, the mutex is going to be less preformant
but is also much more clearly correct.

I assume this patch was posted as a result of a comment I made on the original patch [1], but in hindsight I probably shouldn't have suggested it as it's a relatively minor issue either way -- I think the other things brought up in that email are much more significant concerns. Honestly I don't think that patch should be applied in its present form, though I see it's still present in the regulator/for-next and regulator/for-6.6 branches -- Mark, do you intend to include it as-is in your pull request to Linus for the 6.6 merge window?

[1] https://lore.kernel.org/lkml/d3ea0fe2-00bb-493b-aca7-ba7a31bd3c78@xxxxxxxxxxxxxxxxxxxxxxxx/


Zev