10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
53898Srsb * Common Development and Distribution License (the "License").
63898Srsb * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*10443SVijay.Balakrishna@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/param.h>
280Sstevel@tonic-gate #include <sys/systm.h>
290Sstevel@tonic-gate #include <sys/errno.h>
300Sstevel@tonic-gate #include <sys/kmem.h>
310Sstevel@tonic-gate #include <sys/vnode.h>
323898Srsb #include <sys/vfs_opreg.h>
330Sstevel@tonic-gate #include <sys/swap.h>
340Sstevel@tonic-gate #include <sys/sysmacros.h>
350Sstevel@tonic-gate #include <sys/buf.h>
360Sstevel@tonic-gate #include <sys/callb.h>
370Sstevel@tonic-gate #include <sys/debug.h>
380Sstevel@tonic-gate #include <vm/seg.h>
390Sstevel@tonic-gate #include <sys/fs/swapnode.h>
400Sstevel@tonic-gate #include <fs/fs_subr.h>
410Sstevel@tonic-gate #include <sys/cmn_err.h>
420Sstevel@tonic-gate #include <sys/mem_config.h>
430Sstevel@tonic-gate #include <sys/atomic.h>
440Sstevel@tonic-gate
450Sstevel@tonic-gate extern const fs_operation_def_t swap_vnodeops_template[];
460Sstevel@tonic-gate
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate * swapfs_minfree is the amount of physical memory (actually remaining
490Sstevel@tonic-gate * availrmem) that we want to keep free for the rest of the system. This
500Sstevel@tonic-gate * means that swapfs can only grow to availrmem - swapfs_minfree. This
510Sstevel@tonic-gate * can be set as just constant value or a certain percentage of installed
520Sstevel@tonic-gate * physical memory. It is set in swapinit().
530Sstevel@tonic-gate *
540Sstevel@tonic-gate * Users who want to change the amount of memory that can be used as swap
550Sstevel@tonic-gate * space should do so by setting swapfs_desfree at boot time,
560Sstevel@tonic-gate * not swapfs_minfree.
570Sstevel@tonic-gate */
580Sstevel@tonic-gate
590Sstevel@tonic-gate pgcnt_t swapfs_desfree = 0;
600Sstevel@tonic-gate pgcnt_t swapfs_minfree = 0;
610Sstevel@tonic-gate pgcnt_t swapfs_reserve = 0;
620Sstevel@tonic-gate
630Sstevel@tonic-gate #ifdef SWAPFS_DEBUG
640Sstevel@tonic-gate int swapfs_debug;
650Sstevel@tonic-gate #endif /* SWAPFS_DEBUG */
660Sstevel@tonic-gate
670Sstevel@tonic-gate
680Sstevel@tonic-gate static int swapfs_vpcount;
690Sstevel@tonic-gate static kmutex_t swapfs_lock;
700Sstevel@tonic-gate static struct async_reqs *sw_ar, *sw_pendlist, *sw_freelist;
710Sstevel@tonic-gate
720Sstevel@tonic-gate static struct vnode **swap_vnodes; /* ptr's to swap vnodes */
730Sstevel@tonic-gate
740Sstevel@tonic-gate static void swap_init_mem_config(void);
750Sstevel@tonic-gate
760Sstevel@tonic-gate static pgcnt_t initial_swapfs_desfree;
770Sstevel@tonic-gate static pgcnt_t initial_swapfs_minfree;
780Sstevel@tonic-gate static pgcnt_t initial_swapfs_reserve;
790Sstevel@tonic-gate
800Sstevel@tonic-gate static int swap_sync(struct vfs *vfsp, short flag, struct cred *cr);
810Sstevel@tonic-gate
820Sstevel@tonic-gate static void
swapfs_recalc_save_initial(void)830Sstevel@tonic-gate swapfs_recalc_save_initial(void)
840Sstevel@tonic-gate {
850Sstevel@tonic-gate initial_swapfs_desfree = swapfs_desfree;
860Sstevel@tonic-gate initial_swapfs_minfree = swapfs_minfree;
870Sstevel@tonic-gate initial_swapfs_reserve = swapfs_reserve;
880Sstevel@tonic-gate }
890Sstevel@tonic-gate
900Sstevel@tonic-gate static int
swapfs_recalc(pgcnt_t pgs)910Sstevel@tonic-gate swapfs_recalc(pgcnt_t pgs)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate pgcnt_t new_swapfs_desfree;
940Sstevel@tonic-gate pgcnt_t new_swapfs_minfree;
950Sstevel@tonic-gate pgcnt_t new_swapfs_reserve;
960Sstevel@tonic-gate
970Sstevel@tonic-gate new_swapfs_desfree = initial_swapfs_desfree;
980Sstevel@tonic-gate new_swapfs_minfree = initial_swapfs_minfree;
990Sstevel@tonic-gate new_swapfs_reserve = initial_swapfs_reserve;
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate if (new_swapfs_desfree == 0)
1020Sstevel@tonic-gate new_swapfs_desfree = btopr(7 * 512 * 1024); /* 3-1/2Mb */;
1030Sstevel@tonic-gate
1040Sstevel@tonic-gate if (new_swapfs_minfree == 0) {
1050Sstevel@tonic-gate /*
1060Sstevel@tonic-gate * We set this lower than we'd like here, 2Mb, because we
1070Sstevel@tonic-gate * always boot on swapfs. It's up to a safer value,
1080Sstevel@tonic-gate * swapfs_desfree, when/if we add physical swap devices
1090Sstevel@tonic-gate * in swapadd(). Users who want to change the amount of
1100Sstevel@tonic-gate * memory that can be used as swap space should do so by
1110Sstevel@tonic-gate * setting swapfs_desfree at boot time, not swapfs_minfree.
1120Sstevel@tonic-gate * However, swapfs_minfree is tunable by install as a
1130Sstevel@tonic-gate * workaround for bugid 1147463.
1140Sstevel@tonic-gate */
1150Sstevel@tonic-gate new_swapfs_minfree = MAX(btopr(2 * 1024 * 1024), pgs >> 3);
1160Sstevel@tonic-gate }
1170Sstevel@tonic-gate
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate * priv processes can reserve memory as swap as long as availrmem
1200Sstevel@tonic-gate * remains greater than swapfs_minfree; in the case of non-priv
1210Sstevel@tonic-gate * processes, memory can be reserved as swap only if availrmem
1220Sstevel@tonic-gate * doesn't fall below (swapfs_minfree + swapfs_reserve). Thus,
1230Sstevel@tonic-gate * swapfs_reserve amount of memswap is not available to non-priv
1240Sstevel@tonic-gate * processes. This protects daemons such as automounter dying
1250Sstevel@tonic-gate * as a result of application processes eating away almost entire
1260Sstevel@tonic-gate * membased swap. This safeguard becomes useless if apps are run
1270Sstevel@tonic-gate * with root access.
1280Sstevel@tonic-gate *
1290Sstevel@tonic-gate * set swapfs_reserve to a minimum of 4Mb or 1/128 of physmem whichever
1300Sstevel@tonic-gate * is greater up to the limit of 128 MB.
1310Sstevel@tonic-gate */
1320Sstevel@tonic-gate if (new_swapfs_reserve == 0)
1330Sstevel@tonic-gate new_swapfs_reserve = MIN(btopr(128 * 1024 * 1024),
1340Sstevel@tonic-gate MAX(btopr(4 * 1024 * 1024), pgs >> 7));
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate /* Test basic numeric viability. */
1370Sstevel@tonic-gate if (new_swapfs_minfree > pgs)
1380Sstevel@tonic-gate return (0);
1390Sstevel@tonic-gate
1400Sstevel@tonic-gate /* Equivalent test to anon_resvmem() check. */
1410Sstevel@tonic-gate if (availrmem < new_swapfs_minfree) {
1420Sstevel@tonic-gate /*
1430Sstevel@tonic-gate * If ism pages are being used, then there must be agreement
1440Sstevel@tonic-gate * between these two policies.
1450Sstevel@tonic-gate */
1460Sstevel@tonic-gate if ((availrmem > segspt_minfree) && (segspt_minfree > 0)) {
1470Sstevel@tonic-gate new_swapfs_minfree = segspt_minfree;
1480Sstevel@tonic-gate } else {
1490Sstevel@tonic-gate return (0);
1500Sstevel@tonic-gate }
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate
1530Sstevel@tonic-gate swapfs_desfree = new_swapfs_desfree;
1540Sstevel@tonic-gate swapfs_minfree = new_swapfs_minfree;
1550Sstevel@tonic-gate swapfs_reserve = new_swapfs_reserve;
1560Sstevel@tonic-gate
1570Sstevel@tonic-gate return (1);
1580Sstevel@tonic-gate }
1590Sstevel@tonic-gate
1600Sstevel@tonic-gate /*ARGSUSED1*/
1610Sstevel@tonic-gate int
swapinit(int fstype,char * name)1620Sstevel@tonic-gate swapinit(int fstype, char *name)
1630Sstevel@tonic-gate { /* reserve for mp */
1640Sstevel@tonic-gate ssize_t sw_freelist_size = klustsize / PAGESIZE * 2;
1650Sstevel@tonic-gate int i, error;
1660Sstevel@tonic-gate
1670Sstevel@tonic-gate static const fs_operation_def_t swap_vfsops[] = {
1683898Srsb VFSNAME_SYNC, { .vfs_sync = swap_sync },
1690Sstevel@tonic-gate NULL, NULL
1700Sstevel@tonic-gate };
1710Sstevel@tonic-gate
1720Sstevel@tonic-gate SWAPFS_PRINT(SWAP_SUBR, "swapinit\n", 0, 0, 0, 0, 0);
1730Sstevel@tonic-gate mutex_init(&swapfs_lock, NULL, MUTEX_DEFAULT, NULL);
1740Sstevel@tonic-gate
1750Sstevel@tonic-gate swap_vnodes = kmem_zalloc(MAX_SWAP_VNODES * sizeof (struct vnode *),
1760Sstevel@tonic-gate KM_SLEEP);
1770Sstevel@tonic-gate
1780Sstevel@tonic-gate swapfs_recalc_save_initial();
1790Sstevel@tonic-gate if (!swapfs_recalc(physmem))
1800Sstevel@tonic-gate cmn_err(CE_PANIC, "swapfs_minfree(%lu) > physmem(%lu)",
1810Sstevel@tonic-gate swapfs_minfree, physmem);
1820Sstevel@tonic-gate
1830Sstevel@tonic-gate /*
1840Sstevel@tonic-gate * Arrange for a callback on memory size change.
1850Sstevel@tonic-gate */
1860Sstevel@tonic-gate swap_init_mem_config();
1870Sstevel@tonic-gate
1880Sstevel@tonic-gate sw_ar = (struct async_reqs *)
1890Sstevel@tonic-gate kmem_zalloc(sw_freelist_size*sizeof (struct async_reqs), KM_SLEEP);
1900Sstevel@tonic-gate
1910Sstevel@tonic-gate error = vfs_setfsops(fstype, swap_vfsops, NULL);
1920Sstevel@tonic-gate if (error != 0) {
1930Sstevel@tonic-gate cmn_err(CE_WARN, "swapinit: bad vfs ops template");
1940Sstevel@tonic-gate return (error);
1950Sstevel@tonic-gate }
1960Sstevel@tonic-gate
1970Sstevel@tonic-gate error = vn_make_ops(name, swap_vnodeops_template, &swap_vnodeops);
1980Sstevel@tonic-gate if (error != 0) {
1990Sstevel@tonic-gate (void) vfs_freevfsops_by_type(fstype);
2000Sstevel@tonic-gate cmn_err(CE_WARN, "swapinit: bad vnode ops template");
2010Sstevel@tonic-gate return (error);
2020Sstevel@tonic-gate }
2030Sstevel@tonic-gate sw_freelist = sw_ar;
2040Sstevel@tonic-gate for (i = 0; i < sw_freelist_size - 1; i++)
2050Sstevel@tonic-gate sw_ar[i].a_next = &sw_ar[i + 1];
2060Sstevel@tonic-gate
2070Sstevel@tonic-gate return (0);
2080Sstevel@tonic-gate }
2090Sstevel@tonic-gate
2100Sstevel@tonic-gate /*
2110Sstevel@tonic-gate * Get a swapfs vnode corresponding to the specified identifier.
2120Sstevel@tonic-gate */
2130Sstevel@tonic-gate struct vnode *
swapfs_getvp(ulong_t vidx)2140Sstevel@tonic-gate swapfs_getvp(ulong_t vidx)
2150Sstevel@tonic-gate {
2160Sstevel@tonic-gate struct vnode *vp;
2170Sstevel@tonic-gate
2180Sstevel@tonic-gate vp = swap_vnodes[vidx];
2190Sstevel@tonic-gate if (vp) {
2200Sstevel@tonic-gate return (vp);
2210Sstevel@tonic-gate }
2220Sstevel@tonic-gate
2230Sstevel@tonic-gate mutex_enter(&swapfs_lock);
2240Sstevel@tonic-gate vp = swap_vnodes[vidx];
2250Sstevel@tonic-gate if (vp == NULL) {
2260Sstevel@tonic-gate vp = vn_alloc(KM_SLEEP);
2270Sstevel@tonic-gate vn_setops(vp, swap_vnodeops);
2280Sstevel@tonic-gate vp->v_type = VREG;
2290Sstevel@tonic-gate vp->v_flag |= (VISSWAP|VISSWAPFS);
2300Sstevel@tonic-gate swap_vnodes[vidx] = vp;
2310Sstevel@tonic-gate swapfs_vpcount++;
2320Sstevel@tonic-gate }
2330Sstevel@tonic-gate mutex_exit(&swapfs_lock);
2340Sstevel@tonic-gate return (vp);
2350Sstevel@tonic-gate }
2360Sstevel@tonic-gate
2370Sstevel@tonic-gate int swap_lo;
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate /*ARGSUSED*/
2400Sstevel@tonic-gate static int
swap_sync(struct vfs * vfsp,short flag,struct cred * cr)2410Sstevel@tonic-gate swap_sync(struct vfs *vfsp, short flag, struct cred *cr)
2420Sstevel@tonic-gate {
2430Sstevel@tonic-gate struct vnode *vp;
2440Sstevel@tonic-gate int i;
2450Sstevel@tonic-gate
2460Sstevel@tonic-gate if (!(flag & SYNC_ALL))
2470Sstevel@tonic-gate return (1);
2480Sstevel@tonic-gate
2490Sstevel@tonic-gate /*
2500Sstevel@tonic-gate * assumes that we are the only one left to access this so that
2510Sstevel@tonic-gate * no need to use swapfs_lock (since it's staticly defined)
2520Sstevel@tonic-gate */
2530Sstevel@tonic-gate for (i = 0; i < MAX_SWAP_VNODES; i++) {
2540Sstevel@tonic-gate vp = swap_vnodes[i];
2550Sstevel@tonic-gate if (vp) {
2560Sstevel@tonic-gate VN_HOLD(vp);
2570Sstevel@tonic-gate (void) VOP_PUTPAGE(vp, (offset_t)0, 0,
2585331Samw (B_ASYNC | B_FREE), kcred, NULL);
2590Sstevel@tonic-gate VN_RELE(vp);
2600Sstevel@tonic-gate }
2610Sstevel@tonic-gate }
2620Sstevel@tonic-gate return (0);
2630Sstevel@tonic-gate }
2640Sstevel@tonic-gate
2650Sstevel@tonic-gate extern int sw_pending_size;
2660Sstevel@tonic-gate
2670Sstevel@tonic-gate /*
2680Sstevel@tonic-gate * Take an async request off the pending queue
2690Sstevel@tonic-gate */
2700Sstevel@tonic-gate struct async_reqs *
sw_getreq()2710Sstevel@tonic-gate sw_getreq()
2720Sstevel@tonic-gate {
2730Sstevel@tonic-gate struct async_reqs *arg;
2740Sstevel@tonic-gate
2750Sstevel@tonic-gate mutex_enter(&swapfs_lock);
2760Sstevel@tonic-gate arg = sw_pendlist;
2770Sstevel@tonic-gate if (arg) {
2780Sstevel@tonic-gate sw_pendlist = arg->a_next;
2790Sstevel@tonic-gate arg->a_next = NULL;
2800Sstevel@tonic-gate sw_pending_size -= PAGESIZE;
2810Sstevel@tonic-gate }
2820Sstevel@tonic-gate ASSERT(sw_pending_size >= 0);
2830Sstevel@tonic-gate mutex_exit(&swapfs_lock);
2840Sstevel@tonic-gate return (arg);
2850Sstevel@tonic-gate }
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate /*
2880Sstevel@tonic-gate * Put an async request on the pending queue
2890Sstevel@tonic-gate */
2900Sstevel@tonic-gate void
sw_putreq(struct async_reqs * arg)2910Sstevel@tonic-gate sw_putreq(struct async_reqs *arg)
2920Sstevel@tonic-gate {
2930Sstevel@tonic-gate /* Hold onto it */
2940Sstevel@tonic-gate VN_HOLD(arg->a_vp);
2950Sstevel@tonic-gate
2960Sstevel@tonic-gate mutex_enter(&swapfs_lock);
2970Sstevel@tonic-gate arg->a_next = sw_pendlist;
2980Sstevel@tonic-gate sw_pendlist = arg;
2990Sstevel@tonic-gate sw_pending_size += PAGESIZE;
3000Sstevel@tonic-gate mutex_exit(&swapfs_lock);
3010Sstevel@tonic-gate }
3020Sstevel@tonic-gate
3030Sstevel@tonic-gate /*
3040Sstevel@tonic-gate * Put an async request back on the pending queue
3050Sstevel@tonic-gate */
3060Sstevel@tonic-gate void
sw_putbackreq(struct async_reqs * arg)3070Sstevel@tonic-gate sw_putbackreq(struct async_reqs *arg)
3080Sstevel@tonic-gate {
3090Sstevel@tonic-gate mutex_enter(&swapfs_lock);
3100Sstevel@tonic-gate arg->a_next = sw_pendlist;
3110Sstevel@tonic-gate sw_pendlist = arg;
3120Sstevel@tonic-gate sw_pending_size += PAGESIZE;
3130Sstevel@tonic-gate mutex_exit(&swapfs_lock);
3140Sstevel@tonic-gate }
3150Sstevel@tonic-gate
3160Sstevel@tonic-gate /*
3170Sstevel@tonic-gate * Take an async request structure off the free list
3180Sstevel@tonic-gate */
3190Sstevel@tonic-gate struct async_reqs *
sw_getfree()3200Sstevel@tonic-gate sw_getfree()
3210Sstevel@tonic-gate {
3220Sstevel@tonic-gate struct async_reqs *arg;
3230Sstevel@tonic-gate
3240Sstevel@tonic-gate mutex_enter(&swapfs_lock);
3250Sstevel@tonic-gate arg = sw_freelist;
3260Sstevel@tonic-gate if (arg) {
3270Sstevel@tonic-gate sw_freelist = arg->a_next;
3280Sstevel@tonic-gate arg->a_next = NULL;
3290Sstevel@tonic-gate }
3300Sstevel@tonic-gate mutex_exit(&swapfs_lock);
3310Sstevel@tonic-gate return (arg);
3320Sstevel@tonic-gate }
3330Sstevel@tonic-gate
3340Sstevel@tonic-gate /*
3350Sstevel@tonic-gate * Put an async request structure on the free list
3360Sstevel@tonic-gate */
3370Sstevel@tonic-gate void
sw_putfree(struct async_reqs * arg)3380Sstevel@tonic-gate sw_putfree(struct async_reqs *arg)
3390Sstevel@tonic-gate {
3400Sstevel@tonic-gate /* Release our hold - should have locked the page by now */
3410Sstevel@tonic-gate VN_RELE(arg->a_vp);
3420Sstevel@tonic-gate
3430Sstevel@tonic-gate mutex_enter(&swapfs_lock);
3440Sstevel@tonic-gate arg->a_next = sw_freelist;
3450Sstevel@tonic-gate sw_freelist = arg;
3460Sstevel@tonic-gate mutex_exit(&swapfs_lock);
3470Sstevel@tonic-gate }
3480Sstevel@tonic-gate
3490Sstevel@tonic-gate static pgcnt_t swapfs_pending_delete;
3500Sstevel@tonic-gate
3510Sstevel@tonic-gate /*ARGSUSED*/
3520Sstevel@tonic-gate static void
swap_mem_config_post_add(void * arg,pgcnt_t delta_swaps)3530Sstevel@tonic-gate swap_mem_config_post_add(
3540Sstevel@tonic-gate void *arg,
3550Sstevel@tonic-gate pgcnt_t delta_swaps)
3560Sstevel@tonic-gate {
3570Sstevel@tonic-gate (void) swapfs_recalc(physmem - swapfs_pending_delete);
3580Sstevel@tonic-gate }
3590Sstevel@tonic-gate
3600Sstevel@tonic-gate /*ARGSUSED*/
3610Sstevel@tonic-gate static int
swap_mem_config_pre_del(void * arg,pgcnt_t delta_swaps)3620Sstevel@tonic-gate swap_mem_config_pre_del(
3630Sstevel@tonic-gate void *arg,
3640Sstevel@tonic-gate pgcnt_t delta_swaps)
3650Sstevel@tonic-gate {
3660Sstevel@tonic-gate pgcnt_t nv;
3670Sstevel@tonic-gate
3680Sstevel@tonic-gate nv = atomic_add_long_nv(&swapfs_pending_delete, (spgcnt_t)delta_swaps);
3690Sstevel@tonic-gate if (!swapfs_recalc(physmem - nv)) {
3700Sstevel@tonic-gate /*
3710Sstevel@tonic-gate * Tidy-up is done by the call to post_del which
3720Sstevel@tonic-gate * is always made.
3730Sstevel@tonic-gate */
374*10443SVijay.Balakrishna@Sun.COM cmn_err(CE_NOTE, "Memory operation refused to ensure system "
375*10443SVijay.Balakrishna@Sun.COM "doesn't deadlock due to excessive consumption by swapfs.");
3760Sstevel@tonic-gate return (EBUSY);
3770Sstevel@tonic-gate }
3780Sstevel@tonic-gate return (0);
3790Sstevel@tonic-gate }
3800Sstevel@tonic-gate
3810Sstevel@tonic-gate /*ARGSUSED*/
3820Sstevel@tonic-gate static void
swap_mem_config_post_del(void * arg,pgcnt_t delta_swaps,int cancelled)3830Sstevel@tonic-gate swap_mem_config_post_del(
3840Sstevel@tonic-gate void *arg,
3850Sstevel@tonic-gate pgcnt_t delta_swaps,
3860Sstevel@tonic-gate int cancelled)
3870Sstevel@tonic-gate {
3880Sstevel@tonic-gate pgcnt_t nv;
3890Sstevel@tonic-gate
3900Sstevel@tonic-gate nv = atomic_add_long_nv(&swapfs_pending_delete, -(spgcnt_t)delta_swaps);
3910Sstevel@tonic-gate (void) swapfs_recalc(physmem - nv);
3920Sstevel@tonic-gate }
3930Sstevel@tonic-gate
3940Sstevel@tonic-gate static kphysm_setup_vector_t swap_mem_config_vec = {
3950Sstevel@tonic-gate KPHYSM_SETUP_VECTOR_VERSION,
3960Sstevel@tonic-gate swap_mem_config_post_add,
3970Sstevel@tonic-gate swap_mem_config_pre_del,
3980Sstevel@tonic-gate swap_mem_config_post_del,
3990Sstevel@tonic-gate };
4000Sstevel@tonic-gate
4010Sstevel@tonic-gate static void
swap_init_mem_config(void)4020Sstevel@tonic-gate swap_init_mem_config(void)
4030Sstevel@tonic-gate {
4040Sstevel@tonic-gate int ret;
4050Sstevel@tonic-gate
4060Sstevel@tonic-gate ret = kphysm_setup_func_register(&swap_mem_config_vec, (void *)NULL);
4070Sstevel@tonic-gate ASSERT(ret == 0);
4080Sstevel@tonic-gate }
409