Messages in this thread Patch in this message | | | Date | Mon, 9 Aug 1999 02:38:49 +0200 (CEST) | From | Andrea Arcangeli <> | Subject | [patch] swap clustering (search for an empty cluster) |
| |
This patch will improve swapout performances if lots of swap is free (mainly with my other swap-persistence patch applyed at the same time) since it will avoid us to start swapping new pages in the middle of a fragmented area.
The algorithm is the same as before with the difference that now we first search for a completly empty cluster. If there aren't empty cluster then the algorithm will revert to the current behaviour (to start the cluster from the first free block in the swap area).
In the testing I did some time ago on 2.2.x it even doubled swapout performances.
The patch also fixes a little error: in got_page si->cluster_next must be set to `offset + 1' and to to `offset'.
Patch against 2.3.13-pre8:
--- 2.3.13-pre8-tmp/mm/swapfile.c.~1~ Thu Jul 22 01:07:28 1999 +++ 2.3.13-pre8-tmp/mm/swapfile.c Mon Aug 9 02:30:21 1999 @@ -46,16 +46,36 @@ } } si->cluster_nr = SWAPFILE_CLUSTER; + + /* try to find an empty (even not aligned) cluster. */ + offset = si->lowest_bit; + check_next_cluster: + if (offset+SWAPFILE_CLUSTER-1 <= si->highest_bit) + { + int nr; + for (nr = offset; nr < offset+SWAPFILE_CLUSTER; nr++) + if (si->swap_map[nr]) + { + offset = nr+1; + goto check_next_cluster; + } + /* We found a completly empty cluster, so start + * using it. + */ + goto got_page; + } + /* No luck, so now go finegrined as usual. -Andrea */ for (offset = si->lowest_bit; offset <= si->highest_bit ; offset++) { if (si->swap_map[offset]) continue; - si->lowest_bit = offset; -got_page: - si->swap_map[offset] = 1; - nr_swap_pages--; + got_page: + if (offset == si->lowest_bit) + si->lowest_bit++; if (offset == si->highest_bit) si->highest_bit--; - si->cluster_next = offset; + si->swap_map[offset] = 1; + nr_swap_pages--; + si->cluster_next = offset+1; return offset; } return 0; Andrea
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |