From: "Leonidas ." <leonidas137@gmail.com>
To: Chris Friesen <cfriesen@nortel.com>
Cc: Noah Watkins <noah@noahdesu.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Difference between atomic operations and memory barriers
Date: Tue, 27 Oct 2009 00:30:45 +0530 [thread overview]
Message-ID: <f22d86810910261200n130fda06r46fdbcc808195002@mail.gmail.com> (raw)
In-Reply-To: <4AE5F04E.3050908@nortel.com>
On Tue, Oct 27, 2009 at 12:24 AM, Chris Friesen <cfriesen@nortel.com> wrote:
> On 10/26/2009 12:22 PM, Leonidas . wrote:
>> On Mon, Oct 26, 2009 at 11:49 PM, Noah Watkins <noah@noahdesu.com> wrote:
>>>> Trying to understand difference between atomic ops and memory barriers.
>>>>
>>> There is a bit of info in:
>>> Documentation/atomic_ops.txt
>
>> Thanks for the pointer, there are no atomic operations for pointers, right?
>> I guess barrier is what we need in that case.
>
> You need barriers for the atomics too, at least in some cases. From
> that document:
>
> *** WARNING: atomic_read() and atomic_set() DO NOT IMPLY BARRIERS! ***
>
>
> For simple assignments, I'm fairly sure linux assumes that writes to
> individual variables are atomic. ie, if you're assigning to an int you
> won't get half of the assignment completed while the other half isn't.
>
> What the atomic ops buy you is the ability to do increment-and-test,
> compare-and-exchange, etc. in an atomic fashion.
>
> Barriers are needed to make sure that operations are visible on other
> cpus in the correct order, and to ensure that the compiler doesn't
> reorder the operations.
>
> If you use the normal locking mechanisms (mutexes, spinlocks, etc.) the
> barriers are implicit in the lock.
>
> Chris
>
This takes it a step further ! Thanks for the info.
But locks are expensive for simpler assignments like integer assignment thats
why there are atomic counter parts, but there is no such things for
pointers right?
So we can safely assume that pointer assignment will be done in an
atomic manner?
-Leo.
next prev parent reply other threads:[~2009-10-26 19:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-26 17:19 Leonidas .
[not found] ` <7ADB5FD7-9C97-4987-BC20-997258B25FD2@noahdesu.com>
2009-10-26 18:22 ` Leonidas .
2009-10-26 18:54 ` Chris Friesen
2009-10-26 19:00 ` Leonidas . [this message]
2009-10-26 19:07 ` Noah Watkins
2009-10-26 19:34 ` Stefan Richter
2009-10-26 19:42 ` Noah Watkins
2009-10-27 11:51 ` Valdis.Kletnieks
2009-10-28 10:00 ` Boaz Harrosh
2009-10-28 13:26 ` Valdis.Kletnieks
2009-10-26 19:00 ` Stefan Richter
2009-10-26 19:05 ` Leonidas .
2009-10-27 10:21 ` Michael Schnell
2009-10-27 10:23 ` Leonidas .
2009-10-27 11:01 ` Michael Schnell
2009-10-27 14:57 ` Stefan Richter
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=f22d86810910261200n130fda06r46fdbcc808195002@mail.gmail.com \
--to=leonidas137@gmail.com \
--cc=cfriesen@nortel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=noah@noahdesu.com \
/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®