Index: sys/arm64/arm64/pmap.c =================================================================== --- sys/arm64/arm64/pmap.c +++ sys/arm64/arm64/pmap.c @@ -2467,11 +2467,7 @@ #define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap) #define PC_FREEN 0xfffffffffffffffful -#if _NPCM == 3 -#define PC_FREEL 0x000000fffffffffful -#elif _NPCM == 11 -#define PC_FREEL 0x0000001ffffffffful -#endif +#define PC_FREEL ((1ul << (_NPCPV % 64)) - 1) #if _NPCM == 3 #define PC_IS_FREE(pc) ((pc)->pc_map[0] == PC_FREEN && \ @@ -2491,6 +2487,15 @@ CTASSERT(nitems(pc_freemask) == _NPCM); +static __inline bool +pc_is_full(struct pv_chunk *pc) +{ + for (u_int i = 0; i < _NPCM; i++) + if (pc->pc_map[i] != 0) + return (false); + return (true); +} + #ifdef PV_STATS static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail; @@ -2785,8 +2790,7 @@ pv = &pc->pc_pventry[field * 64 + bit]; pc->pc_map[field] &= ~(1ul << bit); /* If this was the last item, move it to tail */ - if (pc->pc_map[0] == 0 && pc->pc_map[1] == 0 && - pc->pc_map[2] == 0) { + if (pc_is_full(pc)) { TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); @@ -2953,8 +2957,7 @@ va_last = va + L2_SIZE - PAGE_SIZE; for (;;) { pc = TAILQ_FIRST(&pmap->pm_pvchunk); - KASSERT(pc->pc_map[0] != 0 || pc->pc_map[1] != 0 || - pc->pc_map[2] != 0, ("pmap_pv_demote_l2: missing spare")); + KASSERT(!pc_is_full(pc), ("pmap_pv_demote_l2: missing spare")); for (field = 0; field < _NPCM; field++) { while (pc->pc_map[field]) { bit = ffsl(pc->pc_map[field]) - 1; @@ -2975,7 +2978,7 @@ TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } out: - if (pc->pc_map[0] == 0 && pc->pc_map[1] == 0 && pc->pc_map[2] == 0) { + if (pc_is_full(pc)) { TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); }