git: d7acbe481d17 - main - vm_page: Break reservations to handle noobj allocations

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 22 Oct 2021 13:33:30 UTC
The branch main has been updated by markj:

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

commit d7acbe481d17ccb81c2b879b9731c83b018f3094
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-10-21 15:46:25 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-10-22 13:25:59 +0000

    vm_page: Break reservations to handle noobj allocations
    
    vm_reserv_reclaim_*() will release pages to the default freepool, not
    the direct freepool from which noobj allocations are drawn.  But if both
    pools are empty, the noobj allocator variants must break reservations to
    make progress.
    
    Reported by:    cy
    Reviewed by:    kib (previous version)
    Fixes:  b498f71bc56a ("vm_page: Add a new page allocator interface for unnamed pages")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32592
---
 sys/vm/vm_page.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index eca5d0801b7f..76e9ba4db403 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2409,8 +2409,14 @@ again:
 			m = vm_phys_alloc_freelist_pages(domain, freelist,
 			    VM_FREEPOOL_DIRECT, 0);
 		vm_domain_free_unlock(vmd);
-		if (m == NULL)
+		if (m == NULL) {
 			vm_domain_freecnt_inc(vmd, 1);
+#if VM_NRESERVLEVEL > 0
+			if (freelist == VM_NFREELIST &&
+			    vm_reserv_reclaim_inactive(domain))
+				goto again;
+#endif
+		}
 	}
 	if (m == NULL) {
 		if (vm_domain_alloc_fail(vmd, NULL, req))
@@ -2540,6 +2546,11 @@ again:
 		vm_domain_free_unlock(vmd);
 		if (m_ret == NULL) {
 			vm_domain_freecnt_inc(vmd, npages);
+#if VM_NRESERVLEVEL > 0
+			if (vm_reserv_reclaim_contig(domain, npages, low,
+			    high, alignment, boundary))
+				goto again;
+#endif
 		}
 	}
 	if (m_ret == NULL) {