git: 049a256e9aa7 - stable/14 - vm_page: add vm_page_clearref() helper

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 21 Jul 2024 08:51:18 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=049a256e9aa7b37487a6538d8c5763db6ec7a658

commit 049a256e9aa7b37487a6538d8c5763db6ec7a658
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-07-08 17:45:33 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-07-21 08:50:29 +0000

    vm_page: add vm_page_clearref() helper
    
    (cherry picked from commit 45cde0e439188589ca2511f6fd76829cbf68267e)
---
 sys/vm/vm_page.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index c9773f27d195..a1df6f736aee 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -949,6 +949,17 @@ vm_page_in_laundry(vm_page_t m)
 	return (queue == PQ_LAUNDRY || queue == PQ_UNSWAPPABLE);
 }
 
+static inline void
+vm_page_clearref(vm_page_t m)
+{
+	u_int r;
+
+	r = m->ref_count;
+	while (atomic_fcmpset_int(&m->ref_count, &r, r & (VPRC_BLOCKED |
+	    VPRC_OBJREF)) == 0)
+		;
+}
+
 /*
  *	vm_page_drop:
  *