1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-04 17:15:50 +00:00

Micro-optimize free_pv_entry() for the expected case.

This commit is contained in:
Alan Cox 2012-04-06 16:41:19 +00:00
parent 57bd5cce62
commit 3e4c7bf65a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=233954

View File

@ -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++);