lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 27 Oct 2009 00:30:45 +0530
From:	"Leonidas ." <leonidas137@...il.com>
To:	Chris Friesen <cfriesen@...tel.com>
Cc:	Noah Watkins <noah@...hdesu.com>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: Difference between atomic operations and memory barriers

On Tue, Oct 27, 2009 at 12:24 AM, Chris Friesen <cfriesen@...tel.com> wrote:
> On 10/26/2009 12:22 PM, Leonidas . wrote:
>> On Mon, Oct 26, 2009 at 11:49 PM, Noah Watkins <noah@...hdesu.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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ