git: 53dd5ccce2ac - stable/12 - vm_reserv: fix zero-boundary error

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Wed, 29 Dec 2021 17:28:49 UTC
The branch stable/12 has been updated by dougm:

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

commit 53dd5ccce2ac3bc8914d8c6d7dede927887503d9
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2021-12-26 17:40:27 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2021-12-29 17:28:13 +0000

    vm_reserv: fix zero-boundary error
    
    Handle specially the boundary==0 case of vm_reserv_reclaim_config,
    by turning off boundary adjustment in that case.
    
    Reviewed by:    alc
    Tested by:      pho, madpilot
    
    (cherry picked from commit 49fd2d51f07fb29af3fd239f83f249c00cd84123)
    (cherry picked from commit dd8ea1c755b3cc2c9c4eaa8611a97ac8f0f9b755)
---
 sys/vm/vm_reserv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
index 189023257d07..98d9b23dea3e 100644
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -1421,7 +1421,7 @@ vm_reserv_reclaim_contig(int domain, u_long npages, vm_paddr_t low,
 	 * doesn't include a boundary-multiple within it.  Otherwise,
 	 * no boundary-constrained allocation is possible.
 	 */
-	if (size > boundary)
+	if (size > boundary && boundary > 0)
 		return (false);
 	marker = &vm_rvd[domain].marker;
 	queue = &vm_rvd[domain].partpop;
@@ -1432,7 +1432,8 @@ vm_reserv_reclaim_contig(int domain, u_long npages, vm_paddr_t low,
 	 */
 	ppn_align = (int)(ulmin(ulmax(PAGE_SIZE, alignment),
 	    VM_LEVEL_0_SIZE) >> PAGE_SHIFT);
-	ppn_bound = (int)(MIN(MAX(PAGE_SIZE, boundary),
+	ppn_bound = boundary == 0 ? VM_LEVEL_0_NPAGES :
+	    (int)(MIN(MAX(PAGE_SIZE, boundary),
             VM_LEVEL_0_SIZE) >> PAGE_SHIFT);
 
 	vm_reserv_domain_scan_lock(domain);