Source-Changes archive

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

CVS commit: src/sys



Module Name:    src
Committed By:   riastradh
Date:           Sat Jul 30 14:13:27 UTC 2022

Modified Files:
        src/sys/arch/sparc/include: types.h
        src/sys/kern: subr_csan.c
        src/sys/sys: atomic.h

Log Message:
sys/atomic.h: Fix atomic_store_* on sparcv7, sparcv8.

These did not cooperate with the hash-locked scheme of the other
atomic operations, with the effect that, for instance, a typical
naive spin lock based on atomic_*,

volatile unsigned locked = 0;
lock()
{
        while (atomic_swap_uint(&locked, 1))
                continue;
        membar_acquire();
}
unlock()
{
        membar_release();
        atomic_store_relaxed(&locked, 0);
}

would fail to achieve mutual exclusion.

For this case, we need to use atomic_swap_* (or, for 8- or 16-bit
objects, atomic_cas_32 loops, since there is no atomic_swap_8 or
atomic_swap_16).

The new machine/types.h macro __HAVE_HASHLOCKED_ATOMICS says whether
these contortions are necessary.

Note that this _requires_ the use of atomic_store_*(p, v), not
regular stores *p = v, to work with the r/m/w atomic operations.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/sparc/include/types.h
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_csan.c
cvs rdiff -u -r1.24 -r1.25 src/sys/sys/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index