MCPcopy Create free account
hub / github.com/F-Stack/f-stack / swap_pager_unswapped

Function swap_pager_unswapped

freebsd/vm/swap_pager.c:1164–1210  ·  view source on GitHub ↗

* SWAP_PAGER_PAGE_UNSWAPPED() - remove swap backing store related to page * * This removes any associated swap backing store, whether valid or * not, from the page. * * This routine is typically called when a page is made dirty, at * which point any associated swap can be freed. MADV_FREE also * calls us in a special-case situation * * NOTE!!! If the page is clean and the swap was valid

Source from the content-addressed store, hash-verified

1162 * The object containing the page may be locked.
1163 */
1164static void
1165swap_pager_unswapped(vm_page_t m)
1166{
1167 struct swblk *sb;
1168 vm_object_t obj;
1169
1170 /*
1171 * Handle enqueing deferred frees first. If we do not have the
1172 * object lock we wait for the page daemon to clear the space.
1173 */
1174 obj = m->object;
1175 if (!VM_OBJECT_WOWNED(obj)) {
1176 VM_PAGE_OBJECT_BUSY_ASSERT(m);
1177 /*
1178 * The caller is responsible for synchronization but we
1179 * will harmlessly handle races. This is typically provided
1180 * by only calling unswapped() when a page transitions from
1181 * clean to dirty.
1182 */
1183 if ((m->a.flags & (PGA_SWAP_SPACE | PGA_SWAP_FREE)) ==
1184 PGA_SWAP_SPACE) {
1185 vm_page_aflag_set(m, PGA_SWAP_FREE);
1186 counter_u64_add(swap_free_deferred, 1);
1187 }
1188 return;
1189 }
1190 if ((m->a.flags & PGA_SWAP_FREE) != 0)
1191 counter_u64_add(swap_free_completed, 1);
1192 vm_page_aflag_clear(m, PGA_SWAP_FREE | PGA_SWAP_SPACE);
1193
1194 /*
1195 * The meta data only exists if the object is OBJT_SWAP
1196 * and even then might not be allocated yet.
1197 */
1198 KASSERT(m->object->type == OBJT_SWAP,
1199 ("Free object not swappable"));
1200
1201 sb = SWAP_PCTRIE_LOOKUP(&m->object->un_pager.swp.swp_blks,
1202 rounddown(m->pindex, SWAP_META_PAGES));
1203 if (sb == NULL)
1204 return;
1205 if (sb->d[m->pindex % SWAP_META_PAGES] == SWAPBLK_NONE)
1206 return;
1207 swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES], 1);
1208 sb->d[m->pindex % SWAP_META_PAGES] = SWAPBLK_NONE;
1209 swp_pager_free_empty_swblk(m->object, sb);
1210}
1211
1212/*
1213 * swap_pager_getpages() - bring pages in from swap

Callers 1

swp_pager_force_dirtyFunction · 0.85

Calls 5

vm_page_aflag_setFunction · 0.85
vm_page_aflag_clearFunction · 0.85
swp_pager_freeswapspaceFunction · 0.85
counter_u64_addFunction · 0.50

Tested by

no test coverage detected