5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/systm.h>
29 #include <sys/errno.h>
30 #include <sys/kmem.h>
31 #include <sys/vnode.h>
32 #include <sys/vfs_opreg.h>
33 #include <sys/swap.h>
34 #include <sys/sysmacros.h>
35 #include <sys/buf.h>
36 #include <sys/callb.h>
37 #include <sys/debug.h>
38 #include <vm/seg.h>
39 #include <sys/fs/swapnode.h>
40 #include <fs/fs_subr.h>
41 #include <sys/cmn_err.h>
42 #include <sys/mem_config.h>
43 #include <sys/atomic.h>
44
45 extern const fs_operation_def_t swap_vnodeops_template[];
46
47 /*
48 * swapfs_minfree is the amount of physical memory (actually remaining
49 * availrmem) that we want to keep free for the rest of the system. This
50 * means that swapfs can only grow to availrmem - swapfs_minfree. This
51 * can be set as just constant value or a certain percentage of installed
52 * physical memory. It is set in swapinit().
53 *
54 * Users who want to change the amount of memory that can be used as swap
55 * space should do so by setting swapfs_desfree at boot time,
56 * not swapfs_minfree.
57 */
58
59 pgcnt_t swapfs_desfree = 0;
60 pgcnt_t swapfs_minfree = 0;
61 pgcnt_t swapfs_reserve = 0;
62
63 #ifdef SWAPFS_DEBUG
64 int swapfs_debug;
65 #endif /* SWAPFS_DEBUG */
66
67
68 static int swapfs_vpcount;
69 static kmutex_t swapfs_lock;
70 static struct async_reqs *sw_ar, *sw_pendlist, *sw_freelist;
71
72 static struct vnode **swap_vnodes; /* ptr's to swap vnodes */
73
74 static void swap_init_mem_config(void);
75
76 static pgcnt_t initial_swapfs_desfree;
77 static pgcnt_t initial_swapfs_minfree;
78 static pgcnt_t initial_swapfs_reserve;
79
80 static int swap_sync(struct vfs *vfsp, short flag, struct cred *cr);
81
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/errno.h>
33 #include <sys/kmem.h>
34 #include <sys/vnode.h>
35 #include <sys/vfs_opreg.h>
36 #include <sys/swap.h>
37 #include <sys/sysmacros.h>
38 #include <sys/buf.h>
39 #include <sys/callb.h>
40 #include <sys/debug.h>
41 #include <vm/seg.h>
42 #include <sys/fs/swapnode.h>
43 #include <fs/fs_subr.h>
44 #include <sys/cmn_err.h>
45 #include <sys/mem_config.h>
46 #include <sys/atomic.h>
47
48 extern const fs_operation_def_t swap_vnodeops_template[];
49
50 /*
51 * swapfs_minfree is the amount of physical memory (actually remaining
52 * availrmem) that we want to keep free for the rest of the system. This
53 * means that swapfs can only grow to availrmem - swapfs_minfree. This
54 * can be set as just constant value or a certain percentage of installed
55 * physical memory. It is set in swapinit().
56 *
57 * Users who want to change the amount of memory that can be used as swap
58 * space should do so by setting swapfs_desfree at boot time,
59 * not swapfs_minfree.
60 */
61
62 pgcnt_t swapfs_desfree = 0;
63 volatile pgcnt_t swapfs_minfree = 0;
64 volatile pgcnt_t swapfs_reserve = 0;
65
66 #ifdef SWAPFS_DEBUG
67 int swapfs_debug;
68 #endif /* SWAPFS_DEBUG */
69
70
71 static int swapfs_vpcount;
72 static kmutex_t swapfs_lock;
73 static struct async_reqs *sw_ar, *sw_pendlist, *sw_freelist;
74
75 static struct vnode **swap_vnodes; /* ptr's to swap vnodes */
76
77 static void swap_init_mem_config(void);
78
79 static pgcnt_t initial_swapfs_desfree;
80 static pgcnt_t initial_swapfs_minfree;
81 static pgcnt_t initial_swapfs_reserve;
82
83 static int swap_sync(struct vfs *vfsp, short flag, struct cred *cr);
84
|