tech-userlevel archive

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

Re: atomic read in atomic_ops(9)

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).

For things like network stats with only one writer there are various
schemes that can be used - some of which don't require any locked
bus cycles by either the writer or reader.


David Laight:

Home | Main Index | Thread Index | Old Index