--- 2.2.14-swapout-IO/mm/vmscan.c.~1~ Wed Jan 5 14:16:56 2000 +++ 2.2.14-swapout-IO/mm/vmscan.c Sun Jan 23 04:09:27 2000 @@ -32,7 +32,7 @@ * have died while we slept). */ static int try_to_swap_out(struct task_struct * tsk, struct vm_area_struct* vma, - unsigned long address, pte_t * page_table, int gfp_mask) + unsigned long address, pte_t * page_table, int gfp_mask, int * IO) { pte_t pte; unsigned long entry; @@ -156,6 +156,7 @@ set_pte(page_table, __pte(entry)); flush_tlb_page(vma, address); swap_duplicate(entry); /* One for the process, one for the swap cache */ + *IO = 1; add_to_swap_cache(page_map, entry); /* We checked we were unlocked way up above, and we have been careful not to stall until here */ @@ -183,7 +184,7 @@ */ static inline int swap_out_pmd(struct task_struct * tsk, struct vm_area_struct * vma, - pmd_t *dir, unsigned long address, unsigned long end, int gfp_mask) + pmd_t *dir, unsigned long address, unsigned long end, int gfp_mask, int * IO) { pte_t * pte; unsigned long pmd_end; @@ -205,7 +206,7 @@ do { int result; tsk->mm->swap_address = address + PAGE_SIZE; - result = try_to_swap_out(tsk, vma, address, pte, gfp_mask); + result = try_to_swap_out(tsk, vma, address, pte, gfp_mask, IO); if (result) return result; address += PAGE_SIZE; @@ -215,7 +216,7 @@ } static inline int swap_out_pgd(struct task_struct * tsk, struct vm_area_struct * vma, - pgd_t *dir, unsigned long address, unsigned long end, int gfp_mask) + pgd_t *dir, unsigned long address, unsigned long end, int gfp_mask, int * IO) { pmd_t * pmd; unsigned long pgd_end; @@ -235,7 +236,7 @@ end = pgd_end; do { - int result = swap_out_pmd(tsk, vma, pmd, address, end, gfp_mask); + int result = swap_out_pmd(tsk, vma, pmd, address, end, gfp_mask, IO); if (result) return result; address = (address + PMD_SIZE) & PMD_MASK; @@ -245,7 +246,7 @@ } static int swap_out_vma(struct task_struct * tsk, struct vm_area_struct * vma, - unsigned long address, int gfp_mask) + unsigned long address, int gfp_mask, int * IO) { pgd_t *pgdir; unsigned long end; @@ -258,7 +259,7 @@ end = vma->vm_end; while (address < end) { - int result = swap_out_pgd(tsk, vma, pgdir, address, end, gfp_mask); + int result = swap_out_pgd(tsk, vma, pgdir, address, end, gfp_mask, IO); if (result) return result; address = (address + PGDIR_SIZE) & PGDIR_MASK; @@ -267,7 +268,7 @@ return 0; } -static int swap_out_process(struct task_struct * p, int gfp_mask) +static int swap_out_process(struct task_struct * p, int gfp_mask, int * IO) { unsigned long address; struct vm_area_struct* vma; @@ -286,7 +287,7 @@ address = vma->vm_start; for (;;) { - int result = swap_out_vma(p, vma, address, gfp_mask); + int result = swap_out_vma(p, vma, address, gfp_mask, IO); if (result) return result; vma = vma->vm_next; @@ -307,7 +308,7 @@ * N.B. This function returns only 0 or 1. Return values != 1 from * the lower level routines result in continued processing. */ -static int swap_out(unsigned int priority, int gfp_mask) +static int swap_out(unsigned int priority, int gfp_mask, int * IO) { struct task_struct * p, * pbest; int assign = 0, counter; @@ -361,7 +362,7 @@ goto out; } - if (swap_out_process(pbest, gfp_mask)) + if (swap_out_process(pbest, gfp_mask, IO)) return 1; } out: @@ -381,6 +382,7 @@ { int priority; int count = SWAP_CLUSTER_MAX; + int IO = 0; lock_kernel(); @@ -397,13 +399,14 @@ /* Try to get rid of some shared memory pages.. */ if (gfp_mask & __GFP_IO) { while (shm_swap(priority, gfp_mask)) { + IO = 1; if (!--count) goto done; } } /* Then, try to page stuff out.. */ - while (swap_out(priority, gfp_mask)) { + while (swap_out(priority, gfp_mask, &IO)) { if (!--count) goto done; } @@ -412,6 +415,8 @@ } while (--priority >= 0); done: unlock_kernel(); + if (IO) + run_task_queue(&tq_disk); return priority >= 0; }