From nobody Fri Dec 24 04:54:21 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E50D1908124; Fri, 24 Dec 2021 04:54:21 +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 4JKvqK29GMz3q6f; Fri, 24 Dec 2021 04:54:21 +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 2A77F1DC68; Fri, 24 Dec 2021 04:54:21 +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 1BO4sLI1023765; Fri, 24 Dec 2021 04:54:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BO4sLnK023764; Fri, 24 Dec 2021 04:54:21 GMT (envelope-from git) Date: Fri, 24 Dec 2021 04:54:21 GMT Message-Id: <202112240454.1BO4sLnK023764@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: fb38b29b5609 - main - vm_page: Remove extra test, dup code from page alloc List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb38b29b5609b0c0769b2b2e1d6c917c0799f2a0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640321661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l1IzzopsbUMTr09Do5URJtt0tCD/A25sqkLTcI01SXI=; b=wXrEMUk6RI0+BlI6KxTK1bACNLBlmK4wnGZVkNV+fR9AXGMnD+q103xM2PkYeG966bjisd a7F3F5ykCDocrVVShC+U+/aFEmQTLC63J148lmVzAWWKStpcjMdKc0X8z4Ot62LoW1ueeP VohjEyl6xxlCA832PHSNJvMeR+rURredbndo8+EO38NY3s7b9ONQ9RoQpXJbr47vWhC4QG FQXKpVtzSuEyVYl2F+INvR7ECf3YY/63+1Rojm8M8DLIjfVKMOL6gG8FTv01FYb2l0zpkL Oy6xWobr4+h0FVYBsAWUPoxO2idDDpLDSmksLNQXBhL8Q2/LbYVmjOHs69hFmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640321661; a=rsa-sha256; cv=none; b=f5GAkH5vvuAPev9hmeH3f+dK9FScMxQ/+sfGkCNe4XlqYj9LYAhNMIGHyNzsxkraonkdUd BGKyJFGJiyyu8X2Ekyy5rC8Fwzy1G0vDqMr93oi9BbrxLQFNOdw7Z3XzRKYyA+yjSXBQKw 7Uq1serfCZFb4+Z72BVaD2tzmvg9n6yfil7XqbKiE7+PG/WU9ECLW/hkAMp7jFIcxVqavG lGwai1JXYtmnbC3/qs6eoSnRYVNtRPUYIIuybwxNApKdVetykfLdIYeivlSlpCWO1uHgWj z6uZ9yvarJIhpLwZC2tTW5iLLpcxCDyju1saWUYIkCvkm7V7HnZHMikCXVNI7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=fb38b29b5609b0c0769b2b2e1d6c917c0799f2a0 commit fb38b29b5609b0c0769b2b2e1d6c917c0799f2a0 Author: Doug Moore AuthorDate: 2021-12-24 04:45:47 +0000 Commit: Doug Moore CommitDate: 2021-12-24 04:45:47 +0000 vm_page: Remove extra test, dup code from page alloc Extract code common to functions vm_page_alloc_contig_domain and vm_page_alloc_noobj_contig_domain into a new function. Do so in a way that eliminates a bound-to-fail reservation test after a reservation is broken by a call from vm_page_alloc_contig_domain. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D33551 --- sys/vm/vm_page.c | 113 +++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 61 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index f14a9330556b..c24da96f4312 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2178,12 +2178,47 @@ vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req, return (m); } +static vm_page_t +vm_page_find_contig_domain(int domain, int req, u_long npages, vm_paddr_t low, + vm_paddr_t high, u_long alignment, vm_paddr_t boundary) +{ + struct vm_domain *vmd; + vm_page_t m_ret; + + vmd = VM_DOMAIN(domain); + if (!vm_domain_allocate(vmd, req, npages)) + return (NULL); +#if VM_NRESERVLEVEL > 0 +again: +#endif + /* + * Try to allocate the pages from the free page queues. + */ + vm_domain_free_lock(vmd); + m_ret = vm_phys_alloc_contig(domain, npages, low, high, + alignment, boundary); + vm_domain_free_unlock(vmd); + if (m_ret != NULL) + return (m_ret); + vm_domain_freecnt_inc(vmd, npages); +#if VM_NRESERVLEVEL > 0 + /* + * Try to break a reservation to replenish free page queues + * in a way that allows the allocation to succeed. + */ + if ((req & VM_ALLOC_NORECLAIM) == 0 && + vm_reserv_reclaim_contig(domain, npages, low, + high, alignment, boundary)) + goto again; +#endif + return (m_ret); +} + vm_page_t vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr) { - struct vm_domain *vmd; vm_page_t m, m_ret, mpred; u_int busy_lock, flags, oflags; @@ -2210,45 +2245,23 @@ vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, * Can we allocate the pages without the number of free pages falling * below the lower bound for the allocation class? */ - m_ret = NULL; -again: + for (;;) { #if VM_NRESERVLEVEL > 0 - /* - * Can we allocate the pages from a reservation? - */ - if (vm_object_reserv(object) && - (m_ret = vm_reserv_alloc_contig(object, pindex, domain, req, - mpred, npages, low, high, alignment, boundary)) != NULL) { - goto found; - } -#endif - vmd = VM_DOMAIN(domain); - if (vm_domain_allocate(vmd, req, npages)) { /* - * allocate them from the free page queues. + * Can we allocate the pages from a reservation? */ - vm_domain_free_lock(vmd); - m_ret = vm_phys_alloc_contig(domain, npages, low, high, - alignment, boundary); - vm_domain_free_unlock(vmd); - if (m_ret == NULL) { - vm_domain_freecnt_inc(vmd, npages); -#if VM_NRESERVLEVEL > 0 - if ((req & VM_ALLOC_NORECLAIM) == 0 && - vm_reserv_reclaim_contig(domain, npages, low, - high, alignment, boundary)) - goto again; -#endif + if (vm_object_reserv(object) && + (m_ret = vm_reserv_alloc_contig(object, pindex, domain, req, + mpred, npages, low, high, alignment, boundary)) != NULL) { + break; } - } - if (m_ret == NULL) { - if (vm_domain_alloc_fail(vmd, object, req)) - goto again; - return (NULL); - } -#if VM_NRESERVLEVEL > 0 -found: #endif + if ((m_ret = vm_page_find_contig_domain(domain, req, npages, + low, high, alignment, boundary)) != NULL) + break; + if (!vm_domain_alloc_fail(VM_DOMAIN(domain), object, req)) + return (NULL); + } for (m = m_ret; m < &m_ret[npages]; m++) { vm_page_dequeue(m); vm_page_alloc_check(m); @@ -2462,7 +2475,6 @@ vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr) { - struct vm_domain *vmd; vm_page_t m, m_ret; u_int flags; @@ -2477,31 +2489,10 @@ vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages, ("invalid request %#x", req)); KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero")); - m_ret = NULL; -again: - vmd = VM_DOMAIN(domain); - if (vm_domain_allocate(vmd, req, npages)) { - /* - * allocate them from the free page queues. - */ - vm_domain_free_lock(vmd); - m_ret = vm_phys_alloc_contig(domain, npages, low, high, - alignment, boundary); - vm_domain_free_unlock(vmd); - if (m_ret == NULL) { - vm_domain_freecnt_inc(vmd, npages); -#if VM_NRESERVLEVEL > 0 - if ((req & VM_ALLOC_NORECLAIM) == 0 && - vm_reserv_reclaim_contig(domain, npages, low, - high, alignment, boundary)) - goto again; -#endif - } - } - if (m_ret == NULL) { - if (vm_domain_alloc_fail(vmd, NULL, req)) - goto again; - return (NULL); + while ((m_ret = vm_page_find_contig_domain(domain, req, npages, + low, high, alignment, boundary)) == NULL) { + if (!vm_domain_alloc_fail(VM_DOMAIN(domain), NULL, req)) + return (NULL); } /*