git: d8b32da2354d - main - vm_page: Use atomic loads for cmpset loops
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Oct 2024 20:52:31 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=d8b32da2354d2fd72ae017fd63affa3684786e1f
commit d8b32da2354d2fd72ae017fd63affa3684786e1f
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-07 20:50:36 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-10-07 20:52:08 +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
---
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 67a9c2119ab8..3a8d8d137dc1 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2097,7 +2097,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);
@@ -4239,7 +4239,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));
@@ -4273,7 +4273,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));
@@ -4568,7 +4568,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));