From owner-dev-commits-src-all@freebsd.org Sun Sep 19 18:31:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61C7866F594; Sun, 19 Sep 2021 18:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HCGVj2LKrz4X5b; Sun, 19 Sep 2021 18:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 312AA22068; Sun, 19 Sep 2021 18:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18JIVfe5053295; Sun, 19 Sep 2021 18:31:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18JIVfIW053294; Sun, 19 Sep 2021 18:31:41 GMT (envelope-from git) Date: Sun, 19 Sep 2021 18:31:41 GMT Message-Id: <202109191831.18JIVfIW053294@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: bd3a668087ef - main - vm_page_startup: correct calculation of the starting page MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bd3a668087efb02e8e84315f7cc29d3813270dff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Sep 2021 18:31:41 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bd3a668087efb02e8e84315f7cc29d3813270dff commit bd3a668087efb02e8e84315f7cc29d3813270dff Author: Konstantin Belousov AuthorDate: 2021-09-17 18:48:42 +0000 Commit: Konstantin Belousov 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; } }