FreeBSD Bugzilla – Attachment 33364 Details for
Bug 54690
[PATCH] wrap swap_pager's swhash with a mutex
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
swhash.col.patch
swhash.col.patch (text/plain; charset=us-ascii), 4.18 KB, created by
Bruce M Simpson
on 2003-07-23 10:49:08 UTC
(
hide
)
Description:
swhash.col.patch
Filename:
MIME Type:
Creator:
Bruce M Simpson
Created:
2003-07-23 10:49:08 UTC
Size:
4.18 KB
patch
obsolete
>Generated by diffcoll on Wed 23 Jul 2003 07:57:34 BST > >diff -uN src/sys/vm/swap_pager.c.orig src/sys/vm/swap_pager.c >--- /usr/src/sys/vm/swap_pager.c.orig Sat Jul 19 00:56:10 2003 >+++ /usr/src/sys/vm/swap_pager.c Wed Jul 23 07:57:13 2003 >@@ -113,8 +113,11 @@ > static int nsw_cluster_max; /* maximum VOP I/O allowed */ > > struct blist *swapblist; >+ >+static struct mtx swhash_mtx; /* protect hash table */ > static struct swblock **swhash; > static int swhash_mask; >+ > static int swap_async_max = 4; /* maximum in-progress async I/O's */ > static struct sx sw_alloc_sx; > >@@ -256,6 +259,8 @@ > */ > dmmax = SWB_NPAGES * 2; > dmmax_mask = ~(dmmax - 1); >+ >+ mtx_init(&swhash_mtx, "swap_pager swhash mutex", NULL, MTX_DEF); > } > > /* >@@ -1648,6 +1653,7 @@ > int i; > > VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); >+ mtx_lock(&swhash_mtx); > for (bcount = 0; bcount < object->un_pager.swp.swp_bcount; bcount++) { > struct swblock *swap; > >@@ -1655,8 +1661,10 @@ > for (i = 0; i < SWAP_META_PAGES; ++i) { > daddr_t v = swap->swb_pages[i]; > if (v != SWAPBLK_NONE && >- BLK2DEVIDX(v) == devidx) >+ BLK2DEVIDX(v) == devidx) { >+ mtx_unlock(&swhash_mtx); > return 1; >+ } > } > } > >@@ -1664,6 +1672,7 @@ > if (index > 0x20000000) > panic("swap_pager_isswapped: failed to locate all swap meta blocks"); > } >+ mtx_unlock(&swhash_mtx); > return 0; > } > >@@ -1752,6 +1761,7 @@ > > full_rescan: > waitobj = NULL; >+ mtx_lock(&swhash_mtx); > for (i = 0; i <= swhash_mask; i++) { /* '<=' is correct here */ > restart: > pswap = &swhash[i]; >@@ -1763,7 +1773,9 @@ > break; > } > if (j < SWAP_META_PAGES) { >+ mtx_unlock(&swhash_mtx); > swp_pager_force_pagein(swap, j); >+ mtx_lock(&swhash_mtx); > goto restart; > } else if (swap->swb_object->paging_in_progress) { > if (!waitobj) >@@ -1772,6 +1784,8 @@ > pswap = &swap->swb_hnext; > } > } >+ mtx_unlock(&swhash_mtx); >+ > if (waitobj && *sw_used) { > /* > * We wait on an arbitrary object to clock our rescans >@@ -1782,6 +1796,7 @@ > VM_OBJECT_UNLOCK(waitobj); > goto full_rescan; > } >+ > if (*sw_used) > panic("swapoff: failed to locate %d swap blocks", *sw_used); > } >@@ -1809,6 +1824,8 @@ > * find a swapblk. > * > * This routine must be called at splvm(). >+ * It is the caller's responsibility to obtain the swhash_mtx lock >+ * before calling. > */ > static __inline struct swblock ** > swp_pager_hash(vm_object_t object, vm_pindex_t index) >@@ -1817,6 +1834,7 @@ > struct swblock *swap; > > index &= ~(vm_pindex_t)SWAP_META_MASK; >+ > pswap = &swhash[(index ^ (int)(intptr_t)object) & swhash_mask]; > while ((swap = *pswap) != NULL) { > if (swap->swb_object == object && >@@ -1826,6 +1844,7 @@ > } > pswap = &swap->swb_hnext; > } >+ > return (pswap); > } > >@@ -1883,16 +1902,20 @@ > * and, since the hash table may have changed, retry. > */ > retry: >+ mtx_lock(&swhash_mtx); > pswap = swp_pager_hash(object, pindex); > > if ((swap = *pswap) == NULL) { > int i; > >- if (swapblk == SWAPBLK_NONE) >+ if (swapblk == SWAPBLK_NONE) { >+ mtx_unlock(&swhash_mtx); > return; >+ } > > swap = *pswap = uma_zalloc(swap_zone, M_NOWAIT); > if (swap == NULL) { >+ mtx_unlock(&swhash_mtx); > VM_WAIT; > goto retry; > } >@@ -1924,6 +1947,8 @@ > swap->swb_pages[idx] = swapblk; > if (swapblk != SWAPBLK_NONE) > ++swap->swb_count; >+ >+ mtx_unlock(&swhash_mtx); > } > > /* >@@ -1946,6 +1971,7 @@ > if (object->type != OBJT_SWAP) > return; > >+ mtx_lock(&swhash_mtx); > while (count > 0) { > struct swblock **pswap; > struct swblock *swap; >@@ -1973,6 +1999,7 @@ > index += n; > } > } >+ mtx_unlock(&swhash_mtx); > } > > /* >@@ -1993,6 +2020,7 @@ > if (object->type != OBJT_SWAP) > return; > >+ mtx_lock(&swhash_mtx); > while (object->un_pager.swp.swp_bcount) { > struct swblock **pswap; > struct swblock *swap; >@@ -2018,6 +2046,7 @@ > if (index > 0x20000000) > panic("swp_pager_meta_free_all: failed to locate all swap meta blocks"); > } >+ mtx_unlock(&swhash_mtx); > } > > /* >@@ -2062,6 +2091,7 @@ > return (SWAPBLK_NONE); > > r1 = SWAPBLK_NONE; >+ mtx_lock(&swhash_mtx); > pswap = swp_pager_hash(object, pindex); > > if ((swap = *pswap) != NULL) { >@@ -2083,6 +2113,7 @@ > } > } > } >+ mtx_unlock(&swhash_mtx); > return (r1); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 54690
:
33363
| 33364 |
33365