Print this page
patch sccs-keywords
patch SEGOP_SWAPOUT-delete
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/vm/seg.h
+++ new/usr/src/uts/common/vm/seg.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 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /* Copyright (c) 1984, 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
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
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 _VM_SEG_H
40 40 #define _VM_SEG_H
41 41
42 -#pragma ident "%Z%%M% %I% %E% SMI"
43 -
44 42 #include <sys/vnode.h>
45 43 #include <sys/avl.h>
46 44 #include <vm/seg_enum.h>
47 45 #include <vm/faultcode.h>
48 46 #include <vm/hat.h>
49 47
50 48 #ifdef __cplusplus
51 49 extern "C" {
52 50 #endif
53 51
54 52 /*
55 53 * VM - Segments.
56 54 */
57 55
58 56 struct anon_map;
59 57
60 58 /*
61 59 * kstat statistics for segment advise
62 60 */
63 61 typedef struct {
64 62 kstat_named_t MADV_FREE_hit;
65 63 kstat_named_t MADV_FREE_miss;
66 64 } segadvstat_t;
67 65
68 66 /*
69 67 * memory object ids
70 68 */
71 69 typedef struct memid { u_longlong_t val[2]; } memid_t;
72 70
73 71 /*
74 72 * An address space contains a set of segments, managed by drivers.
75 73 * Drivers support mapped devices, sharing, copy-on-write, etc.
76 74 *
77 75 * The seg structure contains a lock to prevent races, the base virtual
78 76 * address and size of the segment, a back pointer to the containing
79 77 * address space, pointers to maintain an AVL tree of segments in the
80 78 * same address space, and procedure and data hooks for the driver.
81 79 * The AVL tree of segments for the address space is sorted by
82 80 * ascending base addresses and overlapping segments are not allowed.
83 81 *
84 82 * After a segment is created, faults may occur on pages of the segment.
85 83 * When a fault occurs, the fault handling code must get the desired
86 84 * object and set up the hardware translation to the object. For some
87 85 * objects, the fault handling code also implements copy-on-write.
88 86 *
89 87 * When the hat wants to unload a translation, it can call the unload
90 88 * routine which is responsible for processing reference and modify bits.
91 89 *
92 90 * Each segment is protected by it's containing address space lock. To
93 91 * access any field in the segment structure, the "as" must be locked.
94 92 * If a segment field is to be modified, the address space lock must be
95 93 * write locked.
96 94 */
97 95
98 96 typedef struct pcache_link {
99 97 struct pcache_link *p_lnext;
100 98 struct pcache_link *p_lprev;
101 99 } pcache_link_t;
102 100
103 101 typedef struct seg {
104 102 caddr_t s_base; /* base virtual address */
105 103 size_t s_size; /* size in bytes */
106 104 uint_t s_szc; /* max page size code */
107 105 uint_t s_flags; /* flags for segment, see below */
108 106 struct as *s_as; /* containing address space */
109 107 avl_node_t s_tree; /* AVL tree links to segs in this as */
110 108 struct seg_ops *s_ops; /* ops vector: see below */
111 109 void *s_data; /* private data for instance */
112 110 kmutex_t s_pmtx; /* protects seg's pcache list */
113 111 pcache_link_t s_phead; /* head of seg's pcache list */
114 112 } seg_t;
115 113
116 114 #define S_PURGE (0x01) /* seg should be purged in as_gap() */
117 115
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
118 116 struct seg_ops {
119 117 int (*dup)(struct seg *, struct seg *);
120 118 int (*unmap)(struct seg *, caddr_t, size_t);
121 119 void (*free)(struct seg *);
122 120 faultcode_t (*fault)(struct hat *, struct seg *, caddr_t, size_t,
123 121 enum fault_type, enum seg_rw);
124 122 faultcode_t (*faulta)(struct seg *, caddr_t);
125 123 int (*setprot)(struct seg *, caddr_t, size_t, uint_t);
126 124 int (*checkprot)(struct seg *, caddr_t, size_t, uint_t);
127 125 int (*kluster)(struct seg *, caddr_t, ssize_t);
128 - size_t (*swapout)(struct seg *);
129 126 int (*sync)(struct seg *, caddr_t, size_t, int, uint_t);
130 127 size_t (*incore)(struct seg *, caddr_t, size_t, char *);
131 128 int (*lockop)(struct seg *, caddr_t, size_t, int, int, ulong_t *,
132 129 size_t);
133 130 int (*getprot)(struct seg *, caddr_t, size_t, uint_t *);
134 131 u_offset_t (*getoffset)(struct seg *, caddr_t);
135 132 int (*gettype)(struct seg *, caddr_t);
136 133 int (*getvp)(struct seg *, caddr_t, struct vnode **);
137 134 int (*advise)(struct seg *, caddr_t, size_t, uint_t);
138 135 void (*dump)(struct seg *);
139 136 int (*pagelock)(struct seg *, caddr_t, size_t, struct page ***,
140 137 enum lock_type, enum seg_rw);
141 138 int (*setpagesize)(struct seg *, caddr_t, size_t, uint_t);
142 139 int (*getmemid)(struct seg *, caddr_t, memid_t *);
143 140 struct lgrp_mem_policy_info *(*getpolicy)(struct seg *, caddr_t);
144 141 int (*capable)(struct seg *, segcapability_t);
145 142 };
146 143
147 144 #ifdef _KERNEL
148 145
149 146 /*
150 147 * Generic segment operations
151 148 */
152 149 extern void seg_init(void);
153 150 extern struct seg *seg_alloc(struct as *as, caddr_t base, size_t size);
154 151 extern int seg_attach(struct as *as, caddr_t base, size_t size,
155 152 struct seg *seg);
156 153 extern void seg_unmap(struct seg *seg);
157 154 extern void seg_free(struct seg *seg);
158 155
159 156 /*
160 157 * functions for pagelock cache support
161 158 */
162 159 typedef int (*seg_preclaim_cbfunc_t)(void *, caddr_t, size_t,
163 160 struct page **, enum seg_rw, int);
164 161
165 162 extern struct page **seg_plookup(struct seg *seg, struct anon_map *amp,
166 163 caddr_t addr, size_t len, enum seg_rw rw, uint_t flags);
167 164 extern void seg_pinactive(struct seg *seg, struct anon_map *amp,
168 165 caddr_t addr, size_t len, struct page **pp, enum seg_rw rw,
169 166 uint_t flags, seg_preclaim_cbfunc_t callback);
170 167
171 168 extern void seg_ppurge(struct seg *seg, struct anon_map *amp,
172 169 uint_t flags);
173 170 extern void seg_ppurge_wiredpp(struct page **pp);
174 171
175 172 extern int seg_pinsert_check(struct seg *seg, struct anon_map *amp,
176 173 caddr_t addr, size_t len, uint_t flags);
177 174 extern int seg_pinsert(struct seg *seg, struct anon_map *amp,
178 175 caddr_t addr, size_t len, size_t wlen, struct page **pp, enum seg_rw rw,
179 176 uint_t flags, seg_preclaim_cbfunc_t callback);
180 177
181 178 extern void seg_pasync_thread(void);
182 179 extern void seg_preap(void);
183 180 extern int seg_p_disable(void);
184 181 extern void seg_p_enable(void);
185 182
186 183 extern segadvstat_t segadvstat;
187 184
188 185 /*
189 186 * Flags for pagelock cache support.
190 187 * Flags argument is passed as uint_t to pcache routines. upper 16 bits of
191 188 * the flags argument are reserved for alignment page shift when SEGP_PSHIFT
192 189 * is set.
193 190 */
194 191 #define SEGP_FORCE_WIRED 0x1 /* skip check against seg_pwindow */
195 192 #define SEGP_AMP 0x2 /* anon map's pcache entry */
196 193 #define SEGP_PSHIFT 0x4 /* addr pgsz shift for hash function */
197 194
198 195 /*
199 196 * Return values for seg_pinsert and seg_pinsert_check functions.
200 197 */
201 198 #define SEGP_SUCCESS 0 /* seg_pinsert() succeeded */
202 199 #define SEGP_FAIL 1 /* seg_pinsert() failed */
203 200
204 201 /* Page status bits for segop_incore */
205 202 #define SEG_PAGE_INCORE 0x01 /* VA has a page backing it */
206 203 #define SEG_PAGE_LOCKED 0x02 /* VA has a page that is locked */
207 204 #define SEG_PAGE_HASCOW 0x04 /* VA has a page with a copy-on-write */
208 205 #define SEG_PAGE_SOFTLOCK 0x08 /* VA has a page with softlock held */
209 206 #define SEG_PAGE_VNODEBACKED 0x10 /* Segment is backed by a vnode */
210 207 #define SEG_PAGE_ANON 0x20 /* VA has an anonymous page */
211 208 #define SEG_PAGE_VNODE 0x40 /* VA has a vnode page backing it */
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
212 209
213 210 #define SEGOP_DUP(s, n) (*(s)->s_ops->dup)((s), (n))
214 211 #define SEGOP_UNMAP(s, a, l) (*(s)->s_ops->unmap)((s), (a), (l))
215 212 #define SEGOP_FREE(s) (*(s)->s_ops->free)((s))
216 213 #define SEGOP_FAULT(h, s, a, l, t, rw) \
217 214 (*(s)->s_ops->fault)((h), (s), (a), (l), (t), (rw))
218 215 #define SEGOP_FAULTA(s, a) (*(s)->s_ops->faulta)((s), (a))
219 216 #define SEGOP_SETPROT(s, a, l, p) (*(s)->s_ops->setprot)((s), (a), (l), (p))
220 217 #define SEGOP_CHECKPROT(s, a, l, p) (*(s)->s_ops->checkprot)((s), (a), (l), (p))
221 218 #define SEGOP_KLUSTER(s, a, d) (*(s)->s_ops->kluster)((s), (a), (d))
222 -#define SEGOP_SWAPOUT(s) (*(s)->s_ops->swapout)((s))
223 219 #define SEGOP_SYNC(s, a, l, atr, f) \
224 220 (*(s)->s_ops->sync)((s), (a), (l), (atr), (f))
225 221 #define SEGOP_INCORE(s, a, l, v) (*(s)->s_ops->incore)((s), (a), (l), (v))
226 222 #define SEGOP_LOCKOP(s, a, l, atr, op, b, p) \
227 223 (*(s)->s_ops->lockop)((s), (a), (l), (atr), (op), (b), (p))
228 224 #define SEGOP_GETPROT(s, a, l, p) (*(s)->s_ops->getprot)((s), (a), (l), (p))
229 225 #define SEGOP_GETOFFSET(s, a) (*(s)->s_ops->getoffset)((s), (a))
230 226 #define SEGOP_GETTYPE(s, a) (*(s)->s_ops->gettype)((s), (a))
231 227 #define SEGOP_GETVP(s, a, vpp) (*(s)->s_ops->getvp)((s), (a), (vpp))
232 228 #define SEGOP_ADVISE(s, a, l, b) (*(s)->s_ops->advise)((s), (a), (l), (b))
233 229 #define SEGOP_DUMP(s) (*(s)->s_ops->dump)((s))
234 230 #define SEGOP_PAGELOCK(s, a, l, p, t, rw) \
235 231 (*(s)->s_ops->pagelock)((s), (a), (l), (p), (t), (rw))
236 232 #define SEGOP_SETPAGESIZE(s, a, l, szc) \
237 233 (*(s)->s_ops->setpagesize)((s), (a), (l), (szc))
238 234 #define SEGOP_GETMEMID(s, a, mp) (*(s)->s_ops->getmemid)((s), (a), (mp))
239 235 #define SEGOP_GETPOLICY(s, a) (*(s)->s_ops->getpolicy)((s), (a))
240 236 #define SEGOP_CAPABLE(s, c) (*(s)->s_ops->capable)((s), (c))
241 237
242 238 #define seg_page(seg, addr) \
243 239 (((uintptr_t)((addr) - (seg)->s_base)) >> PAGESHIFT)
244 240
245 241 #define seg_pages(seg) \
246 242 (((uintptr_t)((seg)->s_size + PAGEOFFSET)) >> PAGESHIFT)
247 243
248 244 #define IE_NOMEM -1 /* internal to seg layer */
249 245 #define IE_RETRY -2 /* internal to seg layer */
250 246 #define IE_REATTACH -3 /* internal to seg layer */
251 247
252 248 /* Delay/retry factors for seg_p_mem_config_pre_del */
253 249 #define SEGP_PREDEL_DELAY_FACTOR 4
254 250 /*
255 251 * As a workaround to being unable to purge the pagelock
256 252 * cache during a DR delete memory operation, we use
257 253 * a stall threshold that is twice the maximum seen
258 254 * during testing. This workaround will be removed
259 255 * when a suitable fix is found.
260 256 */
261 257 #define SEGP_STALL_SECONDS 25
262 258 #define SEGP_STALL_THRESHOLD \
263 259 (SEGP_STALL_SECONDS * SEGP_PREDEL_DELAY_FACTOR)
264 260
265 261 #ifdef VMDEBUG
266 262
267 263 uint_t seg_page(struct seg *, caddr_t);
268 264 uint_t seg_pages(struct seg *);
269 265
270 266 #endif /* VMDEBUG */
271 267
272 268 boolean_t seg_can_change_zones(struct seg *);
273 269 size_t seg_swresv(struct seg *);
274 270
275 271 #endif /* _KERNEL */
276 272
277 273 #ifdef __cplusplus
278 274 }
279 275 #endif
280 276
281 277 #endif /* _VM_SEG_H */
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX