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

Function vm_pageout_cluster

freebsd/vm/vm_pageout.c:350–453  ·  view source on GitHub ↗

* Scan for pages at adjacent offsets within the given page's object that are * eligible for laundering, form a cluster of these pages and the given page, * and launder that cluster. */

Source from the content-addressed store, hash-verified

348 * and launder that cluster.
349 */
350static int
351vm_pageout_cluster(vm_page_t m)
352{
353 vm_object_t object;
354 vm_page_t mc[2 * vm_pageout_page_count], p, pb, ps;
355 vm_pindex_t pindex;
356 int ib, is, page_base, pageout_count;
357
358 object = m->object;
359 VM_OBJECT_ASSERT_WLOCKED(object);
360 pindex = m->pindex;
361
362 vm_page_assert_xbusied(m);
363
364 mc[vm_pageout_page_count] = pb = ps = m;
365 pageout_count = 1;
366 page_base = vm_pageout_page_count;
367 ib = 1;
368 is = 1;
369
370 /*
371 * We can cluster only if the page is not clean, busy, or held, and
372 * the page is in the laundry queue.
373 *
374 * During heavy mmap/modification loads the pageout
375 * daemon can really fragment the underlying file
376 * due to flushing pages out of order and not trying to
377 * align the clusters (which leaves sporadic out-of-order
378 * holes). To solve this problem we do the reverse scan
379 * first and attempt to align our cluster, then do a
380 * forward scan if room remains.
381 */
382more:
383 while (ib != 0 && pageout_count < vm_pageout_page_count) {
384 if (ib > pindex) {
385 ib = 0;
386 break;
387 }
388 if ((p = vm_page_prev(pb)) == NULL ||
389 vm_page_tryxbusy(p) == 0) {
390 ib = 0;
391 break;
392 }
393 if (vm_page_wired(p)) {
394 ib = 0;
395 vm_page_xunbusy(p);
396 break;
397 }
398 vm_page_test_dirty(p);
399 if (p->dirty == 0) {
400 ib = 0;
401 vm_page_xunbusy(p);
402 break;
403 }
404 if (!vm_page_in_laundry(p) || !vm_page_try_remove_write(p)) {
405 vm_page_xunbusy(p);
406 ib = 0;
407 break;

Callers 1

vm_pageout_cleanFunction · 0.85

Calls 8

vm_page_prevFunction · 0.85
vm_page_tryxbusyFunction · 0.85
vm_page_wiredFunction · 0.85
vm_page_test_dirtyFunction · 0.85
vm_page_in_laundryFunction · 0.85
vm_page_try_remove_writeFunction · 0.85
vm_page_nextFunction · 0.85
vm_pageout_flushFunction · 0.85

Tested by

no test coverage detected