Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/swap_pager.c
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
#include "opt_vm.h" | #include "opt_vm.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/bio.h> | #include <sys/bio.h> | ||||
#include <sys/blist.h> | #include <sys/blist.h> | ||||
#include <sys/buf.h> | #include <sys/buf.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/disk.h> | #include <sys/disk.h> | ||||
#include <sys/disklabel.h> | |||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <sys/namei.h> | #include <sys/namei.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/pctrie.h> | #include <sys/pctrie.h> | ||||
▲ Show 20 Lines • Show All 2,203 Lines • ▼ Show 20 Lines | swaponsomething(struct vnode *vp, void *id, u_long nblks, | ||||
sp->sw_nblks = nblks; | sp->sw_nblks = nblks; | ||||
sp->sw_used = 0; | sp->sw_used = 0; | ||||
sp->sw_strategy = strategy; | sp->sw_strategy = strategy; | ||||
sp->sw_close = close; | sp->sw_close = close; | ||||
sp->sw_flags = flags; | sp->sw_flags = flags; | ||||
sp->sw_blist = blist_create(nblks, M_WAITOK); | sp->sw_blist = blist_create(nblks, M_WAITOK); | ||||
/* | /* | ||||
* Do not free the first two block in order to avoid overwriting | * Do not free the first blocks in order to avoid overwriting | ||||
* any bsd label at the front of the partition | * any bsd label at the front of the partition | ||||
*/ | */ | ||||
blist_free(sp->sw_blist, 2, nblks - 2); | blist_free(sp->sw_blist, howmany(BBSIZE, PAGE_SIZE), | ||||
nblks - howmany(BBSIZE, PAGE_SIZE)); | |||||
dvbase = 0; | dvbase = 0; | ||||
mtx_lock(&sw_dev_mtx); | mtx_lock(&sw_dev_mtx); | ||||
TAILQ_FOREACH(tsp, &swtailq, sw_list) { | TAILQ_FOREACH(tsp, &swtailq, sw_list) { | ||||
if (tsp->sw_end >= dvbase) { | if (tsp->sw_end >= dvbase) { | ||||
/* | /* | ||||
* We put one uncovered page between the devices | * We put one uncovered page between the devices | ||||
* in order to definitively prevent any cross-device | * in order to definitively prevent any cross-device | ||||
* I/O requests | * I/O requests | ||||
*/ | */ | ||||
dvbase = tsp->sw_end + 1; | dvbase = tsp->sw_end + 1; | ||||
} | } | ||||
} | } | ||||
sp->sw_first = dvbase; | sp->sw_first = dvbase; | ||||
sp->sw_end = dvbase + nblks; | sp->sw_end = dvbase + nblks; | ||||
TAILQ_INSERT_TAIL(&swtailq, sp, sw_list); | TAILQ_INSERT_TAIL(&swtailq, sp, sw_list); | ||||
nswapdev++; | nswapdev++; | ||||
swap_pager_avail += nblks - 2; | swap_pager_avail += nblks - howmany(BBSIZE, PAGE_SIZE); | ||||
swap_total += nblks; | swap_total += nblks; | ||||
swapon_check_swzone(); | swapon_check_swzone(); | ||||
swp_sizecheck(); | swp_sizecheck(); | ||||
mtx_unlock(&sw_dev_mtx); | mtx_unlock(&sw_dev_mtx); | ||||
EVENTHANDLER_INVOKE(swapon, sp); | EVENTHANDLER_INVOKE(swapon, sp); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | #endif | ||||
if (vm_free_count() + swap_pager_avail < nblks + nswap_lowat) | if (vm_free_count() + swap_pager_avail < nblks + nswap_lowat) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
/* | /* | ||||
* Prevent further allocations on this device. | * Prevent further allocations on this device. | ||||
*/ | */ | ||||
mtx_lock(&sw_dev_mtx); | mtx_lock(&sw_dev_mtx); | ||||
sp->sw_flags |= SW_CLOSING; | sp->sw_flags |= SW_CLOSING; | ||||
swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks); | swap_pager_avail -= blist_fill(sp->sw_blist, 0, nblks); | ||||
ota_j.email.ne.jp: Which one is a better value to pass here, 0 or howmany(BBSIZE, PAGE_SIZE) ?
I think behavior… | |||||
swap_total -= nblks; | swap_total -= nblks; | ||||
mtx_unlock(&sw_dev_mtx); | mtx_unlock(&sw_dev_mtx); | ||||
/* | /* | ||||
* Page in the contents of the device and close it. | * Page in the contents of the device and close it. | ||||
*/ | */ | ||||
swap_pager_swapoff(sp); | swap_pager_swapoff(sp); | ||||
▲ Show 20 Lines • Show All 564 Lines • Show Last 20 Lines |
Which one is a better value to pass here, 0 or howmany(BBSIZE, PAGE_SIZE) ?
I think behavior is the same regardless of the value given blist_free(sp->sw_blist, howmany(BBSIZE, PAGE_SIZE), nblks - howmany(BBSIZE, PAGE_SIZE)) was done.