summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-01-07 11:48:44 +0000
committerkib <kib@FreeBSD.org>2017-01-07 11:48:44 +0000
commitf24d2952a9099f9b7061db82f18b1c7a530f17c8 (patch)
treec95de0b0081a8aa4a23d18fc4869e76c3ceef50b /sys/vm
parent025e6d460abef76b9b283e8a09020aa178b57203 (diff)
downloadFreeBSD-src-f24d2952a9099f9b7061db82f18b1c7a530f17c8.zip
FreeBSD-src-f24d2952a9099f9b7061db82f18b1c7a530f17c8.tar.gz
MFC r310496:
Fix argument type and microoptimize swp_pager_meta_free().
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/swap_pager.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 3402c0a..30f6d97 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -410,7 +410,7 @@ static daddr_t swp_pager_getswapspace(int npages);
*/
static struct swblock **swp_pager_hash(vm_object_t object, vm_pindex_t index);
static void swp_pager_meta_build(vm_object_t, vm_pindex_t, daddr_t);
-static void swp_pager_meta_free(vm_object_t, vm_pindex_t, daddr_t);
+static void swp_pager_meta_free(vm_object_t, vm_pindex_t, vm_pindex_t);
static void swp_pager_meta_free_all(vm_object_t);
static daddr_t swp_pager_meta_ctl(vm_object_t, vm_pindex_t, int);
@@ -1866,42 +1866,42 @@ done:
* with resident pages.
*/
static void
-swp_pager_meta_free(vm_object_t object, vm_pindex_t index, daddr_t count)
+swp_pager_meta_free(vm_object_t object, vm_pindex_t index, vm_pindex_t count)
{
+ struct swblock **pswap, *swap;
+ vm_pindex_t c;
+ daddr_t v;
+ int n, sidx;
VM_OBJECT_ASSERT_LOCKED(object);
- if (object->type != OBJT_SWAP)
+ if (object->type != OBJT_SWAP || count == 0)
return;
- while (count > 0) {
- struct swblock **pswap;
- struct swblock *swap;
-
- mtx_lock(&swhash_mtx);
+ mtx_lock(&swhash_mtx);
+ for (c = 0; c < count;) {
pswap = swp_pager_hash(object, index);
-
- if ((swap = *pswap) != NULL) {
- daddr_t v = swap->swb_pages[index & SWAP_META_MASK];
-
- if (v != SWAPBLK_NONE) {
- swp_pager_freeswapspace(v, 1);
- swap->swb_pages[index & SWAP_META_MASK] =
- SWAPBLK_NONE;
- if (--swap->swb_count == 0) {
- *pswap = swap->swb_hnext;
- uma_zfree(swap_zone, swap);
- --object->un_pager.swp.swp_bcount;
- }
+ sidx = index & SWAP_META_MASK;
+ n = SWAP_META_PAGES - sidx;
+ index += n;
+ if ((swap = *pswap) == NULL) {
+ c += n;
+ continue;
+ }
+ for (; c < count && sidx < SWAP_META_PAGES; ++c, ++sidx) {
+ if ((v = swap->swb_pages[sidx]) == SWAPBLK_NONE)
+ continue;
+ swp_pager_freeswapspace(v, 1);
+ swap->swb_pages[sidx] = SWAPBLK_NONE;
+ if (--swap->swb_count == 0) {
+ *pswap = swap->swb_hnext;
+ uma_zfree(swap_zone, swap);
+ --object->un_pager.swp.swp_bcount;
+ c += SWAP_META_PAGES - sidx;
+ break;
}
- --count;
- ++index;
- } else {
- int n = SWAP_META_PAGES - (index & SWAP_META_MASK);
- count -= n;
- index += n;
}
- mtx_unlock(&swhash_mtx);
}
+ mtx_unlock(&swhash_mtx);
}
/*
OpenPOWER on IntegriCloud