From owner-svn-src-all@freebsd.org Thu Jul 5 02:08:58 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0C1B103897F; Thu, 5 Jul 2018 02:08:57 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9E5E780B4E; Thu, 5 Jul 2018 02:08:57 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FF32138CF; Thu, 5 Jul 2018 02:08:57 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6528vgL098119; Thu, 5 Jul 2018 02:08:57 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6528voB098118; Thu, 5 Jul 2018 02:08:57 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201807050208.w6528voB098118@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Thu, 5 Jul 2018 02:08:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335972 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: alc X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 335972 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2018 02:08:58 -0000 Author: alc Date: Thu Jul 5 02:08:57 2018 New Revision: 335972 URL: https://svnweb.freebsd.org/changeset/base/335972 Log: Allow callers to vm_phys_split_pages() to specify whether insertion should occur at the head or the tail of the page queues. Modified: head/sys/vm/vm_phys.c Modified: head/sys/vm/vm_phys.c ============================================================================== --- head/sys/vm/vm_phys.c Thu Jul 5 02:04:18 2018 (r335971) +++ head/sys/vm/vm_phys.c Thu Jul 5 02:08:57 2018 (r335972) @@ -156,7 +156,7 @@ static vm_page_t vm_phys_alloc_seg_contig(struct vm_ph static void _vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end, int domain); static void vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end); static void vm_phys_split_pages(vm_page_t m, int oind, struct vm_freelist *fl, - int order); + int order, int tail); /* * Red-black tree helpers for vm fictitious range management. @@ -588,9 +588,16 @@ vm_phys_init(void) /* * Split a contiguous, power of two-sized set of physical pages. + * + * When this function is called by a page allocation function, the caller + * should request insertion at the head unless the order [order, oind) queues + * are known to be empty. The objective being to reduce the likelihood of + * long-term fragmentation by promoting contemporaneous allocation and + * (hopefully) deallocation. */ static __inline void -vm_phys_split_pages(vm_page_t m, int oind, struct vm_freelist *fl, int order) +vm_phys_split_pages(vm_page_t m, int oind, struct vm_freelist *fl, int order, + int tail) { vm_page_t m_buddy; @@ -600,7 +607,7 @@ vm_phys_split_pages(vm_page_t m, int oind, struct vm_f KASSERT(m_buddy->order == VM_NFREEORDER, ("vm_phys_split_pages: page %p has unexpected order %d", m_buddy, m_buddy->order)); - vm_freelist_add(fl, m_buddy, oind, 0); + vm_freelist_add(fl, m_buddy, oind, tail); } } @@ -777,7 +784,8 @@ vm_phys_alloc_freelist_pages(int domain, int freelist, m = TAILQ_FIRST(&fl[oind].pl); if (m != NULL) { vm_freelist_rem(fl, m, oind); - vm_phys_split_pages(m, oind, fl, order); + /* The order [order, oind) queues are empty. */ + vm_phys_split_pages(m, oind, fl, order, 1); return (m); } } @@ -795,7 +803,8 @@ vm_phys_alloc_freelist_pages(int domain, int freelist, if (m != NULL) { vm_freelist_rem(alt, m, oind); vm_phys_set_pool(pool, m, oind); - vm_phys_split_pages(m, oind, fl, order); + /* The order [order, oind) queues are empty. */ + vm_phys_split_pages(m, oind, fl, order, 1); return (m); } }