vm_page.c (b99348e5ea4da3e6070eb2eb8c14b6e007101041) | vm_page.c (49ca10d40c30236988dd5153c1456b474ae2e4b9) |
---|---|
1/*- 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * The Mach Operating System project at Carnegie-Mellon University. 8 * --- 1341 unchanged lines hidden (view full) --- 1350 */ 1351 if (vm_paging_needed()) 1352 pagedaemon_wakeup(); 1353 1354 return (m); 1355} 1356 1357/* | 1/*- 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * The Mach Operating System project at Carnegie-Mellon University. 8 * --- 1341 unchanged lines hidden (view full) --- 1350 */ 1351 if (vm_paging_needed()) 1352 pagedaemon_wakeup(); 1353 1354 return (m); 1355} 1356 1357/* |
1358 * Initialize a page that has been freshly dequeued from a freelist. 1359 * The caller has to drop the vnode returned, if it is not NULL. 1360 * 1361 * To be called with vm_page_queue_free_mtx held. 1362 */ 1363struct vnode * 1364vm_page_alloc_init(vm_page_t m) 1365{ 1366 struct vnode *drop; 1367 vm_object_t m_object; 1368 1369 KASSERT(m->queue == PQ_NONE, 1370 ("vm_page_alloc_init: page %p has unexpected queue %d", 1371 m, m->queue)); 1372 KASSERT(m->wire_count == 0, 1373 ("vm_page_alloc_init: page %p is wired", m)); 1374 KASSERT(m->hold_count == 0, 1375 ("vm_page_alloc_init: page %p is held", m)); 1376 KASSERT(m->busy == 0, 1377 ("vm_page_alloc_init: page %p is busy", m)); 1378 KASSERT(m->dirty == 0, 1379 ("vm_page_alloc_init: page %p is dirty", m)); 1380 KASSERT(pmap_page_get_memattr(m) == VM_MEMATTR_DEFAULT, 1381 ("vm_page_alloc_init: page %p has unexpected memattr %d", 1382 m, pmap_page_get_memattr(m))); 1383 mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); 1384 drop = NULL; 1385 if ((m->flags & PG_CACHED) != 0) { 1386 m->valid = 0; 1387 m_object = m->object; 1388 vm_page_cache_remove(m); 1389 if (m_object->type == OBJT_VNODE && 1390 m_object->cache == NULL) 1391 drop = m_object->handle; 1392 } else { 1393 KASSERT(VM_PAGE_IS_FREE(m), 1394 ("vm_page_alloc_init: page %p is not free", m)); 1395 KASSERT(m->valid == 0, 1396 ("vm_page_alloc_init: free page %p is valid", m)); 1397 cnt.v_free_count--; 1398 } 1399 if (m->flags & PG_ZERO) 1400 vm_page_zero_count--; 1401 /* Don't clear the PG_ZERO flag; we'll need it later. */ 1402 m->flags = PG_UNMANAGED | (m->flags & PG_ZERO); 1403 m->oflags = 0; 1404 /* Unmanaged pages don't use "act_count". */ 1405 return (drop); 1406} 1407 1408/* 1409 * vm_page_alloc_freelist: 1410 * 1411 * Allocate a page from the specified freelist with specified order. 1412 * Only the ALLOC_CLASS values in req are honored, other request flags 1413 * are ignored. 1414 */ 1415vm_page_t 1416vm_page_alloc_freelist(int flind, int order, int req) 1417{ 1418 struct vnode *drop; 1419 vm_page_t m; 1420 int page_req; 1421 1422 m = NULL; 1423 page_req = req & VM_ALLOC_CLASS_MASK; 1424 mtx_lock(&vm_page_queue_free_mtx); 1425 /* 1426 * Do not allocate reserved pages unless the req has asked for it. 1427 */ 1428 if (cnt.v_free_count + cnt.v_cache_count > cnt.v_free_reserved || 1429 (page_req == VM_ALLOC_SYSTEM && 1430 cnt.v_free_count + cnt.v_cache_count > cnt.v_interrupt_free_min) || 1431 (page_req == VM_ALLOC_INTERRUPT && 1432 cnt.v_free_count + cnt.v_cache_count > 0)) { 1433 m = vm_phys_alloc_freelist_pages(flind, VM_FREEPOOL_DIRECT, order); 1434 } 1435 if (m == NULL) { 1436 mtx_unlock(&vm_page_queue_free_mtx); 1437 return (NULL); 1438 } 1439 drop = vm_page_alloc_init(m); 1440 mtx_unlock(&vm_page_queue_free_mtx); 1441 if (drop) 1442 vdrop(drop); 1443 return (m); 1444} 1445 1446/* |
|
1358 * vm_wait: (also see VM_WAIT macro) 1359 * 1360 * Block until free pages are available for allocation 1361 * - Called in various places before memory allocations. 1362 */ 1363void 1364vm_wait(void) 1365{ --- 1157 unchanged lines hidden --- | 1447 * vm_wait: (also see VM_WAIT macro) 1448 * 1449 * Block until free pages are available for allocation 1450 * - Called in various places before memory allocations. 1451 */ 1452void 1453vm_wait(void) 1454{ --- 1157 unchanged lines hidden --- |