Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2018 04:08:15 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335790 - head/sys/vm
Message-ID:  <201806290408.w5T48FA8071274@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Fri Jun 29 04:08:14 2018
New Revision: 335790
URL: https://svnweb.freebsd.org/changeset/base/335790

Log:
  Three changes to vm_phys_alloc_seg_contig():
  
  1. Optimize the order computation.
  
  2. Update the pool for all of the chunks that are removed from the free
     page lists, and not just the first chunk.
  
  3. Simplify the code for returning excess pages to the free page lists.
  
  Reviewed by:	Doug Moore <dougm@rice.edu>

Modified:
  head/sys/vm/vm_phys.c

Modified: head/sys/vm/vm_phys.c
==============================================================================
--- head/sys/vm/vm_phys.c	Fri Jun 29 01:06:47 2018	(r335789)
+++ head/sys/vm/vm_phys.c	Fri Jun 29 04:08:14 2018	(r335790)
@@ -1239,7 +1239,7 @@ vm_phys_alloc_seg_contig(struct vm_phys_seg *seg, u_lo
 	KASSERT(powerof2(boundary), ("boundary is not a power of 2"));
 	vm_domain_free_assert_locked(VM_DOMAIN(seg->domain));
 	/* Compute the queue that is the best fit for npages. */
-	for (order = 0; (1 << order) < npages; order++);
+	order = flsl(npages - 1);
 	/* Search for a run satisfying the specified conditions. */
 	size = npages << PAGE_SHIFT;
 	for (oind = min(order, VM_NFREEORDER - 1); oind < VM_NFREEORDER;
@@ -1297,14 +1297,12 @@ vm_phys_alloc_seg_contig(struct vm_phys_seg *seg, u_lo
 done:
 	for (m = m_ret; m < &m_ret[npages]; m = &m[1 << oind]) {
 		fl = (*seg->free_queues)[m->pool];
-		vm_freelist_rem(fl, m, m->order);
+		vm_freelist_rem(fl, m, oind);
+		if (m->pool != VM_FREEPOOL_DEFAULT)
+			vm_phys_set_pool(VM_FREEPOOL_DEFAULT, m, oind);
 	}
-	if (m_ret->pool != VM_FREEPOOL_DEFAULT)
-		vm_phys_set_pool(VM_FREEPOOL_DEFAULT, m_ret, oind);
-	fl = (*seg->free_queues)[m_ret->pool];
-	vm_phys_split_pages(m_ret, oind, fl, order);
 	/* Return excess pages to the free lists. */
-	npages_end = roundup2(npages, 1 << imin(oind, order));
+	npages_end = roundup2(npages, 1 << oind);
 	if (npages < npages_end)
 		vm_phys_free_contig(&m_ret[npages], npages_end - npages);
 	return (m_ret);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806290408.w5T48FA8071274>