Print this page
OS-3088 need a lighterweight page invalidation mechanism for zone memcap
OS-881 To workaround OS-580 add support to only invalidate mappings from a single process
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/vm/hat.h
+++ new/usr/src/uts/common/vm/hat.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
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
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 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + * Copyright 2014 Joyent, Inc. All rights reserved.
24 25 */
25 26
26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 28 /* All Rights Reserved */
28 29
29 30 /*
30 31 * University Copyright- Copyright (c) 1982, 1986, 1988
31 32 * The Regents of the University of California
32 33 * All Rights Reserved
33 34 *
34 35 * University Acknowledgment- Portions of this document are derived from
35 36 * software developed by the University of California, Berkeley, and its
36 37 * contributors.
37 38 */
38 39
39 40 #ifndef _VM_HAT_H
40 41 #define _VM_HAT_H
41 42
42 43 #include <sys/types.h>
43 44 #include <sys/t_lock.h>
44 45 #include <vm/faultcode.h>
45 46 #include <sys/kstat.h>
46 47 #include <sys/siginfo.h>
47 48
48 49 #ifdef __cplusplus
49 50 extern "C" {
50 51 #endif
51 52
52 53 /*
53 54 * VM - Hardware Address Translation management.
54 55 *
55 56 * This file describes the machine independent interfaces to
56 57 * the hardware address translation management routines. Other
57 58 * machine specific interfaces and structures are defined
58 59 * in <vm/hat_xxx.h>. The hat layer manages the address
59 60 * translation hardware as a cache driven by calls from the
60 61 * higher levels of the VM system.
61 62 */
62 63
63 64 struct hat;
64 65 struct kpme;
65 66 struct memseg;
66 67
67 68 #include <vm/page.h>
68 69
69 70 /*
70 71 * a callback used with hat_unload_callback()
71 72 * start and end mark are set to a range of unloaded addresses
72 73 * and the function is invoked with a pointer to this data structure
73 74 */
74 75 typedef struct hat_callback {
75 76 caddr_t hcb_start_addr;
76 77 caddr_t hcb_end_addr;
77 78 void (*hcb_function)(struct hat_callback *);
78 79 void *hcb_data;
79 80 } hat_callback_t;
80 81
81 82 typedef void *hat_region_cookie_t;
82 83
83 84 #ifdef _KERNEL
84 85
85 86 /*
86 87 * One time hat initialization
87 88 */
88 89 void hat_init(void);
89 90
90 91 /*
91 92 * Notify hat of a system dump
92 93 */
93 94 void hat_dump(void);
94 95
95 96 /*
96 97 * Operations on an address space:
97 98 *
98 99 * struct hat *hat_alloc(as)
99 100 * allocated a hat structure for as.
100 101 *
101 102 * void hat_free_start(hat)
102 103 * informs hat layer process has finished executing but as has not
103 104 * been cleaned up yet.
104 105 *
105 106 * void hat_free_end(hat)
106 107 * informs hat layer as is being destroyed. hat layer cannot use as
107 108 * pointer after this call.
108 109 *
109 110 * void hat_swapin(hat)
110 111 * allocate any hat resources required for process being swapped in.
111 112 *
112 113 * void hat_swapout(hat)
113 114 * deallocate hat resources for process being swapped out.
114 115 *
115 116 * size_t hat_get_mapped_size(hat)
116 117 * returns number of bytes that have valid mappings in hat.
117 118 *
118 119 * void hat_stats_enable(hat)
119 120 * void hat_stats_disable(hat)
120 121 * enables/disables collection of stats for hat.
121 122 *
122 123 * int hat_dup(parenthat, childhat, addr, len, flags)
123 124 * Duplicate address translations of the parent to the child. Supports
124 125 * the entire address range or a range depending on flag,
125 126 * zero returned on success, non-zero on error
126 127 *
127 128 * void hat_thread_exit(thread)
128 129 * Notifies the HAT that a thread is exiting, called after it has been
129 130 * reassigned to the kernel AS.
130 131 */
131 132
132 133 struct hat *hat_alloc(struct as *);
133 134 void hat_free_start(struct hat *);
134 135 void hat_free_end(struct hat *);
135 136 int hat_dup(struct hat *, struct hat *, caddr_t, size_t, uint_t);
136 137 void hat_swapin(struct hat *);
137 138 void hat_swapout(struct hat *);
138 139 size_t hat_get_mapped_size(struct hat *);
139 140 int hat_stats_enable(struct hat *);
140 141 void hat_stats_disable(struct hat *);
141 142 void hat_thread_exit(kthread_t *);
142 143
143 144 /*
144 145 * Operations on a named address within a segment:
145 146 *
146 147 * void hat_memload(hat, addr, pp, attr, flags)
147 148 * load/lock the given page struct
148 149 *
149 150 * void hat_memload_array(hat, addr, len, ppa, attr, flags)
150 151 * load/lock the given array of page structs
151 152 *
152 153 * void hat_devload(hat, addr, len, pf, attr, flags)
153 154 * load/lock the given page frame number
154 155 *
155 156 * void hat_unlock(hat, addr, len)
156 157 * unlock a given range of addresses
157 158 *
158 159 * void hat_unload(hat, addr, len, flags)
159 160 * void hat_unload_callback(hat, addr, len, flags, callback)
160 161 * unload a given range of addresses (has optional callback)
161 162 *
162 163 * void hat_sync(hat, addr, len, flags)
163 164 * synchronize mapping with software data structures
164 165 *
165 166 * void hat_map(hat, addr, len, flags)
166 167 *
167 168 * void hat_setattr(hat, addr, len, attr)
168 169 * void hat_clrattr(hat, addr, len, attr)
169 170 * void hat_chgattr(hat, addr, len, attr)
170 171 * modify attributes for a range of addresses. skips any invalid mappings
171 172 *
172 173 * uint_t hat_getattr(hat, addr, *attr)
173 174 * returns attr for <hat,addr> in *attr. returns 0 if there was a
174 175 * mapping and *attr is valid, nonzero if there was no mapping and
175 176 * *attr is not valid.
176 177 *
177 178 * size_t hat_getpagesize(hat, addr)
178 179 * returns pagesize in bytes for <hat, addr>. returns -1 if there is
179 180 * no mapping. This is an advisory call.
180 181 *
181 182 * pfn_t hat_getpfnum(hat, addr)
182 183 * returns pfn for <hat, addr> or PFN_INVALID if mapping is invalid.
183 184 *
184 185 * int hat_probe(hat, addr)
185 186 * return 0 if no valid mapping is present. Faster version
186 187 * of hat_getattr in certain architectures.
187 188 *
188 189 * int hat_share(dhat, daddr, shat, saddr, len, szc)
189 190 *
190 191 * void hat_unshare(hat, addr, len, szc)
191 192 *
192 193 * void hat_chgprot(hat, addr, len, vprot)
193 194 * This is a deprecated call. New segment drivers should store
194 195 * all attributes and use hat_*attr calls.
195 196 * Change the protections in the virtual address range
196 197 * given to the specified virtual protection. If vprot is ~PROT_WRITE,
197 198 * then remove write permission, leaving the other permissions
198 199 * unchanged. If vprot is ~PROT_USER, remove user permissions.
199 200 *
200 201 * void hat_flush_range(hat, addr, size)
201 202 * Invalidate a virtual address translation for the local CPU.
202 203 */
203 204
204 205 void hat_memload(struct hat *, caddr_t, struct page *, uint_t, uint_t);
205 206 void hat_memload_array(struct hat *, caddr_t, size_t, struct page **,
206 207 uint_t, uint_t);
207 208 void hat_memload_region(struct hat *, caddr_t, struct page *, uint_t,
208 209 uint_t, hat_region_cookie_t);
209 210 void hat_memload_array_region(struct hat *, caddr_t, size_t, struct page **,
210 211 uint_t, uint_t, hat_region_cookie_t);
211 212
212 213 void hat_devload(struct hat *, caddr_t, size_t, pfn_t, uint_t, int);
213 214
214 215 void hat_unlock(struct hat *, caddr_t, size_t);
215 216 void hat_unlock_region(struct hat *, caddr_t, size_t, hat_region_cookie_t);
216 217
217 218 void hat_unload(struct hat *, caddr_t, size_t, uint_t);
218 219 void hat_unload_callback(struct hat *, caddr_t, size_t, uint_t,
219 220 hat_callback_t *);
220 221 void hat_flush_range(struct hat *, caddr_t, size_t);
221 222 void hat_sync(struct hat *, caddr_t, size_t, uint_t);
222 223 void hat_map(struct hat *, caddr_t, size_t, uint_t);
223 224 void hat_setattr(struct hat *, caddr_t, size_t, uint_t);
224 225 void hat_clrattr(struct hat *, caddr_t, size_t, uint_t);
225 226 void hat_chgattr(struct hat *, caddr_t, size_t, uint_t);
226 227 uint_t hat_getattr(struct hat *, caddr_t, uint_t *);
227 228 ssize_t hat_getpagesize(struct hat *, caddr_t);
228 229 pfn_t hat_getpfnum(struct hat *, caddr_t);
229 230 int hat_probe(struct hat *, caddr_t);
230 231 int hat_share(struct hat *, caddr_t, struct hat *, caddr_t, size_t, uint_t);
231 232 void hat_unshare(struct hat *, caddr_t, size_t, uint_t);
232 233 void hat_chgprot(struct hat *, caddr_t, size_t, uint_t);
233 234 void hat_reserve(struct as *, caddr_t, size_t);
234 235 pfn_t va_to_pfn(void *);
235 236 uint64_t va_to_pa(void *);
236 237
237 238 /*
238 239 * Kernel Physical Mapping (segkpm) hat interface routines.
239 240 */
240 241 caddr_t hat_kpm_mapin(struct page *, struct kpme *);
241 242 void hat_kpm_mapout(struct page *, struct kpme *, caddr_t);
242 243 caddr_t hat_kpm_mapin_pfn(pfn_t);
243 244 void hat_kpm_mapout_pfn(pfn_t);
244 245 caddr_t hat_kpm_page2va(struct page *, int);
245 246 struct page *hat_kpm_vaddr2page(caddr_t);
246 247 int hat_kpm_fault(struct hat *, caddr_t);
247 248 void hat_kpm_mseghash_clear(int);
248 249 void hat_kpm_mseghash_update(pgcnt_t, struct memseg *);
249 250 void hat_kpm_addmem_mseg_update(struct memseg *, pgcnt_t, offset_t);
250 251 void hat_kpm_addmem_mseg_insert(struct memseg *);
251 252 void hat_kpm_addmem_memsegs_update(struct memseg *);
252 253 caddr_t hat_kpm_mseg_reuse(struct memseg *);
253 254 void hat_kpm_delmem_mseg_update(struct memseg *, struct memseg **);
254 255 void hat_kpm_split_mseg_update(struct memseg *, struct memseg **,
255 256 struct memseg *, struct memseg *, struct memseg *);
256 257 void hat_kpm_walk(void (*)(void *, void *, size_t), void *);
257 258
258 259 /*
259 260 * Operations on all translations for a given page(s)
260 261 *
261 262 * void hat_page_setattr(pp, flag)
|
↓ open down ↓ |
228 lines elided |
↑ open up ↑ |
262 263 * void hat_page_clrattr(pp, flag)
263 264 * used to set/clr red/mod bits.
264 265 *
265 266 * uint hat_page_getattr(pp, flag)
266 267 * If flag is specified, returns 0 if attribute is disabled
267 268 * and non zero if enabled. If flag specifes multiple attributs
268 269 * then returns 0 if ALL atriibutes are disabled. This is an advisory
269 270 * call.
270 271 *
271 272 * int hat_pageunload(pp, forceflag)
272 - * unload all translations attached to pp.
273 + * Unload all translations attached to pp. On x86 the bulk of the work is
274 + * done by hat_page_inval.
273 275 *
276 + * void hat_page_inval(pp, pgsz, curhat)
277 + * Unload translations attached to pp. If curhat is provided, only the
278 + * translation for that process is unloaded, otherwise all are unloaded.
279 + *
274 280 * uint_t hat_pagesync(pp, flags)
275 281 * get hw stats from hardware into page struct and reset hw stats
276 282 * returns attributes of page
277 283 *
278 284 * ulong_t hat_page_getshare(pp)
279 285 * returns approx number of mappings to this pp. A return of 0 implies
280 286 * there are no mappings to the page.
281 287 *
282 288 * faultcode_t hat_softlock(hat, addr, lenp, ppp, flags);
283 289 * called to softlock pages for zero copy tcp
284 290 *
285 291 * void hat_page_demote(pp);
286 292 * unload all large mappings to pp and decrease p_szc of all
287 293 * constituent pages according to the remaining mappings.
288 294 */
289 295
290 296 void hat_page_setattr(struct page *, uint_t);
291 297 void hat_page_clrattr(struct page *, uint_t);
292 298 uint_t hat_page_getattr(struct page *, uint_t);
293 299 int hat_pageunload(struct page *, uint_t);
300 +void hat_page_inval(struct page *, uint_t, struct hat *);
294 301 uint_t hat_pagesync(struct page *, uint_t);
295 302 ulong_t hat_page_getshare(struct page *);
296 303 int hat_page_checkshare(struct page *, ulong_t);
297 304 faultcode_t hat_softlock(struct hat *, caddr_t, size_t *,
298 305 struct page **, uint_t);
299 306 void hat_page_demote(struct page *);
300 307
301 308 /*
302 309 * Rountine to expose supported HAT features to PIM.
303 310 */
304 311 enum hat_features {
305 312 HAT_SHARED_PT, /* Shared page tables */
306 313 HAT_DYNAMIC_ISM_UNMAP, /* hat_pageunload() handles ISM pages */
307 314 HAT_VMODSORT, /* support for VMODSORT flag of vnode */
308 315 HAT_SHARED_REGIONS /* shared regions support */
309 316 };
310 317
311 318 int hat_supported(enum hat_features, void *);
312 319
313 320 /*
314 321 * Services provided to the hat:
315 322 *
316 323 * void as_signal_proc(as, siginfo)
317 324 * deliver signal to all processes that have this as.
318 325 *
319 326 * int hat_setstat(as, addr, len, rmbits)
320 327 * informs hatstat layer that ref/mod bits need to be updated for
321 328 * address range. Returns 0 on success, 1 for failure.
322 329 */
323 330 void as_signal_proc(struct as *, k_siginfo_t *siginfo);
324 331 void hat_setstat(struct as *, caddr_t, size_t, uint_t);
325 332
326 333 /*
327 334 * Flags to pass to hat routines.
328 335 *
329 336 * Certain flags only apply to some interfaces:
330 337 *
331 338 * HAT_LOAD Default flags to load a translation to the page.
332 339 * HAT_LOAD_LOCK Lock down mapping resources; hat_map(), hat_memload(),
333 340 * and hat_devload().
334 341 * HAT_LOAD_ADV Advisory load - Load translation if and only if
335 342 * sufficient MMU resources exist (i.e., do not steal).
336 343 * HAT_LOAD_SHARE A flag to hat_memload() to indicate h/w page tables
337 344 * that map some user pages (not kas) is shared by more
338 345 * than one process (eg. ISM).
339 346 * HAT_LOAD_CONTIG Pages are contigous
340 347 * HAT_LOAD_NOCONSIST Do not add mapping to mapping list.
341 348 * HAT_LOAD_REMAP Reload a valid pte with a different page frame.
342 349 * HAT_RELOAD_SHARE Reload a shared page table entry. Some platforms
343 350 * may require different actions than on the first
344 351 * load of a shared mapping.
345 352 * HAT_NO_KALLOC Do not kmem_alloc while creating the mapping; at this
346 353 * point, it's setting up mapping to allocate internal
347 354 * hat layer data structures. This flag forces hat layer
348 355 * to tap its reserves in order to prevent infinite
349 356 * recursion.
350 357 * HAT_LOAD_TEXT A flag to hat_memload() to indicate loading text pages.
351 358 */
352 359
353 360 /*
354 361 * Flags for hat_memload/hat_devload
355 362 */
356 363 #define HAT_FLAGS_RESV 0xFF000000 /* resv for hat impl */
357 364 #define HAT_LOAD 0x00
358 365 #define HAT_LOAD_LOCK 0x01
359 366 #define HAT_LOAD_ADV 0x04
360 367 #define HAT_LOAD_CONTIG 0x10
361 368 #define HAT_LOAD_NOCONSIST 0x20
362 369 #define HAT_LOAD_SHARE 0x40
363 370 #define HAT_LOAD_REMAP 0x80
364 371 #define HAT_RELOAD_SHARE 0x100
365 372 #define HAT_NO_KALLOC 0x200
366 373 #define HAT_LOAD_TEXT 0x400
367 374
368 375 /*
369 376 * Flags for initializing disable_*large_pages.
370 377 *
371 378 * HAT_AUTO_TEXT Get MMU specific disable_auto_text_large_pages
372 379 * HAT_AUTO_DATA Get MMU specific disable_auto_data_large_pages
373 380 */
374 381 #define HAT_AUTO_TEXT 0x800
375 382 #define HAT_AUTO_DATA 0x1000
376 383
377 384 /*
378 385 * Attributes for hat_memload/hat_devload/hat_*attr
379 386 * are a superset of prot flags defined in mman.h.
380 387 */
381 388 #define HAT_PLAT_ATTR_MASK 0xF00000
382 389 #define HAT_PROT_MASK 0x0F
383 390
384 391 #define HAT_NOFAULT 0x10
385 392 #define HAT_NOSYNC 0x20
386 393
387 394 /*
388 395 * Advisory ordering attributes. Apply only to device mappings.
389 396 *
390 397 * HAT_STRICTORDER: the CPU must issue the references in order, as the
391 398 * programmer specified. This is the default.
392 399 * HAT_UNORDERED_OK: the CPU may reorder the references (this is all kinds
393 400 * of reordering; store or load with store or load).
394 401 * HAT_MERGING_OK: merging and batching: the CPU may merge individual stores
395 402 * to consecutive locations (for example, turn two consecutive byte
396 403 * stores into one halfword store), and it may batch individual loads
397 404 * (for example, turn two consecutive byte loads into one halfword load).
398 405 * This also implies re-ordering.
399 406 * HAT_LOADCACHING_OK: the CPU may cache the data it fetches and reuse it
400 407 * until another store occurs. The default is to fetch new data
401 408 * on every load. This also implies merging.
402 409 * HAT_STORECACHING_OK: the CPU may keep the data in the cache and push it to
403 410 * the device (perhaps with other data) at a later time. The default is
404 411 * to push the data right away. This also implies load caching.
405 412 */
406 413 #define HAT_STRICTORDER 0x0000
407 414 #define HAT_UNORDERED_OK 0x0100
408 415 #define HAT_MERGING_OK 0x0200
409 416 #define HAT_LOADCACHING_OK 0x0300
410 417 #define HAT_STORECACHING_OK 0x0400
411 418 #define HAT_ORDER_MASK 0x0700
412 419
413 420 /* endian attributes */
414 421 #define HAT_NEVERSWAP 0x0000
415 422 #define HAT_STRUCTURE_BE 0x1000
416 423 #define HAT_STRUCTURE_LE 0x2000
417 424 #define HAT_ENDIAN_MASK 0x3000
418 425
419 426 /* flags for hat_softlock */
420 427 #define HAT_COW 0x0001
421 428
422 429 /*
423 430 * Flags for hat_unload
424 431 */
425 432 #define HAT_UNLOAD 0x00
426 433 #define HAT_UNLOAD_NOSYNC 0x02
427 434 #define HAT_UNLOAD_UNLOCK 0x04
428 435 #define HAT_UNLOAD_OTHER 0x08
429 436 #define HAT_UNLOAD_UNMAP 0x10
430 437
431 438 /*
432 439 * Flags for hat_pagesync, hat_getstat, hat_sync
433 440 */
434 441 #define HAT_SYNC_DONTZERO 0x00
435 442 #define HAT_SYNC_ZERORM 0x01
436 443 /* Additional flags for hat_pagesync */
437 444 #define HAT_SYNC_STOPON_REF 0x02
438 445 #define HAT_SYNC_STOPON_MOD 0x04
439 446 #define HAT_SYNC_STOPON_RM (HAT_SYNC_STOPON_REF | HAT_SYNC_STOPON_MOD)
440 447 #define HAT_SYNC_STOPON_SHARED 0x08
441 448
442 449 /*
443 450 * Flags for hat_dup
444 451 *
445 452 * HAT_DUP_ALL dup entire address space
446 453 * HAT_DUP_COW dup plus hat_clrattr(..PROT_WRITE) on newas
447 454 */
448 455 #define HAT_DUP_ALL 1
449 456 #define HAT_DUP_COW 2
450 457 #define HAT_DUP_SRD 3
451 458
452 459
|
↓ open down ↓ |
149 lines elided |
↑ open up ↑ |
453 460 /*
454 461 * Flags for hat_map
455 462 */
456 463 #define HAT_MAP 0x00
457 464
458 465 /*
459 466 * Flag for hat_pageunload
460 467 */
461 468 #define HAT_ADV_PGUNLOAD 0x00
462 469 #define HAT_FORCE_PGUNLOAD 0x01
470 +#define HAT_CURPROC_PGUNLOAD 0x02
463 471
464 472 /*
465 473 * Attributes for hat_page_*attr, hat_setstats and
466 474 * returned by hat_pagesync.
467 475 */
468 476 #define P_MOD 0x1 /* the modified bit */
469 477 #define P_REF 0x2 /* the referenced bit */
470 478 #define P_RO 0x4 /* Read only page */
471 479 #define P_NSH 0x8 /* Not to shuffle v_pages */
472 480
473 481 #define hat_ismod(pp) (hat_page_getattr(pp, P_MOD))
474 482 #define hat_isref(pp) (hat_page_getattr(pp, P_REF))
475 483 #define hat_isro(pp) (hat_page_getattr(pp, P_RO))
476 484
477 485 #define hat_setmod(pp) (hat_page_setattr(pp, P_MOD))
478 486 #define hat_setmod_only(pp) (hat_page_setattr(pp, P_MOD|P_NSH))
479 487 #define hat_setref(pp) (hat_page_setattr(pp, P_REF))
480 488 #define hat_setrefmod(pp) (hat_page_setattr(pp, P_REF|P_MOD))
481 489
482 490 #define hat_clrmod(pp) (hat_page_clrattr(pp, P_MOD))
483 491 #define hat_clrref(pp) (hat_page_clrattr(pp, P_REF))
484 492 #define hat_clrrefmod(pp) (hat_page_clrattr(pp, P_REF|P_MOD))
485 493
486 494 #define hat_page_is_mapped(pp) (hat_page_getshare(pp))
487 495
488 496 /*
489 497 * hat_setup is being used in sparc/os/sundep.c
490 498 */
491 499 void hat_setup(struct hat *, int);
492 500
493 501 /*
494 502 * Flags for hat_setup
495 503 */
496 504 #define HAT_DONTALLOC 0
497 505 #define HAT_ALLOC 1
498 506 #define HAT_INIT 2
499 507
500 508 /*
501 509 * Other routines, for statistics
502 510 */
503 511 int hat_startstat(struct as *);
504 512 void hat_getstat(struct as *, caddr_t, size_t, uint_t, char *, int);
505 513 void hat_freestat(struct as *, int);
506 514 void hat_resvstat(size_t, struct as *, caddr_t);
507 515
508 516 /*
509 517 * Relocation callback routines. Currently only sfmmu HAT supports
510 518 * these.
511 519 */
512 520 extern int hat_add_callback(id_t, caddr_t, uint_t, uint_t, void *,
513 521 pfn_t *, void **);
514 522 extern id_t hat_register_callback(int,
515 523 int (*prehandler)(caddr_t, uint_t, uint_t, void *),
516 524 int (*posthandler)(caddr_t, uint_t, uint_t, void *, pfn_t),
517 525 int (*errhandler)(caddr_t, uint_t, uint_t, void *), int);
518 526 extern void hat_delete_callback(caddr_t, uint_t, void *, uint_t, void *);
519 527
520 528 /*
521 529 * hat_add_callback()/hat_delete_callback() flags.
522 530 */
523 531 #define HAC_NOSLEEP 0x0
524 532 #define HAC_SLEEP 0x1
525 533 #define HAC_PAGELOCK 0x2
526 534
527 535 /*
528 536 * Suspend/unsuspend handler callback arguments.
529 537 */
530 538 #define HAT_SUSPEND 0x0010
531 539 #define HAT_UNSUSPEND 0x0010
532 540 #define HAT_PRESUSPEND 0x0020
533 541 #define HAT_POSTUNSUSPEND 0x0020
534 542
535 543 /*
536 544 * Error handler callback arguments. See the block comments
537 545 * before the implementation of hat_add_callback() for an
538 546 * explanation of what these mean.
539 547 */
540 548 #define HAT_CB_ERR_LEAKED 0x1
541 549
542 550 #endif /* _KERNEL */
543 551
544 552 /*
545 553 * The size of the bit array for ref and mod bit storage must be a power of 2.
546 554 * 2 bits are collected for each page. Below the power used is 4,
547 555 * which is 16 8-bit characters = 128 bits, ref and mod bit information
548 556 * for 64 pages.
549 557 */
550 558 #define HRM_SHIFT 4
551 559 #define HRM_BYTES (1 << HRM_SHIFT)
552 560 #define HRM_PAGES ((HRM_BYTES * NBBY) / 2)
553 561 #define HRM_PGPERBYTE (NBBY/2)
554 562 #define HRM_PGBYTEMASK (HRM_PGPERBYTE-1)
555 563
556 564 #define HRM_PGOFFMASK ((HRM_PGPERBYTE-1) << MMU_PAGESHIFT)
557 565 #define HRM_BASEOFFSET (((MMU_PAGESIZE * HRM_PAGES) - 1))
558 566 #define HRM_BASEMASK (~(HRM_BASEOFFSET))
559 567
560 568 #define HRM_BASESHIFT (MMU_PAGESHIFT + (HRM_SHIFT + 2))
561 569 #define HRM_PAGEMASK (MMU_PAGEMASK ^ HRM_BASEMASK)
562 570
563 571 #define HRM_HASHSIZE 0x200
564 572 #define HRM_HASHMASK (HRM_HASHSIZE - 1)
565 573
566 574 #define HRM_BLIST_INCR 0x200
567 575
568 576 /*
569 577 * The structure for maintaining referenced and modified information
570 578 */
571 579 struct hrmstat {
572 580 struct as *hrm_as; /* stat block belongs to this as */
573 581 uintptr_t hrm_base; /* base of block */
574 582 ushort_t hrm_id; /* opaque identifier, one of a_vbits */
575 583 struct hrmstat *hrm_anext; /* as statistics block list */
576 584 struct hrmstat *hrm_hnext; /* list for hashed blocks */
577 585 uchar_t hrm_bits[HRM_BYTES]; /* the ref and mod bits */
578 586 };
579 587
580 588 extern struct hrmstat **hrm_hashtab;
581 589
582 590 /*
583 591 * For global monitoring of the reference and modified bits
584 592 * of all address spaces we reserve one id bit.
585 593 */
586 594 #define HRM_SWSMONID 1
587 595
588 596
589 597 #ifdef _KERNEL
590 598
591 599 /*
592 600 * Hat locking functions
593 601 * XXX - these two functions are currently being used by hatstats
594 602 * they can be removed by using a per-as mutex for hatstats.
595 603 */
596 604 void hat_enter(struct hat *);
597 605 void hat_exit(struct hat *);
598 606
599 607 typedef void (*hat_rgn_cb_func_t)(caddr_t, caddr_t, caddr_t,
600 608 size_t, void *, u_offset_t);
601 609
602 610 void hat_join_srd(struct hat *, vnode_t *);
603 611
604 612 hat_region_cookie_t hat_join_region(struct hat *, caddr_t, size_t, void *,
605 613 u_offset_t, uchar_t, uchar_t, hat_rgn_cb_func_t,
606 614 uint_t);
607 615 void hat_leave_region(struct hat *, hat_region_cookie_t,
608 616 uint_t);
609 617 void hat_dup_region(struct hat *, hat_region_cookie_t);
610 618
611 619 #define HAT_INVALID_REGION_COOKIE ((hat_region_cookie_t)-1)
612 620 #define HAT_IS_REGION_COOKIE_VALID(c) ((c) != HAT_INVALID_REGION_COOKIE)
613 621
614 622 /* hat_join_region() flags */
615 623
616 624 #define HAT_REGION_TEXT 0x1 /* passed by segvn */
617 625 #define HAT_REGION_ISM 0x2 /* for hat_share()/hat_unshare() */
618 626
619 627 #define HAT_REGION_TYPE_MASK (0x7)
620 628
621 629 #endif /* _KERNEL */
622 630
623 631 #ifdef __cplusplus
624 632 }
625 633 #endif
626 634
627 635 #endif /* _VM_HAT_H */
|
↓ open down ↓ |
155 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX