* Apply the given advice to the specified range of addresses within the * given pmap. Depending on the advice, clear the referenced and/or * modified flags in each mapping and set the mapped page's dirty field. */
| 5654 | * modified flags in each mapping and set the mapped page's dirty field. |
| 5655 | */ |
| 5656 | void |
| 5657 | pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int advice) |
| 5658 | { |
| 5659 | struct rwlock *lock; |
| 5660 | vm_offset_t va, va_next; |
| 5661 | vm_page_t m; |
| 5662 | pd_entry_t *l0, *l1, *l2, oldl2; |
| 5663 | pt_entry_t *l3, oldl3; |
| 5664 | |
| 5665 | PMAP_ASSERT_STAGE1(pmap); |
| 5666 | |
| 5667 | if (advice != MADV_DONTNEED && advice != MADV_FREE) |
| 5668 | return; |
| 5669 | |
| 5670 | PMAP_LOCK(pmap); |
| 5671 | for (; sva < eva; sva = va_next) { |
| 5672 | l0 = pmap_l0(pmap, sva); |
| 5673 | if (pmap_load(l0) == 0) { |
| 5674 | va_next = (sva + L0_SIZE) & ~L0_OFFSET; |
| 5675 | if (va_next < sva) |
| 5676 | va_next = eva; |
| 5677 | continue; |
| 5678 | } |
| 5679 | |
| 5680 | va_next = (sva + L1_SIZE) & ~L1_OFFSET; |
| 5681 | if (va_next < sva) |
| 5682 | va_next = eva; |
| 5683 | l1 = pmap_l0_to_l1(l0, sva); |
| 5684 | if (pmap_load(l1) == 0) |
| 5685 | continue; |
| 5686 | if ((pmap_load(l1) & ATTR_DESCR_MASK) == L1_BLOCK) { |
| 5687 | KASSERT(va_next <= eva, |
| 5688 | ("partial update of non-transparent 1G page " |
| 5689 | "l1 %#lx sva %#lx eva %#lx va_next %#lx", |
| 5690 | pmap_load(l1), sva, eva, va_next)); |
| 5691 | continue; |
| 5692 | } |
| 5693 | |
| 5694 | va_next = (sva + L2_SIZE) & ~L2_OFFSET; |
| 5695 | if (va_next < sva) |
| 5696 | va_next = eva; |
| 5697 | l2 = pmap_l1_to_l2(l1, sva); |
| 5698 | oldl2 = pmap_load(l2); |
| 5699 | if (oldl2 == 0) |
| 5700 | continue; |
| 5701 | if ((oldl2 & ATTR_DESCR_MASK) == L2_BLOCK) { |
| 5702 | if ((oldl2 & ATTR_SW_MANAGED) == 0) |
| 5703 | continue; |
| 5704 | lock = NULL; |
| 5705 | if (!pmap_demote_l2_locked(pmap, l2, sva, &lock)) { |
| 5706 | if (lock != NULL) |
| 5707 | rw_wunlock(lock); |
| 5708 | |
| 5709 | /* |
| 5710 | * The 2MB page mapping was destroyed. |
| 5711 | */ |
| 5712 | continue; |
| 5713 | } |
nothing calls this directly
no test coverage detected