diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp
index 4c597d9..ae0d979 100644
a
|
b
|
swap_init_post_modules()
|
1493 | 1493 | |
1494 | 1494 | if (swapAutomatic) { |
1495 | 1495 | swapEnabled = true; |
1496 | | swapSize = (off_t)vm_page_num_pages() * B_PAGE_SIZE * 2; |
| 1496 | swapSize = (off_t)vm_page_num_pages() * B_PAGE_SIZE; |
| 1497 | if (swapSize <= (1024 * 1024 * 1024)) { |
| 1498 | // Memory under 1GB? double the swap |
| 1499 | swapSize *= 2; |
| 1500 | } |
1497 | 1501 | } |
1498 | 1502 | |
1499 | 1503 | if (!swapEnabled || swapSize < B_PAGE_SIZE) |
… |
… |
swap_init_post_modules()
|
1557 | 1561 | const char* swapPath = path.Path(); |
1558 | 1562 | |
1559 | 1563 | // Swap size limits prevent oversized swap files |
1560 | | off_t existingSwapSize = 0; |
1561 | | struct stat existingSwapStat; |
1562 | | if (stat(swapPath, &existingSwapStat) == 0) |
1563 | | existingSwapSize = existingSwapStat.st_size; |
1564 | | |
1565 | | off_t freeSpace = info.free_blocks * info.block_size + existingSwapSize; |
1566 | | off_t maxSwap = freeSpace; |
1567 | 1564 | if (swapAutomatic) { |
| 1565 | off_t existingSwapSize = 0; |
| 1566 | struct stat existingSwapStat; |
| 1567 | if (stat(swapPath, &existingSwapStat) == 0) |
| 1568 | existingSwapSize = existingSwapStat.st_size; |
| 1569 | |
| 1570 | off_t freeSpace = info.free_blocks * info.block_size + existingSwapSize; |
| 1571 | |
1568 | 1572 | // Adjust automatic swap to a maximum of 25% of the free space |
1569 | | maxSwap = (off_t)(0.25 * freeSpace); |
1570 | | } else { |
1571 | | // If user specified, leave 10% of the disk free |
1572 | | maxSwap = freeSpace - (off_t)(0.10 * freeSpace); |
1573 | | dprintf("%s: Warning: User specified swap file consumes over 90%% of " |
1574 | | "the available free space, limiting to 90%%\n", __func__); |
| 1573 | if (swapSize > (freeSpace / 4)) |
| 1574 | swapSize = (freeSpace / 4); |
1575 | 1575 | } |
1576 | 1576 | |
1577 | | if (swapSize > maxSwap) |
1578 | | swapSize = maxSwap; |
1579 | | |
1580 | 1577 | // Create swap file |
1581 | 1578 | int fd = open(swapPath, O_RDWR | O_CREAT | O_NOCACHE, S_IRUSR | S_IWUSR); |
1582 | 1579 | if (fd < 0) { |