tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: atomic read in atomic_ops(9)



Le 26/12/11 17:39, David Laight a écrit :
On Mon, Dec 26, 2011 at 01:26:31AM +0100, Joerg Sonnenberger wrote:
On Mon, Dec 26, 2011 at 01:01:01AM +0100, Jean-Yves Migeon wrote:
I encounter situations where I'd like to read a 64 bits value
atomically under a 32 bits platform (canonical example is Xen
balloon(4)), yet the current atomic_ops(9) functions do not provide
a stub for it.

Well, there is no general way to do atomic reads of 64bit values.
On x86, it is only possible with Pentium and newer systems (having
the cmpxchg extension). Other platforms are even more restrictive...

It can only make sense to do an atomic 64bit read if the writes
are also atomic.
So they really ought to apply to an atomic_int64_t (or similar).

Write can be atomic (oagain, when the arch implements it) via atomic_swap_64.

My proposal is to add an atomic_read_64() function to architectures that already implement 64b atomic writes, i386 being the main target.

It feels somehow inconsistent to have atomic writes but no atomic read on architectures where manipulating 64 bits/long long values is known _not_ to be atomic.

Jean-Yves


Home | Main Index | Thread Index | Old Index