summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2012-04-06 16:41:19 +0000
committeralc <alc@FreeBSD.org>2012-04-06 16:41:19 +0000
commit84663665875313094ef5b78dfe6a2afd011ae12e (patch)
tree9c7ebaacbb23f27b0829e91d9efeab2681a84393 /sys/amd64
parent9c79ae8eeae5c79b22d21b6b31cdb8cef3f8478a (diff)
downloadFreeBSD-src-84663665875313094ef5b78dfe6a2afd011ae12e.zip
FreeBSD-src-84663665875313094ef5b78dfe6a2afd011ae12e.tar.gz
Micro-optimize free_pv_entry() for the expected case.
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/pmap.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index f293aaf..ff4f96b 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -2095,7 +2095,6 @@ pmap_collect(pmap_t locked_pmap, struct vpgqueues *vpq)
}
}
-
/*
* 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++);
OpenPOWER on IntegriCloud