Source-Changes archive

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

CVS commit: src/sys/kern



Module Name:    src
Committed By:   riastradh
Date:           Fri Feb 24 11:21:29 UTC 2023

Modified Files:
        src/sys/kern: kern_mutex.c

Log Message:
mutex(9): Simplify membars.

- Elide macro indirection for membar_acquire.
- Use atomic_store_release instead of membar_release and store.

No functional change intended.  Possible very very very very minor
performance gain on architectures with a native store-release
instruction.

Note: It is possible there are some code paths that worked by
accident with this change which could, in theory, break now, such as
the logic I recently fixed in kern_descrip.c that assumed a
mutex_enter/exit cycle would serve as a store-before-store barrier:

        fp->f_... = ...;                // A

        /* fd_affix */
        mutex_enter(&fp->f_lock);
        fp->f_count++;
        mutex_exit(&fp->f_lock);
        ...
        ff->ff_file = fp;               // B

This logic was never correct, and is likely already broken in
practice on aarch64 because the mutex_exit stub already uses STLXR
instead of DMB ISH(ST); STXR.  This change only affects the slow path
of mutex_exit, so it doesn't change even the accidental guarantees
mutex_exit makes in all paths.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/kern/kern_mutex.c

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