vm_page.c (60755) | vm_page.c (61081) |
---|---|
1/* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91 | 1/* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91 |
37 * $FreeBSD: head/sys/vm/vm_page.c 60755 2000-05-21 12:50:18Z peter $ | 37 * $FreeBSD: head/sys/vm/vm_page.c 61081 2000-05-29 22:40:54Z dillon $ |
38 */ 39 40/* 41 * Copyright (c) 1987, 1990 Carnegie-Mellon University. 42 * All rights reserved. 43 * 44 * Authors: Avadis Tevanian, Jr., Michael Wayne Young 45 * --- 637 unchanged lines hidden (view full) --- 683 vm_page_t m; 684 685 while (TRUE) { 686 m = vm_page_list_find( 687 PQ_CACHE, 688 (pindex + object->pg_color) & PQ_L2_MASK, 689 FALSE 690 ); | 38 */ 39 40/* 41 * Copyright (c) 1987, 1990 Carnegie-Mellon University. 42 * All rights reserved. 43 * 44 * Authors: Avadis Tevanian, Jr., Michael Wayne Young 45 * --- 637 unchanged lines hidden (view full) --- 683 vm_page_t m; 684 685 while (TRUE) { 686 m = vm_page_list_find( 687 PQ_CACHE, 688 (pindex + object->pg_color) & PQ_L2_MASK, 689 FALSE 690 ); |
691 if (m && ((m->flags & PG_BUSY) || m->busy || | 691 if (m && ((m->flags & (PG_BUSY|PG_UNMANAGED)) || m->busy || |
692 m->hold_count || m->wire_count)) { 693 vm_page_deactivate(m); 694 continue; 695 } 696 return m; 697 } 698} 699 --- 292 unchanged lines hidden (view full) --- 992 993 s = splvm(); 994 if (m->queue != PQ_ACTIVE) { 995 if ((m->queue - m->pc) == PQ_CACHE) 996 cnt.v_reactivated++; 997 998 vm_page_unqueue(m); 999 | 692 m->hold_count || m->wire_count)) { 693 vm_page_deactivate(m); 694 continue; 695 } 696 return m; 697 } 698} 699 --- 292 unchanged lines hidden (view full) --- 992 993 s = splvm(); 994 if (m->queue != PQ_ACTIVE) { 995 if ((m->queue - m->pc) == PQ_CACHE) 996 cnt.v_reactivated++; 997 998 vm_page_unqueue(m); 999 |
1000 if (m->wire_count == 0) { | 1000 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) { |
1001 m->queue = PQ_ACTIVE; 1002 vm_page_queues[PQ_ACTIVE].lcnt++; 1003 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); 1004 if (m->act_count < ACT_INIT) 1005 m->act_count = ACT_INIT; 1006 cnt.v_active_count++; 1007 } 1008 } else { --- 114 unchanged lines hidden (view full) --- 1123 if (vp && VSHOULDFREE(vp)) { 1124 if ((vp->v_flag & (VTBFREE|VDOOMED|VFREE)) == 0) { 1125 TAILQ_INSERT_TAIL(&vnode_tobefree_list, vp, v_freelist); 1126 vp->v_flag |= VTBFREE; 1127 } 1128 } 1129 } 1130 | 1001 m->queue = PQ_ACTIVE; 1002 vm_page_queues[PQ_ACTIVE].lcnt++; 1003 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); 1004 if (m->act_count < ACT_INIT) 1005 m->act_count = ACT_INIT; 1006 cnt.v_active_count++; 1007 } 1008 } else { --- 114 unchanged lines hidden (view full) --- 1123 if (vp && VSHOULDFREE(vp)) { 1124 if ((vp->v_flag & (VTBFREE|VDOOMED|VFREE)) == 0) { 1125 TAILQ_INSERT_TAIL(&vnode_tobefree_list, vp, v_freelist); 1126 vp->v_flag |= VTBFREE; 1127 } 1128 } 1129 } 1130 |
1131 /* 1132 * Clear the UNMANAGED flag when freeing an unmanaged page. 1133 */ 1134 1135 if (m->flags & PG_UNMANAGED) { 1136 m->flags &= ~PG_UNMANAGED; 1137 } else { |
|
1131#ifdef __alpha__ | 1138#ifdef __alpha__ |
1132 pmap_page_is_free(m); | 1139 pmap_page_is_free(m); |
1133#endif | 1140#endif |
1141 } |
|
1134 1135 m->queue = PQ_FREE + m->pc; 1136 pq = &vm_page_queues[m->queue]; 1137 pq->lcnt++; 1138 ++(*pq->cnt); 1139 1140 /* 1141 * Put zero'd pages on the end ( where we look for zero'd pages --- 8 unchanged lines hidden (view full) --- 1150 } 1151 1152 vm_page_free_wakeup(); 1153 1154 splx(s); 1155} 1156 1157/* | 1142 1143 m->queue = PQ_FREE + m->pc; 1144 pq = &vm_page_queues[m->queue]; 1145 pq->lcnt++; 1146 ++(*pq->cnt); 1147 1148 /* 1149 * Put zero'd pages on the end ( where we look for zero'd pages --- 8 unchanged lines hidden (view full) --- 1158 } 1159 1160 vm_page_free_wakeup(); 1161 1162 splx(s); 1163} 1164 1165/* |
1166 * vm_page_unmanage: 1167 * 1168 * Prevent PV management from being done on the page. The page is 1169 * removed from the paging queues as if it were wired, and as a 1170 * consequence of no longer being managed the pageout daemon will not 1171 * touch it (since there is no way to locate the pte mappings for the 1172 * page). madvise() calls that mess with the pmap will also no longer 1173 * operate on the page. 1174 * 1175 * Beyond that the page is still reasonably 'normal'. Freeing the page 1176 * will clear the flag. 1177 * 1178 * This routine is used by OBJT_PHYS objects - objects using unswappable 1179 * physical memory as backing store rather then swap-backed memory and 1180 * will eventually be extended to support 4MB unmanaged physical 1181 * mappings. 1182 */ 1183 1184void 1185vm_page_unmanage(vm_page_t m) 1186{ 1187 int s; 1188 1189 s = splvm(); 1190 if ((m->flags & PG_UNMANAGED) == 0) { 1191 if (m->wire_count == 0) 1192 vm_page_unqueue(m); 1193 } 1194 vm_page_flag_set(m, PG_UNMANAGED); 1195 splx(s); 1196} 1197 1198/* |
|
1158 * vm_page_wire: 1159 * 1160 * Mark this page as wired down by yet 1161 * another map, removing it from paging queues 1162 * as necessary. 1163 * 1164 * The page queues must be locked. 1165 * This routine may not block. 1166 */ 1167void 1168vm_page_wire(m) 1169 register vm_page_t m; 1170{ 1171 int s; 1172 | 1199 * vm_page_wire: 1200 * 1201 * Mark this page as wired down by yet 1202 * another map, removing it from paging queues 1203 * as necessary. 1204 * 1205 * The page queues must be locked. 1206 * This routine may not block. 1207 */ 1208void 1209vm_page_wire(m) 1210 register vm_page_t m; 1211{ 1212 int s; 1213 |
1214 /* 1215 * Only bump the wire statistics if the page is not already wired, 1216 * and only unqueue the page if it is on some queue (if it is unmanaged 1217 * it is already off the queues). 1218 */ |
|
1173 s = splvm(); 1174 if (m->wire_count == 0) { | 1219 s = splvm(); 1220 if (m->wire_count == 0) { |
1175 vm_page_unqueue(m); | 1221 if ((m->flags & PG_UNMANAGED) == 0) 1222 vm_page_unqueue(m); |
1176 cnt.v_wire_count++; 1177 } 1178 m->wire_count++; 1179 splx(s); 1180 vm_page_flag_set(m, PG_MAPPED); 1181} 1182 1183/* --- 29 unchanged lines hidden (view full) --- 1213 int s; 1214 1215 s = splvm(); 1216 1217 if (m->wire_count > 0) { 1218 m->wire_count--; 1219 if (m->wire_count == 0) { 1220 cnt.v_wire_count--; | 1223 cnt.v_wire_count++; 1224 } 1225 m->wire_count++; 1226 splx(s); 1227 vm_page_flag_set(m, PG_MAPPED); 1228} 1229 1230/* --- 29 unchanged lines hidden (view full) --- 1260 int s; 1261 1262 s = splvm(); 1263 1264 if (m->wire_count > 0) { 1265 m->wire_count--; 1266 if (m->wire_count == 0) { 1267 cnt.v_wire_count--; |
1221 if (activate) { | 1268 if (m->flags & PG_UNMANAGED) { 1269 ; 1270 } else if (activate) { |
1222 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); 1223 m->queue = PQ_ACTIVE; 1224 vm_page_queues[PQ_ACTIVE].lcnt++; 1225 cnt.v_active_count++; 1226 } else { 1227 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1228 m->queue = PQ_INACTIVE; 1229 vm_page_queues[PQ_INACTIVE].lcnt++; --- 24 unchanged lines hidden (view full) --- 1254 1255 /* 1256 * Ignore if already inactive. 1257 */ 1258 if (m->queue == PQ_INACTIVE) 1259 return; 1260 1261 s = splvm(); | 1271 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_ACTIVE].pl, m, pageq); 1272 m->queue = PQ_ACTIVE; 1273 vm_page_queues[PQ_ACTIVE].lcnt++; 1274 cnt.v_active_count++; 1275 } else { 1276 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1277 m->queue = PQ_INACTIVE; 1278 vm_page_queues[PQ_INACTIVE].lcnt++; --- 24 unchanged lines hidden (view full) --- 1303 1304 /* 1305 * Ignore if already inactive. 1306 */ 1307 if (m->queue == PQ_INACTIVE) 1308 return; 1309 1310 s = splvm(); |
1262 if (m->wire_count == 0) { | 1311 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) { |
1263 if ((m->queue - m->pc) == PQ_CACHE) 1264 cnt.v_reactivated++; 1265 vm_page_unqueue(m); 1266 if (athead) 1267 TAILQ_INSERT_HEAD(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1268 else 1269 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1270 m->queue = PQ_INACTIVE; --- 17 unchanged lines hidden (view full) --- 1288 * This routine may not block. 1289 */ 1290void 1291vm_page_cache(m) 1292 register vm_page_t m; 1293{ 1294 int s; 1295 | 1312 if ((m->queue - m->pc) == PQ_CACHE) 1313 cnt.v_reactivated++; 1314 vm_page_unqueue(m); 1315 if (athead) 1316 TAILQ_INSERT_HEAD(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1317 else 1318 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq); 1319 m->queue = PQ_INACTIVE; --- 17 unchanged lines hidden (view full) --- 1337 * This routine may not block. 1338 */ 1339void 1340vm_page_cache(m) 1341 register vm_page_t m; 1342{ 1343 int s; 1344 |
1296 if ((m->flags & PG_BUSY) || m->busy || m->wire_count) { | 1345 if ((m->flags & (PG_BUSY|PG_UNMANAGED)) || m->busy || m->wire_count) { |
1297 printf("vm_page_cache: attempting to cache busy page\n"); 1298 return; 1299 } 1300 if ((m->queue - m->pc) == PQ_CACHE) 1301 return; 1302 1303 /* 1304 * Remove all pmaps and indicate that the page is not --- 624 unchanged lines hidden --- | 1346 printf("vm_page_cache: attempting to cache busy page\n"); 1347 return; 1348 } 1349 if ((m->queue - m->pc) == PQ_CACHE) 1350 return; 1351 1352 /* 1353 * Remove all pmaps and indicate that the page is not --- 624 unchanged lines hidden --- |