No memory barrier is required. This was pointed out by kib@ a while ago,

but I got distracted by other matters.
This commit is contained in:
Dag-Erling Smørgrav 2012-09-04 19:04:02 +00:00
parent 81f72adf0f
commit db0390e833

View File

@ -163,6 +163,12 @@ static int overcommit = 0;
SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0, SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0,
"Configure virtual memory overcommit behavior. See tuning(7) " "Configure virtual memory overcommit behavior. See tuning(7) "
"for details."); "for details.");
static unsigned long swzone;
SYSCTL_ULONG(_vm, OID_AUTO, swzone, CTLFLAG_RD, &swzone, 0,
"Actual size of swap metadata zone");
static unsigned long swap_maxpages;
SYSCTL_ULONG(_vm, OID_AUTO, swap_maxpages, CTLFLAG_RD, &swap_maxpages, 0,
"Maximum amount of swap supported");
/* bits from overcommit */ /* bits from overcommit */
#define SWAP_RESERVE_FORCE_ON (1 << 0) #define SWAP_RESERVE_FORCE_ON (1 << 0)
@ -506,7 +512,7 @@ swap_pager_init(void)
void void
swap_pager_swap_init(void) swap_pager_swap_init(void)
{ {
int n, n2; unsigned long n, n2;
/* /*
* Number of in-transit swap bp operations. Don't * Number of in-transit swap bp operations. Don't
@ -548,11 +554,11 @@ swap_pager_swap_init(void)
n = cnt.v_page_count / 2; n = cnt.v_page_count / 2;
if (maxswzone && n > maxswzone / sizeof(struct swblock)) if (maxswzone && n > maxswzone / sizeof(struct swblock))
n = maxswzone / sizeof(struct swblock); n = maxswzone / sizeof(struct swblock);
n2 = n;
swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL, swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL,
NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM); NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM);
if (swap_zone == NULL) if (swap_zone == NULL)
panic("failed to create swap_zone."); panic("failed to create swap_zone.");
n2 = n;
do { do {
if (uma_zone_set_obj(swap_zone, &swap_zone_obj, n)) if (uma_zone_set_obj(swap_zone, &swap_zone_obj, n))
break; break;
@ -563,8 +569,9 @@ swap_pager_swap_init(void)
n -= ((n + 2) / 3); n -= ((n + 2) / 3);
} while (n > 0); } while (n > 0);
if (n2 != n) if (n2 != n)
printf("Swap zone entries reduced from %d to %d.\n", n2, n); printf("Swap zone entries reduced from %lu to %lu.\n", n2, n);
n2 = n; swap_maxpages = n * SWAP_META_PAGES;
swzone = n * sizeof(struct swblock);
/* /*
* Initialize our meta-data hash table. The swapper does not need to * Initialize our meta-data hash table. The swapper does not need to
@ -1848,7 +1855,7 @@ retry:
mtx_unlock(&swhash_mtx); mtx_unlock(&swhash_mtx);
VM_OBJECT_UNLOCK(object); VM_OBJECT_UNLOCK(object);
if (uma_zone_exhausted(swap_zone)) { if (uma_zone_exhausted(swap_zone)) {
if (atomic_cmpset_rel_int(&exhausted, 0, 1)) if (atomic_cmpset_int(&exhausted, 0, 1))
printf("swap zone exhausted, " printf("swap zone exhausted, "
"increase kern.maxswzone\n"); "increase kern.maxswzone\n");
vm_pageout_oom(VM_OOM_SWAPZ); vm_pageout_oom(VM_OOM_SWAPZ);
@ -1859,7 +1866,7 @@ retry:
goto retry; goto retry;
} }
if (atomic_cmpset_rel_int(&exhausted, 1, 0)) if (atomic_cmpset_int(&exhausted, 1, 0))
printf("swap zone ok\n"); printf("swap zone ok\n");
swap->swb_hnext = NULL; swap->swb_hnext = NULL;