swap_pager.c (426de76026cd7f586975b79b7159ee83bdaaacd1) swap_pager.c (05f0fdd26aa1789c04ae89358880922a54d197c3)
1/*
2 * Copyright (c) 1994 John S. Dyson
3 * Copyright (c) 1990 University of Utah.
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer

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

34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
40 *
41 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
1/*
2 * Copyright (c) 1994 John S. Dyson
3 * Copyright (c) 1990 University of Utah.
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer

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

34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
40 *
41 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
42 * $Id: swap_pager.c,v 1.8 1994/08/29 06:23:18 davidg Exp $
42 * $Id: swap_pager.c,v 1.9 1994/09/25 04:02:10 davidg Exp $
43 */
44
45/*
46 * Quick hack to page to dedicated partition(s).
47 * TODO:
48 * Add multiprocessor locks
49 * Deal with async writes in a better fashion
50 */

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

64#include <vm/vm_page.h>
65#include <vm/vm_pageout.h>
66#include <vm/swap_pager.h>
67
68#ifndef NPENDINGIO
69#define NPENDINGIO 16
70#endif
71
43 */
44
45/*
46 * Quick hack to page to dedicated partition(s).
47 * TODO:
48 * Add multiprocessor locks
49 * Deal with async writes in a better fashion
50 */

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

64#include <vm/vm_page.h>
65#include <vm/vm_pageout.h>
66#include <vm/swap_pager.h>
67
68#ifndef NPENDINGIO
69#define NPENDINGIO 16
70#endif
71
72int swap_pager_input __P((sw_pager_t, vm_page_t *, int, int));
73int swap_pager_output __P((sw_pager_t, vm_page_t *, int, int, int *));
74
72int nswiodone;
73extern int vm_pageout_rate_limit;
74static int cleandone;
75extern int hz;
76int swap_pager_full;
77extern vm_map_t pager_map;
78extern int vm_swap_size;
79

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

375}
376
377/*
378 * this routine frees swap space with a fragmentation
379 * minimization policy.
380 */
381void
382swap_pager_freeswapspace( unsigned from, unsigned to) {
75int nswiodone;
76extern int vm_pageout_rate_limit;
77static int cleandone;
78extern int hz;
79int swap_pager_full;
80extern vm_map_t pager_map;
81extern int vm_swap_size;
82

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

378}
379
380/*
381 * this routine frees swap space with a fragmentation
382 * minimization policy.
383 */
384void
385swap_pager_freeswapspace( unsigned from, unsigned to) {
386#ifdef EXP
383 unsigned nblocksfrag = btodb(SWB_NPAGES*PAGE_SIZE);
384 unsigned tmpalloc;
387 unsigned nblocksfrag = btodb(SWB_NPAGES*PAGE_SIZE);
388 unsigned tmpalloc;
385#ifdef EXP
386 if( ((to + 1) - from) >= nblocksfrag) {
387#endif
388 rlist_free(&swapmap, from, to);
389#ifdef EXP
390 return;
391 }
392 rlist_free(&swapfrag, from, to);
393 while( rlist_alloc(&swapfrag, nblocksfrag, &tmpalloc)) {

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

1533 if (swap_pager_done.tqh_first == NULL)
1534 return FALSE;
1535 for (;;) {
1536 s = splbio();
1537 /*
1538 * Look up and removal from done list must be done
1539 * at splbio() to avoid conflicts with swap_pager_iodone.
1540 */
389 if( ((to + 1) - from) >= nblocksfrag) {
390#endif
391 rlist_free(&swapmap, from, to);
392#ifdef EXP
393 return;
394 }
395 rlist_free(&swapfrag, from, to);
396 while( rlist_alloc(&swapfrag, nblocksfrag, &tmpalloc)) {

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

1536 if (swap_pager_done.tqh_first == NULL)
1537 return FALSE;
1538 for (;;) {
1539 s = splbio();
1540 /*
1541 * Look up and removal from done list must be done
1542 * at splbio() to avoid conflicts with swap_pager_iodone.
1543 */
1541 while (spc = swap_pager_done.tqh_first) {
1544 while ((spc = swap_pager_done.tqh_first) != 0) {
1542 pmap_qremove( spc->spc_kva, spc->spc_count);
1543 swap_pager_finish(spc);
1544 TAILQ_REMOVE(&swap_pager_done, spc, spc_list);
1545 goto doclean;
1546 }
1547
1548 /*
1549 * No operations done, thats all we can do for now.

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

1585
1586 /*
1587 * If no error mark as clean and inform the pmap system.
1588 * If error, mark as dirty so we will try again.
1589 * (XXX could get stuck doing this, should give up after awhile)
1590 */
1591 if (spc->spc_flags & SPC_ERROR) {
1592 for(i=0;i<spc->spc_count;i++) {
1545 pmap_qremove( spc->spc_kva, spc->spc_count);
1546 swap_pager_finish(spc);
1547 TAILQ_REMOVE(&swap_pager_done, spc, spc_list);
1548 goto doclean;
1549 }
1550
1551 /*
1552 * No operations done, thats all we can do for now.

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

1588
1589 /*
1590 * If no error mark as clean and inform the pmap system.
1591 * If error, mark as dirty so we will try again.
1592 * (XXX could get stuck doing this, should give up after awhile)
1593 */
1594 if (spc->spc_flags & SPC_ERROR) {
1595 for(i=0;i<spc->spc_count;i++) {
1593 printf("swap_pager_finish: clean of page %x failed\n",
1594 VM_PAGE_TO_PHYS(spc->spc_m[i]));
1596 printf("swap_pager_finish: clean of page %lx failed\n",
1597 (u_long)VM_PAGE_TO_PHYS(spc->spc_m[i]));
1595 spc->spc_m[i]->flags |= PG_LAUNDRY;
1596 }
1597 } else {
1598 for(i=0;i<spc->spc_count;i++) {
1599 pmap_clear_modify(VM_PAGE_TO_PHYS(spc->spc_m[i]));
1600 spc->spc_m[i]->flags |= PG_CLEAN;
1601 }
1602 }

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

1625 int s;
1626
1627 s = splbio();
1628 spc = (swp_clean_t) bp->b_spc;
1629 TAILQ_REMOVE(&swap_pager_inuse, spc, spc_list);
1630 TAILQ_INSERT_TAIL(&swap_pager_done, spc, spc_list);
1631 if (bp->b_flags & B_ERROR) {
1632 spc->spc_flags |= SPC_ERROR;
1598 spc->spc_m[i]->flags |= PG_LAUNDRY;
1599 }
1600 } else {
1601 for(i=0;i<spc->spc_count;i++) {
1602 pmap_clear_modify(VM_PAGE_TO_PHYS(spc->spc_m[i]));
1603 spc->spc_m[i]->flags |= PG_CLEAN;
1604 }
1605 }

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

1628 int s;
1629
1630 s = splbio();
1631 spc = (swp_clean_t) bp->b_spc;
1632 TAILQ_REMOVE(&swap_pager_inuse, spc, spc_list);
1633 TAILQ_INSERT_TAIL(&swap_pager_done, spc, spc_list);
1634 if (bp->b_flags & B_ERROR) {
1635 spc->spc_flags |= SPC_ERROR;
1633 printf("error %d blkno %d sz %d ",
1634 bp->b_error, bp->b_blkno, bp->b_bcount);
1636 printf("error %d blkno %lu sz %ld ",
1637 bp->b_error, (u_long)bp->b_blkno, bp->b_bcount);
1635 }
1636
1637/*
1638 if ((bp->b_flags & B_READ) == 0)
1639 vwakeup(bp);
1640*/
1641
1642 bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS|B_DIRTY|B_ASYNC);

--- 42 unchanged lines hidden ---
1638 }
1639
1640/*
1641 if ((bp->b_flags & B_READ) == 0)
1642 vwakeup(bp);
1643*/
1644
1645 bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS|B_DIRTY|B_ASYNC);

--- 42 unchanged lines hidden ---