svn commit: r233954 - head/sys/amd64/amd64
Alan Cox
alc at FreeBSD.org
Fri Apr 6 16:41:20 UTC 2012
Author: alc
Date: Fri Apr 6 16:41:19 2012
New Revision: 233954
URL: http://svn.freebsd.org/changeset/base/233954
Log:
Micro-optimize free_pv_entry() for the expected case.
Modified:
head/sys/amd64/amd64/pmap.c
Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c Fri Apr 6 16:32:29 2012 (r233953)
+++ head/sys/amd64/amd64/pmap.c Fri Apr 6 16:41:19 2012 (r233954)
@@ -2095,7 +2095,6 @@ pmap_collect(pmap_t locked_pmap, struct
}
}
-
/*
* free the pv_entry back to the free list
*/
@@ -2116,13 +2115,16 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
field = idx / 64;
bit = idx % 64;
pc->pc_map[field] |= 1ul << bit;
- /* move to head of list */
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 ||
pc->pc_map[2] != PC_FREE2) {
- TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
+ /* 98% of the time, pc is already at the head of the list. */
+ if (__predict_false(pc != TAILQ_FIRST(&pmap->pm_pvchunk))) {
+ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
+ TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
+ }
return;
}
+ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
PV_STAT(pv_entry_spare -= _NPCPV);
PV_STAT(pc_chunk_count--);
PV_STAT(pc_chunk_frees++);
More information about the svn-src-head
mailing list