- }
-
- queue_iterate( &vm_page_queue_active,
- m,
- vm_page_t,
- pageq )
- {
- if ((kIOHibernateModeDiscardCleanActive & gIOHibernateMode)
- && consider_discard(m))
- {
- hibernate_page_bitset(page_list, TRUE, m->phys_page);
- if (m->dirty)
- count_discard_purgeable++;
- else
- count_discard_active++;
- }
- else
- count_active++;
- count_wire--;
- hibernate_page_bitset(page_list_wired, TRUE, m->phys_page);
- }
-
- // pull wired from hibernate_bitmap
-
- bitmap = &page_list->bank_bitmap[0];
- bitmap_wired = &page_list_wired->bank_bitmap[0];
- for (bank = 0; bank < page_list->bank_count; bank++)
- {
- for (i = 0; i < bitmap->bitmapwords; i++)
- bitmap->bitmap[i] = bitmap->bitmap[i] | ~bitmap_wired->bitmap[i];
- bitmap = (hibernate_bitmap_t *) &bitmap->bitmap [bitmap->bitmapwords];
- bitmap_wired = (hibernate_bitmap_t *) &bitmap_wired->bitmap[bitmap_wired->bitmapwords];
- }
-
- // machine dependent adjustments
- hibernate_page_list_setall_machine(page_list, page_list_wired, &pages);
-
- clock_get_uptime(&end);
- absolutetime_to_nanoseconds(end - start, &nsec);
- HIBLOG("hibernate_page_list_setall time: %qd ms\n", nsec / 1000000ULL);
-
- HIBLOG("pages %d, wire %d, act %d, inact %d, spec %d, zf %d, throt %d, could discard act %d inact %d purgeable %d spec %d\n",
- pages, count_wire, count_active, count_inactive, count_speculative, count_zf, count_throttled,
- count_discard_active, count_discard_inactive, count_discard_purgeable, count_discard_speculative);
-
- *pagesOut = pages - count_discard_active - count_discard_inactive - count_discard_purgeable - count_discard_speculative;
-}
-
-void
-hibernate_page_list_discard(hibernate_page_list_t * page_list)
-{
- uint64_t start, end, nsec;
- vm_page_t m;
- vm_page_t next;
- uint32_t i;
- uint32_t count_discard_active = 0;
- uint32_t count_discard_inactive = 0;
- uint32_t count_discard_purgeable = 0;
- uint32_t count_discard_speculative = 0;
-
- clock_get_uptime(&start);
-
- m = (vm_page_t) queue_first(&vm_page_queue_zf);
- while (m && !queue_end(&vm_page_queue_zf, (queue_entry_t)m))
- {
- next = (vm_page_t) m->pageq.next;
- if (hibernate_page_bittst(page_list, m->phys_page))
- {
- if (m->dirty)
- count_discard_purgeable++;
- else
- count_discard_inactive++;
- discard_page(m);
- }
- m = next;
- }
-
- for( i = 0; i <= VM_PAGE_MAX_SPECULATIVE_AGE_Q; i++ )
- {
- m = (vm_page_t) queue_first(&vm_page_queue_speculative[i].age_q);
- while (m && !queue_end(&vm_page_queue_speculative[i].age_q, (queue_entry_t)m))
- {
- next = (vm_page_t) m->pageq.next;
- if (hibernate_page_bittst(page_list, m->phys_page))
- {
- count_discard_speculative++;
- discard_page(m);
- }
- m = next;