swap_pager.c (d9135e724e78fb06f675b74f7e66bd9eaec8d094) | swap_pager.c (222d01951f8677015e3e96c6950e809c0d983c09) |
---|---|
1/*- 2 * Copyright (c) 1998 Matthew Dillon, 3 * Copyright (c) 1994 John S. Dyson 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1982, 1986, 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 371 unchanged lines hidden (view full) --- 380 mtx_unlock(&pbuf_mtx); 381 382 /* 383 * Initialize our zone. Right now I'm just guessing on the number 384 * we need based on the number of pages in the system. Each swblock 385 * can hold 16 pages, so this is probably overkill. This reservation 386 * is typically limited to around 32MB by default. 387 */ | 1/*- 2 * Copyright (c) 1998 Matthew Dillon, 3 * Copyright (c) 1994 John S. Dyson 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1982, 1986, 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 371 unchanged lines hidden (view full) --- 380 mtx_unlock(&pbuf_mtx); 381 382 /* 383 * Initialize our zone. Right now I'm just guessing on the number 384 * we need based on the number of pages in the system. Each swblock 385 * can hold 16 pages, so this is probably overkill. This reservation 386 * is typically limited to around 32MB by default. 387 */ |
388 n = cnt.v_page_count / 2; | 388 n = VMCNT_GET(page_count) / 2; |
389 if (maxswzone && n > maxswzone / sizeof(struct swblock)) 390 n = maxswzone / sizeof(struct swblock); 391 n2 = n; 392 swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL, 393 NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM); 394 if (swap_zone == NULL) 395 panic("failed to create swap_zone."); 396 do { --- 635 unchanged lines hidden (view full) --- 1032 1033 for (k = i; k < j; ++k) { 1034 bp->b_pages[k - i] = m[k]; 1035 m[k]->oflags |= VPO_SWAPINPROG; 1036 } 1037 } 1038 bp->b_npages = j - i; 1039 | 389 if (maxswzone && n > maxswzone / sizeof(struct swblock)) 390 n = maxswzone / sizeof(struct swblock); 391 n2 = n; 392 swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL, 393 NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM); 394 if (swap_zone == NULL) 395 panic("failed to create swap_zone."); 396 do { --- 635 unchanged lines hidden (view full) --- 1032 1033 for (k = i; k < j; ++k) { 1034 bp->b_pages[k - i] = m[k]; 1035 m[k]->oflags |= VPO_SWAPINPROG; 1036 } 1037 } 1038 bp->b_npages = j - i; 1039 |
1040 cnt.v_swapin++; 1041 cnt.v_swappgsin += bp->b_npages; | 1040 VMCNT_ADD(swapin, 1); 1041 VMCNT_ADD(swappgsin, bp->b_npages); |
1042 1043 /* 1044 * We still hold the lock on mreq, and our automatic completion routine 1045 * does not remove it. 1046 */ 1047 vm_object_pip_add(object, bp->b_npages); 1048 VM_OBJECT_UNLOCK(object); 1049 --- 17 unchanged lines hidden (view full) --- 1067 * is set in the meta-data. 1068 */ 1069 VM_OBJECT_LOCK(object); 1070 while ((mreq->oflags & VPO_SWAPINPROG) != 0) { 1071 mreq->oflags |= VPO_WANTED; 1072 vm_page_lock_queues(); 1073 vm_page_flag_set(mreq, PG_REFERENCED); 1074 vm_page_unlock_queues(); | 1042 1043 /* 1044 * We still hold the lock on mreq, and our automatic completion routine 1045 * does not remove it. 1046 */ 1047 vm_object_pip_add(object, bp->b_npages); 1048 VM_OBJECT_UNLOCK(object); 1049 --- 17 unchanged lines hidden (view full) --- 1067 * is set in the meta-data. 1068 */ 1069 VM_OBJECT_LOCK(object); 1070 while ((mreq->oflags & VPO_SWAPINPROG) != 0) { 1071 mreq->oflags |= VPO_WANTED; 1072 vm_page_lock_queues(); 1073 vm_page_flag_set(mreq, PG_REFERENCED); 1074 vm_page_unlock_queues(); |
1075 cnt.v_intrans++; | 1075 VMCNT_ADD(intrans, 1); |
1076 if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) { 1077 printf( 1078"swap_pager: indefinite wait buffer: bufobj: %p, blkno: %jd, size: %ld\n", 1079 bp->b_bufobj, (intmax_t)bp->b_blkno, bp->b_bcount); 1080 } 1081 } 1082 1083 /* --- 174 unchanged lines hidden (view full) --- 1258 VM_OBJECT_UNLOCK(object); 1259 bp->b_npages = n; 1260 /* 1261 * Must set dirty range for NFS to work. 1262 */ 1263 bp->b_dirtyoff = 0; 1264 bp->b_dirtyend = bp->b_bcount; 1265 | 1076 if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) { 1077 printf( 1078"swap_pager: indefinite wait buffer: bufobj: %p, blkno: %jd, size: %ld\n", 1079 bp->b_bufobj, (intmax_t)bp->b_blkno, bp->b_bcount); 1080 } 1081 } 1082 1083 /* --- 174 unchanged lines hidden (view full) --- 1258 VM_OBJECT_UNLOCK(object); 1259 bp->b_npages = n; 1260 /* 1261 * Must set dirty range for NFS to work. 1262 */ 1263 bp->b_dirtyoff = 0; 1264 bp->b_dirtyend = bp->b_bcount; 1265 |
1266 cnt.v_swapout++; 1267 cnt.v_swappgsout += bp->b_npages; | 1266 VMCNT_ADD(swapout, 1); 1267 VMCNT_ADD(swappgsout, bp->b_npages); |
1268 1269 /* 1270 * asynchronous 1271 * 1272 * NOTE: b_blkno is destroyed by the call to swapdev_strategy 1273 */ 1274 if (sync == FALSE) { 1275 bp->b_iodone = swp_pager_async_iodone; --- 854 unchanged lines hidden (view full) --- 2130 nblks = sp->sw_nblks; 2131 2132 /* 2133 * We can turn off this swap device safely only if the 2134 * available virtual memory in the system will fit the amount 2135 * of data we will have to page back in, plus an epsilon so 2136 * the system doesn't become critically low on swap space. 2137 */ | 1268 1269 /* 1270 * asynchronous 1271 * 1272 * NOTE: b_blkno is destroyed by the call to swapdev_strategy 1273 */ 1274 if (sync == FALSE) { 1275 bp->b_iodone = swp_pager_async_iodone; --- 854 unchanged lines hidden (view full) --- 2130 nblks = sp->sw_nblks; 2131 2132 /* 2133 * We can turn off this swap device safely only if the 2134 * available virtual memory in the system will fit the amount 2135 * of data we will have to page back in, plus an epsilon so 2136 * the system doesn't become critically low on swap space. 2137 */ |
2138 if (cnt.v_free_count + cnt.v_cache_count + swap_pager_avail < 2139 nblks + nswap_lowat) { | 2138 if (VMCNT_GET(free_count) + VMCNT_GET(cache_count) + 2139 swap_pager_avail < nblks + nswap_lowat) { |
2140 return (ENOMEM); 2141 } 2142 2143 /* 2144 * Prevent further allocations on this device. 2145 */ 2146 mtx_lock(&sw_dev_mtx); 2147 sp->sw_flags |= SW_CLOSING; --- 399 unchanged lines hidden --- | 2140 return (ENOMEM); 2141 } 2142 2143 /* 2144 * Prevent further allocations on this device. 2145 */ 2146 mtx_lock(&sw_dev_mtx); 2147 sp->sw_flags |= SW_CLOSING; --- 399 unchanged lines hidden --- |