All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-iio <linux-iio@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>, Peter Meerwald <pmeerw@pmeerw.net>
Subject: Re: atomic use is not atomic?
Date: Tue, 8 Jun 2021 14:44:14 +0200	[thread overview]
Message-ID: <eb9f9c75-98c9-0f93-7fd9-565061c78cf0@metafoo.de> (raw)
In-Reply-To: <CAHp75VfuoWi72b1wAYoJD_mF6+s-h7k7JCU3CFbEzuGtYBuCZA@mail.gmail.com>

On 6/8/21 2:35 PM, Andy Shevchenko wrote:
> Hi!
>
> Can anybody explain this code [1] in terms of atomicity?
>
>    if (!atomic_read(&trig->use_count)) {
>      atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
>      ...
>    }
>
> AFAIU how atomics are supposed to work the above doesn't do anything
> atomically. I.o.w. use_count may be simple int with the same effect.
>
The operations here do not require atomic access, it is just operating 
on a atomic type. The atomic access is the atomic_dec_and_test() in 
iio_trigger_notify_done().

  reply	other threads:[~2021-06-08 12:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 12:35 atomic use is not atomic? Andy Shevchenko
2021-06-08 12:44 ` Lars-Peter Clausen [this message]
2021-06-08 13:14   ` Andy Shevchenko
2021-06-08 13:22     ` Lars-Peter Clausen
2021-06-08 13:30       ` Andy Shevchenko
2021-06-08 16:00         ` Jonathan Cameron

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=eb9f9c75-98c9-0f93-7fd9-565061c78cf0@metafoo.de \
    --to=lars@metafoo.de \
    --cc=andy.shevchenko@gmail.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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.