Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_swapout.c
Show First 20 Lines • Show All 564 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Bring the kernel stack for a specified thread back in. | * Bring the kernel stack for a specified thread back in. | ||||
*/ | */ | ||||
static void | static void | ||||
vm_thread_swapin(struct thread *td, int oom_alloc) | vm_thread_swapin(struct thread *td, int oom_alloc) | ||||
{ | { | ||||
vm_object_t ksobj; | vm_object_t ksobj; | ||||
vm_page_t ma[KSTACK_MAX_PAGES]; | vm_page_t ma[KSTACK_MAX_PAGES]; | ||||
int a, count, i, j, pages, rv; | int a, count, i, j, pages; | ||||
boolean_t rv; | |||||
dougm: The changes to this file may be good or bad, but they don't seem related to the purpose of this… | |||||
Done Inline ActionsI referenced this function to find how to page-in multiple pages in a single call. I copied KASSERT from here. ota_j.email.ne.jp: I referenced this function to find how to page-in multiple pages in a single call. I copied… | |||||
pages = td->td_kstack_pages; | pages = td->td_kstack_pages; | ||||
ksobj = td->td_kstack_obj; | ksobj = td->td_kstack_obj; | ||||
VM_OBJECT_WLOCK(ksobj); | VM_OBJECT_WLOCK(ksobj); | ||||
(void)vm_page_grab_pages(ksobj, 0, oom_alloc | VM_ALLOC_WIRED, ma, | (void)vm_page_grab_pages(ksobj, 0, oom_alloc | VM_ALLOC_WIRED, ma, | ||||
pages); | pages); | ||||
for (i = 0; i < pages;) { | for (i = 0; i < pages;) { | ||||
vm_page_assert_xbusied(ma[i]); | vm_page_assert_xbusied(ma[i]); | ||||
if (ma[i]->valid == VM_PAGE_BITS_ALL) { | if (ma[i]->valid == VM_PAGE_BITS_ALL) { | ||||
vm_page_xunbusy(ma[i]); | vm_page_xunbusy(ma[i]); | ||||
i++; | i++; | ||||
continue; | continue; | ||||
} | } | ||||
vm_object_pip_add(ksobj, 1); | vm_object_pip_add(ksobj, 1); | ||||
for (j = i + 1; j < pages; j++) | for (j = i + 1; j < pages; j++) | ||||
if (ma[j]->valid == VM_PAGE_BITS_ALL) | if (ma[j]->valid == VM_PAGE_BITS_ALL) | ||||
break; | break; | ||||
rv = vm_pager_has_page(ksobj, ma[i]->pindex, NULL, &a); | KASSERT(vm_pager_has_page(ksobj, ma[i]->pindex, NULL, &a), | ||||
KASSERT(rv == 1, ("%s: missing page %p", __func__, ma[i])); | ("%s: missing page %p", __func__, ma[i])); | ||||
count = min(a + 1, j - i); | count = min(a + 1, j - i); | ||||
Not Done Inline ActionsIf the value of 'a' matters here, then that value can't be set in a KASSERT expression, since if asserts are turned off, 'a' won't be set. dougm: If the value of 'a' matters here, then that value can't be set in a KASSERT expression, since… | |||||
Done Inline ActionsSo, we'd better do ota_j.email.ne.jp: So, we'd better do
KASSERT(rv, ("%s: missing page %p", __func__, ma[i]));
here, too, as rv is… | |||||
rv = vm_pager_get_pages(ksobj, ma + i, count, NULL, NULL); | rv = vm_pager_get_pages(ksobj, ma + i, count, NULL, NULL); | ||||
KASSERT(rv == VM_PAGER_OK, ("%s: cannot get kstack for proc %d", | KASSERT(rv == VM_PAGER_OK, ("%s: cannot get kstack for proc %d", | ||||
__func__, td->td_proc->p_pid)); | __func__, td->td_proc->p_pid)); | ||||
vm_object_pip_wakeup(ksobj); | vm_object_pip_wakeup(ksobj); | ||||
for (j = i; j < i + count; j++) | for (j = i; j < i + count; j++) | ||||
vm_page_xunbusy(ma[j]); | vm_page_xunbusy(ma[j]); | ||||
i += count; | i += count; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 362 Lines • Show Last 20 Lines |
The changes to this file may be good or bad, but they don't seem related to the purpose of this change, so they should be part of a different patch.