- s64 = l64;
-
- if (s64 < e64 && rdtsc64() >= deadline) {
- PMAP_UNLOCK(pmap);
- PMAP_LOCK(pmap);
- deadline = rdtsc64() + max_preemption_latency_tsc;
- }
- }
-
- PMAP_UNLOCK(pmap);
-
- PMAP_TRACE(PMAP_CODE(PMAP__REUSABLE) | DBG_FUNC_END,
- pmap, reusable, 0, 0, 0);
-}
-
-void
-pmap_reusable_range(
- pmap_t pmap,
- vm_map_offset_t start_vaddr,
- pt_entry_t *spte,
- pt_entry_t *epte,
- boolean_t reusable)
-{
- pt_entry_t *cpte;
- int num_external, num_internal, num_reusable;
- ppnum_t pai;
- pmap_paddr_t pa;
- vm_map_offset_t vaddr;
-
- num_external = 0;
- num_internal = 0;
- num_reusable = 0;
-
- for (cpte = spte, vaddr = start_vaddr;
- cpte < epte;
- cpte++, vaddr += PAGE_SIZE_64) {
-
- pa = pte_to_pa(*cpte);
- if (pa == 0)
- continue;
-
- pai = pa_index(pa);
-
- LOCK_PVH(pai);
-
- pa = pte_to_pa(*cpte);
- if (pa == 0) {
- UNLOCK_PVH(pai);
- continue;
- }
- if (reusable) {
- /* we want to set "reusable" */
- if (IS_REUSABLE_PAGE(pai)) {
- /* already reusable: no change */
- } else {
- pmap_phys_attributes[pai] |= PHYS_REUSABLE;
- /* one more "reusable" */
- num_reusable++;
- if (IS_INTERNAL_PAGE(pai)) {
- /* one less "internal" */
- num_internal--;
- } else {
- /* one less "external" */
- num_external--;
- }
- }
- } else {
- /* we want to clear "reusable" */
- if (IS_REUSABLE_PAGE(pai)) {
- pmap_phys_attributes[pai] &= ~PHYS_REUSABLE;
- /* one less "reusable" */
- num_reusable--;
- if (IS_INTERNAL_PAGE(pai)) {
- /* one more "internal" */
- num_internal++;
- } else {
- /* one more "external" */
- num_external++;
- }
- } else {
- /* already not reusable: no change */
- }
- }
-
- UNLOCK_PVH(pai);
-
- } /* for loop */
-
- /*
- * Update the counts
- */
- if (pmap != kernel_pmap) {
- if (num_external) {
- OSAddAtomic(num_external, &pmap->stats.external);
- PMAP_STATS_PEAK(pmap->stats.external);
- }
- assert(pmap->stats.external >= 0);
- if (num_internal) {
- OSAddAtomic(num_internal, &pmap->stats.internal);
- PMAP_STATS_PEAK(pmap->stats.internal);
- }
- assert(pmap->stats.internal >= 0);
- if (num_reusable) {
- OSAddAtomic(num_reusable, &pmap->stats.reusable);
- PMAP_STATS_PEAK(pmap->stats.reusable);
- }
- assert(pmap->stats.reusable >= 0);