git: 94e5ec7f869e - stable/14 - vm_page: Use atomic loads for cmpset loops
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Oct 2024 13:36:07 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=94e5ec7f869e244afa174af2f8a61e4355a2cb73 commit 94e5ec7f869e244afa174af2f8a61e4355a2cb73 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-10-07 20:50:36 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-10-15 12:39:44 +0000 vm_page: Use atomic loads for cmpset loops Make sure that the compiler loads the initial value value only once. Because atomic_fcmpset is used to load the value for subsequent iterations, this is probably not needed, but we should not rely on that. I verified that code generated for an amd64 GENERIC kernel does not change. Reviewed by: dougm, alc, kib Tested by: pho MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46943 (cherry picked from commit d8b32da2354d2fd72ae017fd63affa3684786e1f) --- sys/vm/vm_page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index fe104e1e87af..7c3083de42de 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1972,7 +1972,7 @@ _vm_domain_allocate(struct vm_domain *vmd, int req_class, int npages) * Attempt to reserve the pages. Fail if we're below the limit. */ limit += npages; - old = vmd->vmd_free_count; + old = atomic_load_int(&vmd->vmd_free_count); do { if (old < limit) return (0); @@ -4054,7 +4054,7 @@ vm_page_wire_mapped(vm_page_t m) { u_int old; - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(old > 0, ("vm_page_wire_mapped: wiring unreferenced page %p", m)); @@ -4088,7 +4088,7 @@ vm_page_unwire_managed(vm_page_t m, uint8_t nqueue, bool noreuse) * Use a release store when updating the reference count to * synchronize with vm_page_free_prep(). */ - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(VPRC_WIRE_COUNT(old) > 0, ("vm_page_unwire: wire count underflow for page %p", m)); @@ -4383,7 +4383,7 @@ vm_page_try_blocked_op(vm_page_t m, void (*op)(vm_page_t)) ("vm_page_try_blocked_op: page %p is not busy", m)); VM_OBJECT_ASSERT_LOCKED(m->object); - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(old != 0, ("vm_page_try_blocked_op: page %p has no references", m));