git: bd3a668087ef - main - vm_page_startup: correct calculation of the starting page

Konstantin Belousov kib at FreeBSD.org
Sun Sep 19 18:31:41 UTC 2021


The branch main has been updated by kib:

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

commit bd3a668087efb02e8e84315f7cc29d3813270dff
Author:     Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-09-17 18:48:42 +0000
Commit:     Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-09-19 18:27:55 +0000

    vm_page_startup: correct calculation of the starting page
    
    Also avoid unneded calculations when phys segment end is the phys_avail[]
    start.
    
    Submitted by:   alc
    Reviewed by:    markj
    MFC after:      1 week
    Fixes:  181bfb42fd01bfa9f46
    Differential revision:  https://reviews.freebsd.org/D32009
---
 sys/vm/vm_page.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index d2e94ced6766..25e6dce32aa6 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -775,27 +775,25 @@ vm_page_startup(vm_offset_t vaddr)
 		 * phys_avail's ranges to the free lists.
 		 */
 		for (i = 0; phys_avail[i + 1] != 0; i += 2) {
-			if (seg->end < phys_avail[i] ||
+			if (seg->end <= phys_avail[i] ||
 			    seg->start >= phys_avail[i + 1])
 				continue;
 
 			startp = MAX(seg->start, phys_avail[i]);
-			m = seg->first_page + atop(seg->start - startp);
 			endp = MIN(seg->end, phys_avail[i + 1]);
 			pagecount = (u_long)atop(endp - startp);
 			if (pagecount == 0)
 				continue;
 
+			m = seg->first_page + atop(startp - seg->start);
 			vmd = VM_DOMAIN(seg->domain);
 			vm_domain_free_lock(vmd);
 			vm_phys_enqueue_contig(m, pagecount);
 			vm_domain_free_unlock(vmd);
 			vm_domain_freecnt_inc(vmd, pagecount);
 			vm_cnt.v_page_count += (u_int)pagecount;
-
-			vmd = VM_DOMAIN(seg->domain);
 			vmd->vmd_page_count += (u_int)pagecount;
-			vmd->vmd_segs |= 1UL << m->segind;
+			vmd->vmd_segs |= 1UL << segind;
 		}
 	}
 


More information about the dev-commits-src-all mailing list