Print this page
XXXX give me a better summary
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/swap.h
+++ new/usr/src/uts/common/sys/swap.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 23 * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
28 28
29 29 /*
30 30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 31 * The Regents of the University of California
32 32 * All Rights Reserved
33 33 *
34 34 * University Acknowledgment- Portions of this document are derived from
35 35 * software developed by the University of California, Berkeley, and its
36 36 * contributors.
37 37 */
38 38
39 39 #ifndef _SYS_SWAP_H
40 40 #define _SYS_SWAP_H
41 41
42 42 #include <sys/isa_defs.h>
43 43 #include <sys/feature_tests.h>
44 44 #include <vm/anon.h>
45 45 #include <sys/fs/swapnode.h>
46 46
47 47 #ifdef __cplusplus
48 48 extern "C" {
49 49 #endif
50 50
51 51 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
52 52 #error "Cannot use swapctl in the large files compilation environment"
53 53 #endif
54 54
55 55 /* The following are for the swapctl system call */
56 56
57 57 #define SC_ADD 1 /* add a specified resource for swapping */
58 58 #define SC_LIST 2 /* list all the swapping resources */
59 59 #define SC_REMOVE 3 /* remove the specified swapping resource */
60 60 #define SC_GETNSWP 4 /* get number of swap resources configured */
61 61 #define SC_AINFO 5 /* get anonymous memory resource information */
62 62
63 63 typedef struct swapres {
64 64 char *sr_name; /* pathname of the resource specified */
65 65 off_t sr_start; /* starting offset of the swapping resource */
66 66 off_t sr_length; /* length of the swap area */
67 67 } swapres_t;
68 68
69 69 typedef struct swapent {
70 70 char *ste_path; /* get the name of the swap file */
71 71 off_t ste_start; /* starting block for swapping */
72 72 off_t ste_length; /* length of swap area */
73 73 long ste_pages; /* numbers of pages for swapping */
74 74 long ste_free; /* numbers of ste_pages free */
75 75 int ste_flags; /* see below */
76 76 } swapent_t;
77 77
78 78 typedef struct swaptable {
79 79 int swt_n; /* number of swapents following */
80 80 struct swapent swt_ent[1]; /* array of swt_n swapents */
81 81 } swaptbl_t;
82 82
83 83
84 84 #if defined(_SYSCALL32)
85 85
86 86 /* Kernel's view of user ILP32 swapres and swapent structures */
87 87
88 88 typedef struct swapres32 {
89 89 caddr32_t sr_name; /* pathname of the resource specified */
90 90 off32_t sr_start; /* starting offset of the swapping resource */
91 91 off32_t sr_length; /* length of the swap area */
92 92 } swapres32_t;
93 93
94 94 typedef struct swapent32 {
95 95 caddr32_t ste_path; /* get the name of the swap file */
96 96 off32_t ste_start; /* starting block for swapping */
97 97 off32_t ste_length; /* length of swap area */
98 98 int32_t ste_pages; /* numbers of pages for swapping */
99 99 int32_t ste_free; /* numbers of ste_pages free */
100 100 int32_t ste_flags; /* see below */
101 101 } swapent32_t;
102 102
103 103 typedef struct swaptable32 {
104 104 int32_t swt_n; /* number of swapents following */
105 105 struct swapent32 swt_ent[1]; /* array of swt_n swapents */
106 106 } swaptbl32_t;
107 107
108 108 #endif /* _SYSCALL32 */
109 109
110 110 #if defined(_KERNEL)
111 111 extern int swapctl(int, void *, int *);
112 112 #if defined(_LP64) && defined(_SYSCALL32)
113 113 extern int swapctl32(int, void *, int *);
114 114 #endif /* _LP64 && _SYSCALL32 */
115 115 #else /* !_KERNEL */
116 116 extern int swapctl(int, void *);
117 117 #endif /* _KERNEL */
118 118
119 119
120 120 /* ste_flags values */
121 121
122 122 #define ST_INDEL 0x01 /* Deletion of file is in progress. */
123 123 /* Prevents others from deleting or */
124 124 /* allocating from it */
125 125 #define ST_DOINGDEL 0x02 /* Set during deletion of file */
126 126 /* Clearing during deletion signals */
127 127 /* that you want to add the file back */
128 128 /* again, and will eventually cause */
129 129 /* it to be added back */
130 130
131 131 /*
132 132 * VM - virtual swap device.
133 133 */
134 134 struct swapinfo {
135 135 ulong_t si_soff; /* starting offset (bytes) of file */
136 136 ulong_t si_eoff; /* ending offset (bytes) of file */
137 137 struct vnode *si_vp; /* vnode (commonvp if device) */
138 138 struct swapinfo *si_next; /* next swap area */
139 139 int si_allocs; /* # of conseq. allocs from this area */
140 140 short si_flags; /* flags defined below */
141 141 pgcnt_t si_npgs; /* number of pages of swap space */
142 142 pgcnt_t si_nfpgs; /* number of free pages of swap space */
143 143 int si_pnamelen; /* swap file name length + 1 */
144 144 char *si_pname; /* swap file name */
145 145 ssize_t si_mapsize; /* # bytes allocated for bitmap */
146 146 uint_t *si_swapslots; /* bitmap of slots, unset == free */
147 147 pgcnt_t si_hint; /* first page to check if free */
148 148 ssize_t si_checkcnt; /* # of checks to find freeslot */
149 149 ssize_t si_alloccnt; /* used to find ave checks */
150 150 };
151 151
152 152 /*
153 153 * Stuff to convert an anon slot pointer to a page name.
154 154 * Because the address of the slot (ap) is a unique identifier, we
155 155 * use it to generate a unique (vp,off), as shown in the comment for
156 156 * swap_alloc().
157 157 *
158 158 * The off bits are shifted PAGESHIFT to directly form a page aligned
159 159 * offset; the vp index bits map 1-1 to a vnode.
160 160 *
161 161 */
162 162 #define MAX_SWAP_VNODES_LOG2 11 /* log2(MAX_SWAP_VNODES) */
163 163 #define MAX_SWAP_VNODES (1U << MAX_SWAP_VNODES_LOG2) /* max # swap vnodes */
164 164 #define AN_VPMASK (MAX_SWAP_VNODES - 1) /* vp index mask */
165 165 #define AN_VPSHIFT MAX_SWAP_VNODES_LOG2
166 166 /*
167 167 * Convert from an anon slot to associated vnode and offset.
168 168 */
169 169 #define swap_xlate(AP, VPP, OFFP) \
170 170 { \
171 171 *(VPP) = (AP)->an_vp; \
172 172 *(OFFP) = (AP)->an_off; \
173 173 }
174 174 #define swap_xlate_nopanic swap_xlate
175 175
176 176 /*
177 177 * Get a vnode name for an anon slot.
178 178 * The vnum, offset are derived from anon struct address which is
179 179 * 16 bytes aligned. anon structs may be kmem_cache_alloc'd concurrently by
180 180 * multiple threads and come from a small range of addresses (same slab), in
181 181 * which case high order AP bits do not vary much, so choose vnum from low
182 182 * order bits which vary the most. Different threads will thus get different
183 183 * vnums and vnodes, which avoids vph_mutex_contention on the subsequent
184 184 * page_hashin().
185 185 *
186 186 * +-----------...-------------------+-----------------------+----+
187 187 * | swap offset | vnum |0000|
188 188 * +-----------...-------------------+-----------------------+----+
189 189 * 63 15 14 4 3 0
190 190 */
191 191 #define swap_alloc(AP) \
192 192 { \
193 193 (AP)->an_vp = swapfs_getvp(((uintptr_t)(AP) >> AN_CACHE_ALIGN_LOG2) \
194 194 & AN_VPMASK); \
195 195 (AP)->an_off = (anoff_t)((((uintptr_t)(AP)) >> \
196 196 AN_VPSHIFT + AN_CACHE_ALIGN_LOG2) << PAGESHIFT); \
197 197 }
198 198
199 199 /*
200 200 * Free the page name for the specified anon slot.
|
↓ open down ↓ |
200 lines elided |
↑ open up ↑ |
201 201 * For now there's nothing to do.
202 202 */
203 203 #define swap_free(AP)
204 204
205 205 /* Flags for swap_phys_alloc */
206 206 #define SA_NOT 0x01 /* Must have slot from swap dev other than input one */
207 207
208 208 /* Special error codes for swap_newphysname() */
209 209 #define SE_NOSWAP -1 /* No physical swap slots available */
210 210 #define SE_NOANON -2 /* No anon slot for swap slot */
211 +#define SE_NODEV -3 /* No swap devices on this machine. */
211 212
212 213 #ifdef _KERNEL
213 214 extern struct anon *swap_anon(struct vnode *vp, u_offset_t off);
214 215 extern int swap_phys_alloc(struct vnode **vpp, u_offset_t *offp, size_t *lenp,
215 216 uint_t flags);
216 217 extern void swap_phys_free(struct vnode *vp, u_offset_t off, size_t len);
217 218 extern int swap_getphysname(struct vnode *vp, u_offset_t off,
218 219 struct vnode **pvpp, u_offset_t *poffp);
219 220 extern int swap_newphysname(struct vnode *vp, u_offset_t offset,
220 221 u_offset_t *offp, size_t *lenp, struct vnode **pvpp, u_offset_t *poffp);
221 222
222 223 extern struct swapinfo *swapinfo;
223 224 extern int swap_debug;
224 225 #endif /* _KERNEL */
225 226
226 227 #ifdef SWAP_DEBUG
227 228 #define SW_RENAME 0x01
228 229 #define SW_RESV 0x02
229 230 #define SW_ALLOC 0x04
230 231 #define SW_CTL 0x08
231 232 #define SWAP_PRINT(f, s, x1, x2, x3, x4, x5) \
232 233 if (swap_debug & f) \
233 234 printf(s, x1, x2, x3, x4, x5);
234 235 #else /* SWAP_DEBUG */
235 236 #define SWAP_PRINT(f, s, x1, x2, x3, x4, x5)
236 237 #endif /* SWAP_DEBUG */
237 238
238 239 #ifdef __cplusplus
239 240 }
240 241 #endif
241 242
242 243 #endif /* _SYS_SWAP_H */
|
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX