vm_phys.c (27067774dce3388702a4cf744d7096c6fb71b688) vm_phys.c (dbbaf04f1e3ff8e00eb536769e9531203f6e3631)
1/*-
2 * Copyright (c) 2002-2006 Rice University
3 * Copyright (c) 2007 Alan L. Cox <alc@cs.rice.edu>
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Alan L. Cox,
7 * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro.
8 *

--- 118 unchanged lines hidden (view full) ---

127 */
128#if defined(VM_ISADMA_BOUNDARY) && defined(VM_LOWMEM_BOUNDARY)
129CTASSERT(VM_ISADMA_BOUNDARY < VM_LOWMEM_BOUNDARY);
130#endif
131#if defined(VM_LOWMEM_BOUNDARY) && defined(VM_DMA32_BOUNDARY)
132CTASSERT(VM_LOWMEM_BOUNDARY < VM_DMA32_BOUNDARY);
133#endif
134
1/*-
2 * Copyright (c) 2002-2006 Rice University
3 * Copyright (c) 2007 Alan L. Cox <alc@cs.rice.edu>
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Alan L. Cox,
7 * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro.
8 *

--- 118 unchanged lines hidden (view full) ---

127 */
128#if defined(VM_ISADMA_BOUNDARY) && defined(VM_LOWMEM_BOUNDARY)
129CTASSERT(VM_ISADMA_BOUNDARY < VM_LOWMEM_BOUNDARY);
130#endif
131#if defined(VM_LOWMEM_BOUNDARY) && defined(VM_DMA32_BOUNDARY)
132CTASSERT(VM_LOWMEM_BOUNDARY < VM_DMA32_BOUNDARY);
133#endif
134
135static int cnt_prezero;
136SYSCTL_INT(_vm_stats_misc, OID_AUTO, cnt_prezero, CTLFLAG_RD,
137 &cnt_prezero, 0, "The number of physical pages prezeroed at idle time");
138
139static int sysctl_vm_phys_free(SYSCTL_HANDLER_ARGS);
140SYSCTL_OID(_vm, OID_AUTO, phys_free, CTLTYPE_STRING | CTLFLAG_RD,
141 NULL, 0, sysctl_vm_phys_free, "A", "Phys Free Info");
142
143static int sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS);
144SYSCTL_OID(_vm, OID_AUTO, phys_segs, CTLTYPE_STRING | CTLFLAG_RD,
145 NULL, 0, sysctl_vm_phys_segs, "A", "Phys Seg Info");
146

--- 1146 unchanged lines hidden (view full) ---

1293 }
1294 vm_freelist_add(fl, m_tmp, order, 0);
1295 }
1296 KASSERT(m_set == m, ("vm_phys_unfree_page: fatal inconsistency"));
1297 return (TRUE);
1298}
1299
1300/*
135static int sysctl_vm_phys_free(SYSCTL_HANDLER_ARGS);
136SYSCTL_OID(_vm, OID_AUTO, phys_free, CTLTYPE_STRING | CTLFLAG_RD,
137 NULL, 0, sysctl_vm_phys_free, "A", "Phys Free Info");
138
139static int sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS);
140SYSCTL_OID(_vm, OID_AUTO, phys_segs, CTLTYPE_STRING | CTLFLAG_RD,
141 NULL, 0, sysctl_vm_phys_segs, "A", "Phys Seg Info");
142

--- 1146 unchanged lines hidden (view full) ---

1289 }
1290 vm_freelist_add(fl, m_tmp, order, 0);
1291 }
1292 KASSERT(m_set == m, ("vm_phys_unfree_page: fatal inconsistency"));
1293 return (TRUE);
1294}
1295
1296/*
1301 * Try to zero one physical page. Used by an idle priority thread.
1302 */
1303boolean_t
1304vm_phys_zero_pages_idle(void)
1305{
1306 static struct vm_freelist *fl;
1307 static int flind, oind, pind;
1308 vm_page_t m, m_tmp;
1309 int domain;
1310
1311 domain = vm_rr_selectdomain();
1312 fl = vm_phys_free_queues[domain][0][0];
1313 mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
1314 for (;;) {
1315 TAILQ_FOREACH_REVERSE(m, &fl[oind].pl, pglist, plinks.q) {
1316 for (m_tmp = m; m_tmp < &m[1 << oind]; m_tmp++) {
1317 if ((m_tmp->flags & (PG_CACHED | PG_ZERO)) == 0) {
1318 vm_phys_unfree_page(m_tmp);
1319 vm_phys_freecnt_adj(m, -1);
1320 mtx_unlock(&vm_page_queue_free_mtx);
1321 pmap_zero_page_idle(m_tmp);
1322 m_tmp->flags |= PG_ZERO;
1323 mtx_lock(&vm_page_queue_free_mtx);
1324 vm_phys_freecnt_adj(m, 1);
1325 vm_phys_free_pages(m_tmp, 0);
1326 vm_page_zero_count++;
1327 cnt_prezero++;
1328 return (TRUE);
1329 }
1330 }
1331 }
1332 oind++;
1333 if (oind == VM_NFREEORDER) {
1334 oind = 0;
1335 pind++;
1336 if (pind == VM_NFREEPOOL) {
1337 pind = 0;
1338 flind++;
1339 if (flind == vm_nfreelists)
1340 flind = 0;
1341 }
1342 fl = vm_phys_free_queues[domain][flind][pind];
1343 }
1344 }
1345}
1346
1347/*
1348 * Allocate a contiguous set of physical pages of the given size
1349 * "npages" from the free lists. All of the physical pages must be at
1350 * or above the given physical address "low" and below the given
1351 * physical address "high". The given value "alignment" determines the
1352 * alignment of the first physical page in the set. If the given value
1353 * "boundary" is non-zero, then the set of physical pages cannot cross
1354 * any physical address boundary that is a multiple of that value. Both
1355 * "alignment" and "boundary" must be a power of two.

--- 175 unchanged lines hidden ---
1297 * Allocate a contiguous set of physical pages of the given size
1298 * "npages" from the free lists. All of the physical pages must be at
1299 * or above the given physical address "low" and below the given
1300 * physical address "high". The given value "alignment" determines the
1301 * alignment of the first physical page in the set. If the given value
1302 * "boundary" is non-zero, then the set of physical pages cannot cross
1303 * any physical address boundary that is a multiple of that value. Both
1304 * "alignment" and "boundary" must be a power of two.

--- 175 unchanged lines hidden ---