From owner-dev-commits-src-branches@freebsd.org Tue Mar 16 15:14:28 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 2933C5B2C0E; Tue, 16 Mar 2021 15:14:28 +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 4F0GzS0lrbz4ggb; Tue, 16 Mar 2021 15:14:28 +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 0CC942586E; Tue, 16 Mar 2021 15:14:28 +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 12GFERDa074450; Tue, 16 Mar 2021 15:14:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12GFERCd074449; Tue, 16 Mar 2021 15:14:27 GMT (envelope-from git) Date: Tue, 16 Mar 2021 15:14:27 GMT Message-Id: <202103161514.12GFERCd074449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 03984bdfa033 - stable/13 - vm: Round up npages and alignment for contig reclamation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 03984bdfa033efe0597aa6adac85dba6e7ddb9a8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2021 15:14:28 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=03984bdfa033efe0597aa6adac85dba6e7ddb9a8 commit 03984bdfa033efe0597aa6adac85dba6e7ddb9a8 Author: Mark Johnston AuthorDate: 2021-03-02 15:19:53 +0000 Commit: Mark Johnston CommitDate: 2021-03-16 15:14:09 +0000 vm: Round up npages and alignment for contig reclamation When searching for runs to reclaim, we need to ensure that the entire run will be added to the buddy allocator as a single unit. Otherwise, it will not be visible to vm_phys_alloc_contig() as it is currently implemented. This is a problem for allocation requests that are not a power of 2 in size, as with 9KB jumbo mbuf clusters. Reported by: alc Reviewed by: alc Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28924 (cherry picked from commit 0401989282d1bb9972ae2bf4862c2c6c92ae5f27) --- sys/vm/vm_page.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index c36b8cdc5762..da62e6795c81 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2972,17 +2972,29 @@ vm_page_reclaim_contig_domain(int domain, int req, u_long npages, struct vm_domain *vmd; vm_paddr_t curr_low; vm_page_t m_run, m_runs[NRUNS]; - u_long count, reclaimed; + u_long count, minalign, reclaimed; int error, i, options, req_class; KASSERT(npages > 0, ("npages is 0")); KASSERT(powerof2(alignment), ("alignment is not a power of 2")); KASSERT(powerof2(boundary), ("boundary is not a power of 2")); - req_class = req & VM_ALLOC_CLASS_MASK; + + /* + * The caller will attempt an allocation after some runs have been + * reclaimed and added to the vm_phys buddy lists. Due to limitations + * of vm_phys_alloc_contig(), round up the requested length to the next + * power of two or maximum chunk size, and ensure that each run is + * suitably aligned. + */ + minalign = 1ul << imin(flsl(npages - 1), VM_NFREEORDER - 1); + npages = roundup2(npages, minalign); + if (alignment < ptoa(minalign)) + alignment = ptoa(minalign); /* * The page daemon is allowed to dig deeper into the free page list. */ + req_class = req & VM_ALLOC_CLASS_MASK; if (curproc == pageproc && req_class != VM_ALLOC_INTERRUPT) req_class = VM_ALLOC_SYSTEM;