Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/swap_pager.c
Show First 20 Lines • Show All 943 Lines • ▼ Show 20 Lines | KASSERT(srcobject->type == OBJT_SWAP, | ||||
("%s: Srcobject not swappable", __func__)); | ("%s: Srcobject not swappable", __func__)); | ||||
if (dstobject->type == OBJT_SWAP && | if (dstobject->type == OBJT_SWAP && | ||||
swp_pager_meta_lookup(dstobject, pindex) != SWAPBLK_NONE) { | swp_pager_meta_lookup(dstobject, pindex) != SWAPBLK_NONE) { | ||||
/* Caller should destroy the source block. */ | /* Caller should destroy the source block. */ | ||||
return (false); | return (false); | ||||
} | } | ||||
/* | /* | ||||
* Destination has no swapblk and is not resident, transfer source. | * Transfer source. | ||||
* swp_pager_meta_build() can sleep. | * swp_pager_meta_build() can sleep. | ||||
*/ | */ | ||||
vm_object_pip_add(srcobject, 1); | vm_object_pip_add(srcobject, 1); | ||||
VM_OBJECT_WUNLOCK(srcobject); | VM_OBJECT_WUNLOCK(srcobject); | ||||
vm_object_pip_add(dstobject, 1); | vm_object_pip_add(dstobject, 1); | ||||
dstaddr = swp_pager_meta_build(dstobject, pindex, addr); | dstaddr = swp_pager_meta_build(dstobject, pindex, addr); | ||||
KASSERT(dstaddr == SWAPBLK_NONE, | KASSERT(dstaddr == SWAPBLK_NONE, | ||||
("Unexpected destination swapblk")); | ("Unexpected destination swapblk")); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
* This routine may not sleep. | * This routine may not sleep. | ||||
* | * | ||||
* The object containing the page must be locked. | * The object containing the page must be locked. | ||||
*/ | */ | ||||
static void | static void | ||||
swap_pager_unswapped(vm_page_t m) | swap_pager_unswapped(vm_page_t m) | ||||
{ | { | ||||
struct swblk *sb; | struct swblk *sb; | ||||
bool locked; | |||||
VM_OBJECT_ASSERT_WLOCKED(m->object); | VM_OBJECT_ASSERT_LOCKED(m->object); | ||||
/* | /* | ||||
* The meta data only exists if the object is OBJT_SWAP | * The meta data only exists if the object is OBJT_SWAP | ||||
* and even then might not be allocated yet. | * and even then might not be allocated yet. | ||||
*/ | */ | ||||
KASSERT(m->object->type == OBJT_SWAP, | KASSERT(m->object->type == OBJT_SWAP, | ||||
("Free object not swappable")); | ("Free object not swappable")); | ||||
sb = SWAP_PCTRIE_LOOKUP(&m->object->un_pager.swp.swp_blks, | sb = SWAP_PCTRIE_LOOKUP(&m->object->un_pager.swp.swp_blks, | ||||
rounddown(m->pindex, SWAP_META_PAGES)); | rounddown(m->pindex, SWAP_META_PAGES)); | ||||
if (sb == NULL) | if (sb == NULL) | ||||
return; | return; | ||||
if (sb->d[m->pindex % SWAP_META_PAGES] == SWAPBLK_NONE) | if (sb->d[m->pindex % SWAP_META_PAGES] == SWAPBLK_NONE) | ||||
return; | return; | ||||
locked = VM_OBJECT_WOWNED(m->object); | |||||
if (!locked && !VM_OBJECT_TRYUPGRADE(m->object)) | |||||
return; | |||||
swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES], 1); | swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES], 1); | ||||
ota_j.email.ne.jp: We need
We also need
swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES, 1);
before… | |||||
sb->d[m->pindex % SWAP_META_PAGES] = SWAPBLK_NONE; | sb->d[m->pindex % SWAP_META_PAGES] = SWAPBLK_NONE; | ||||
swp_pager_free_empty_swblk(m->object, sb); | swp_pager_free_empty_swblk(m->object, sb); | ||||
if (!locked) | |||||
VM_OBJECT_LOCK_DOWNGRADE(m->object); | |||||
Not Done Inline ActionsGiven swp_pager_meta_ctl() with SWM_POP calls VM_OBJECT_ASSERT_WLOCKED, I expected VM_OBJECT_ASSERT_WLOCKED. ota_j.email.ne.jp: Given swp_pager_meta_ctl() with SWM_POP calls VM_OBJECT_ASSERT_WLOCKED, I expected… | |||||
} | } | ||||
/* | /* | ||||
* swap_pager_getpages() - bring pages in from swap | * swap_pager_getpages() - bring pages in from swap | ||||
* | * | ||||
* Attempt to page in the pages in array "ma" of length "count". The | * Attempt to page in the pages in array "ma" of length "count". The | ||||
* caller may optionally specify that additional pages preceding and | * caller may optionally specify that additional pages preceding and | ||||
* succeeding the specified range be paged in. The number of such pages | * succeeding the specified range be paged in. The number of such pages | ||||
▲ Show 20 Lines • Show All 1,006 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct swblk *sb; | struct swblk *sb; | ||||
VM_OBJECT_ASSERT_LOCKED(object); | VM_OBJECT_ASSERT_LOCKED(object); | ||||
/* | /* | ||||
* The meta data only exists if the object is OBJT_SWAP | * The meta data only exists if the object is OBJT_SWAP | ||||
* and even then might not be allocated yet. | * and even then might not be allocated yet. | ||||
*/ | */ | ||||
KASSERT(object->type == OBJT_SWAP, | KASSERT(object->type == OBJT_SWAP, | ||||
Not Done Inline ActionsIs this check still needed after the rest of the changes ? kib: Is this check still needed after the rest of the changes ? | |||||
("Lookup object not swappable")); | ("Lookup object not swappable")); | ||||
sb = SWAP_PCTRIE_LOOKUP(&object->un_pager.swp.swp_blks, | sb = SWAP_PCTRIE_LOOKUP(&object->un_pager.swp.swp_blks, | ||||
rounddown(pindex, SWAP_META_PAGES)); | rounddown(pindex, SWAP_META_PAGES)); | ||||
if (sb == NULL) | if (sb == NULL) | ||||
return (SWAPBLK_NONE); | return (SWAPBLK_NONE); | ||||
return (sb->d[pindex % SWAP_META_PAGES]); | return (sb->d[pindex % SWAP_META_PAGES]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 887 Lines • Show Last 20 Lines |
We need
We also need
swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES, 1);
before SWAPBLK_NONE assignment.
swp_pager_freeswapspace calls blist_free while swp_pager_free_empty_swblk calls uma_zfree.