Convert extents_t's npages field to use C11-style atomics

In the process, we can do some strength reduction, changing the fetch-adds and
fetch-subs to be simple loads followed by stores, since the modifications all
occur while holding the mutex.
This commit is contained in:
David Goldblatt
2017-03-07 17:57:48 -08:00
committed by David Goldblatt
parent dafadce622
commit 8adab26972
2 changed files with 28 additions and 8 deletions

View File

@@ -109,9 +109,12 @@ struct extents_s {
/*
* Page sum for all extents in heaps.
*
* Synchronization: atomic.
* The synchronization here is a little tricky. Modifications to npages
* must hold mtx, but reads need not (though, a reader who sees npages
* without holding the mutex can't assume anything about the rest of the
* state of the extents_t).
*/
size_t npages;
atomic_zu_t npages;
/* All stored extents must be in the same state. */
extent_state_t state;