* free the pv_entry back to the free list */
| 5121 | * free the pv_entry back to the free list |
| 5122 | */ |
| 5123 | static void |
| 5124 | free_pv_entry(pmap_t pmap, pv_entry_t pv) |
| 5125 | { |
| 5126 | struct pv_chunk *pc; |
| 5127 | int idx, field, bit; |
| 5128 | |
| 5129 | PMAP_LOCK_ASSERT(pmap, MA_OWNED); |
| 5130 | PV_STAT(atomic_add_long(&pv_entry_frees, 1)); |
| 5131 | PV_STAT(atomic_add_int(&pv_entry_spare, 1)); |
| 5132 | PV_STAT(atomic_subtract_long(&pv_entry_count, 1)); |
| 5133 | pc = pv_to_chunk(pv); |
| 5134 | idx = pv - &pc->pc_pventry[0]; |
| 5135 | field = idx / 64; |
| 5136 | bit = idx % 64; |
| 5137 | pc->pc_map[field] |= 1ul << bit; |
| 5138 | if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 || |
| 5139 | pc->pc_map[2] != PC_FREE2) { |
| 5140 | /* 98% of the time, pc is already at the head of the list. */ |
| 5141 | if (__predict_false(pc != TAILQ_FIRST(&pmap->pm_pvchunk))) { |
| 5142 | TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); |
| 5143 | TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); |
| 5144 | } |
| 5145 | return; |
| 5146 | } |
| 5147 | TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); |
| 5148 | free_pv_chunk(pc); |
| 5149 | } |
| 5150 | |
| 5151 | static void |
| 5152 | free_pv_chunk_dequeued(struct pv_chunk *pc) |
no test coverage detected