Print this page
6154 const-ify segment ops structures
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/vm/seg_map.c
+++ new/usr/src/uts/common/vm/seg_map.c
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 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
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 * Portions of this source code were derived from Berkeley 4.3 BSD
31 31 * under license from the Regents of the University of California.
32 32 */
33 33
34 34 /*
35 35 * VM - generic vnode mapping segment.
36 36 *
37 37 * The segmap driver is used only by the kernel to get faster (than seg_vn)
38 38 * mappings [lower routine overhead; more persistent cache] to random
39 39 * vnode/offsets. Note than the kernel may (and does) use seg_vn as well.
40 40 */
41 41
42 42 #include <sys/types.h>
43 43 #include <sys/t_lock.h>
44 44 #include <sys/param.h>
45 45 #include <sys/sysmacros.h>
46 46 #include <sys/buf.h>
47 47 #include <sys/systm.h>
48 48 #include <sys/vnode.h>
49 49 #include <sys/mman.h>
50 50 #include <sys/errno.h>
51 51 #include <sys/cred.h>
52 52 #include <sys/kmem.h>
53 53 #include <sys/vtrace.h>
54 54 #include <sys/cmn_err.h>
55 55 #include <sys/debug.h>
56 56 #include <sys/thread.h>
57 57 #include <sys/dumphdr.h>
58 58 #include <sys/bitmap.h>
59 59 #include <sys/lgrp.h>
60 60
61 61 #include <vm/seg_kmem.h>
62 62 #include <vm/hat.h>
63 63 #include <vm/as.h>
64 64 #include <vm/seg.h>
65 65 #include <vm/seg_kpm.h>
66 66 #include <vm/seg_map.h>
67 67 #include <vm/page.h>
68 68 #include <vm/pvn.h>
69 69 #include <vm/rm.h>
70 70
71 71 /*
72 72 * Private seg op routines.
73 73 */
74 74 static void segmap_free(struct seg *seg);
75 75 faultcode_t segmap_fault(struct hat *hat, struct seg *seg, caddr_t addr,
76 76 size_t len, enum fault_type type, enum seg_rw rw);
77 77 static faultcode_t segmap_faulta(struct seg *seg, caddr_t addr);
78 78 static int segmap_checkprot(struct seg *seg, caddr_t addr, size_t len,
79 79 uint_t prot);
80 80 static int segmap_kluster(struct seg *seg, caddr_t addr, ssize_t);
81 81 static int segmap_getprot(struct seg *seg, caddr_t addr, size_t len,
82 82 uint_t *protv);
83 83 static u_offset_t segmap_getoffset(struct seg *seg, caddr_t addr);
84 84 static int segmap_gettype(struct seg *seg, caddr_t addr);
85 85 static int segmap_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
86 86 static void segmap_dump(struct seg *seg);
87 87 static int segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
88 88 struct page ***ppp, enum lock_type type,
89 89 enum seg_rw rw);
↓ open down ↓ |
89 lines elided |
↑ open up ↑ |
90 90 static void segmap_badop(void);
91 91 static int segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
92 92
93 93 /* segkpm support */
94 94 static caddr_t segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
95 95 struct smap *, enum seg_rw);
96 96 struct smap *get_smap_kpm(caddr_t, page_t **);
97 97
98 98 #define SEGMAP_BADOP(t) (t(*)())segmap_badop
99 99
100 -static struct seg_ops segmap_ops = {
100 +static const struct seg_ops segmap_ops = {
101 101 .dup = SEGMAP_BADOP(int),
102 102 .unmap = SEGMAP_BADOP(int),
103 103 .free = segmap_free,
104 104 .fault = segmap_fault,
105 105 .faulta = segmap_faulta,
106 106 .setprot = SEGMAP_BADOP(int),
107 107 .checkprot = segmap_checkprot,
108 108 .kluster = segmap_kluster,
109 109 .swapout = SEGMAP_BADOP(size_t),
110 110 .sync = SEGMAP_BADOP(int),
111 111 .incore = SEGMAP_BADOP(size_t),
112 112 .lockop = SEGMAP_BADOP(int),
113 113 .getprot = segmap_getprot,
114 114 .getoffset = segmap_getoffset,
115 115 .gettype = segmap_gettype,
116 116 .getvp = segmap_getvp,
117 117 .advise = SEGMAP_BADOP(int),
118 118 .dump = segmap_dump,
119 119 .pagelock = segmap_pagelock,
120 120 .setpagesize = SEGMAP_BADOP(int),
121 121 .getmemid = segmap_getmemid,
122 122 };
123 123
124 124 /*
125 125 * Private segmap routines.
126 126 */
127 127 static void segmap_unlock(struct hat *hat, struct seg *seg, caddr_t addr,
128 128 size_t len, enum seg_rw rw, struct smap *smp);
129 129 static void segmap_smapadd(struct smap *smp);
130 130 static struct smap *segmap_hashin(struct smap *smp, struct vnode *vp,
131 131 u_offset_t off, int hashid);
132 132 static void segmap_hashout(struct smap *smp);
133 133
134 134
135 135 /*
136 136 * Statistics for segmap operations.
137 137 *
138 138 * No explicit locking to protect these stats.
139 139 */
140 140 struct segmapcnt segmapcnt = {
141 141 { "fault", KSTAT_DATA_ULONG },
142 142 { "faulta", KSTAT_DATA_ULONG },
143 143 { "getmap", KSTAT_DATA_ULONG },
144 144 { "get_use", KSTAT_DATA_ULONG },
145 145 { "get_reclaim", KSTAT_DATA_ULONG },
146 146 { "get_reuse", KSTAT_DATA_ULONG },
147 147 { "get_unused", KSTAT_DATA_ULONG },
148 148 { "get_nofree", KSTAT_DATA_ULONG },
149 149 { "rel_async", KSTAT_DATA_ULONG },
150 150 { "rel_write", KSTAT_DATA_ULONG },
151 151 { "rel_free", KSTAT_DATA_ULONG },
152 152 { "rel_abort", KSTAT_DATA_ULONG },
153 153 { "rel_dontneed", KSTAT_DATA_ULONG },
154 154 { "release", KSTAT_DATA_ULONG },
155 155 { "pagecreate", KSTAT_DATA_ULONG },
156 156 { "free_notfree", KSTAT_DATA_ULONG },
157 157 { "free_dirty", KSTAT_DATA_ULONG },
158 158 { "free", KSTAT_DATA_ULONG },
159 159 { "stolen", KSTAT_DATA_ULONG },
160 160 { "get_nomtx", KSTAT_DATA_ULONG }
161 161 };
162 162
163 163 kstat_named_t *segmapcnt_ptr = (kstat_named_t *)&segmapcnt;
164 164 uint_t segmapcnt_ndata = sizeof (segmapcnt) / sizeof (kstat_named_t);
165 165
166 166 /*
167 167 * Return number of map pages in segment.
168 168 */
169 169 #define MAP_PAGES(seg) ((seg)->s_size >> MAXBSHIFT)
170 170
171 171 /*
172 172 * Translate addr into smap number within segment.
173 173 */
174 174 #define MAP_PAGE(seg, addr) (((addr) - (seg)->s_base) >> MAXBSHIFT)
175 175
176 176 /*
177 177 * Translate addr in seg into struct smap pointer.
178 178 */
179 179 #define GET_SMAP(seg, addr) \
180 180 &(((struct segmap_data *)((seg)->s_data))->smd_sm[MAP_PAGE(seg, addr)])
181 181
182 182 /*
183 183 * Bit in map (16 bit bitmap).
184 184 */
185 185 #define SMAP_BIT_MASK(bitindex) (1 << ((bitindex) & 0xf))
186 186
187 187 static int smd_colormsk = 0;
188 188 static int smd_ncolor = 0;
189 189 static int smd_nfree = 0;
190 190 static int smd_freemsk = 0;
191 191 #ifdef DEBUG
192 192 static int *colors_used;
193 193 #endif
194 194 static struct smap *smd_smap;
195 195 static struct smaphash *smd_hash;
196 196 #ifdef SEGMAP_HASHSTATS
197 197 static unsigned int *smd_hash_len;
198 198 #endif
199 199 static struct smfree *smd_free;
200 200 static ulong_t smd_hashmsk = 0;
201 201
202 202 #define SEGMAP_MAXCOLOR 2
203 203 #define SEGMAP_CACHE_PAD 64
204 204
205 205 union segmap_cpu {
206 206 struct {
207 207 uint32_t scpu_free_ndx[SEGMAP_MAXCOLOR];
208 208 struct smap *scpu_last_smap;
209 209 ulong_t scpu_getmap;
210 210 ulong_t scpu_release;
211 211 ulong_t scpu_get_reclaim;
212 212 ulong_t scpu_fault;
213 213 ulong_t scpu_pagecreate;
214 214 ulong_t scpu_get_reuse;
215 215 } scpu;
216 216 char scpu_pad[SEGMAP_CACHE_PAD];
217 217 };
218 218 static union segmap_cpu *smd_cpu;
219 219
220 220 /*
221 221 * There are three locks in seg_map:
222 222 * - per freelist mutexes
223 223 * - per hashchain mutexes
224 224 * - per smap mutexes
225 225 *
226 226 * The lock ordering is to get the smap mutex to lock down the slot
227 227 * first then the hash lock (for hash in/out (vp, off) list) or the
228 228 * freelist lock to put the slot back on the free list.
229 229 *
230 230 * The hash search is done by only holding the hashchain lock, when a wanted
231 231 * slot is found, we drop the hashchain lock then lock the slot so there
232 232 * is no overlapping of hashchain and smap locks. After the slot is
233 233 * locked, we verify again if the slot is still what we are looking
234 234 * for.
235 235 *
236 236 * Allocation of a free slot is done by holding the freelist lock,
237 237 * then locking the smap slot at the head of the freelist. This is
238 238 * in reversed lock order so mutex_tryenter() is used.
239 239 *
240 240 * The smap lock protects all fields in smap structure except for
241 241 * the link fields for hash/free lists which are protected by
242 242 * hashchain and freelist locks.
243 243 */
244 244
245 245 #define SHASHMTX(hashid) (&smd_hash[hashid].sh_mtx)
246 246
247 247 #define SMP2SMF(smp) (&smd_free[(smp - smd_smap) & smd_freemsk])
248 248 #define SMP2SMF_NDX(smp) (ushort_t)((smp - smd_smap) & smd_freemsk)
249 249
250 250 #define SMAPMTX(smp) (&smp->sm_mtx)
251 251
252 252 #define SMAP_HASHFUNC(vp, off, hashid) \
253 253 { \
254 254 hashid = ((((uintptr_t)(vp) >> 6) + ((uintptr_t)(vp) >> 3) + \
255 255 ((off) >> MAXBSHIFT)) & smd_hashmsk); \
256 256 }
257 257
258 258 /*
259 259 * The most frequently updated kstat counters are kept in the
260 260 * per cpu array to avoid hot cache blocks. The update function
261 261 * sums the cpu local counters to update the global counters.
262 262 */
263 263
264 264 /* ARGSUSED */
265 265 int
266 266 segmap_kstat_update(kstat_t *ksp, int rw)
267 267 {
268 268 int i;
269 269 ulong_t getmap, release, get_reclaim;
270 270 ulong_t fault, pagecreate, get_reuse;
271 271
272 272 if (rw == KSTAT_WRITE)
273 273 return (EACCES);
274 274 getmap = release = get_reclaim = (ulong_t)0;
275 275 fault = pagecreate = get_reuse = (ulong_t)0;
276 276 for (i = 0; i < max_ncpus; i++) {
277 277 getmap += smd_cpu[i].scpu.scpu_getmap;
278 278 release += smd_cpu[i].scpu.scpu_release;
279 279 get_reclaim += smd_cpu[i].scpu.scpu_get_reclaim;
280 280 fault += smd_cpu[i].scpu.scpu_fault;
281 281 pagecreate += smd_cpu[i].scpu.scpu_pagecreate;
282 282 get_reuse += smd_cpu[i].scpu.scpu_get_reuse;
283 283 }
284 284 segmapcnt.smp_getmap.value.ul = getmap;
285 285 segmapcnt.smp_release.value.ul = release;
286 286 segmapcnt.smp_get_reclaim.value.ul = get_reclaim;
287 287 segmapcnt.smp_fault.value.ul = fault;
288 288 segmapcnt.smp_pagecreate.value.ul = pagecreate;
289 289 segmapcnt.smp_get_reuse.value.ul = get_reuse;
290 290 return (0);
291 291 }
292 292
293 293 int
294 294 segmap_create(struct seg *seg, void *argsp)
295 295 {
296 296 struct segmap_data *smd;
297 297 struct smap *smp;
298 298 struct smfree *sm;
299 299 struct segmap_crargs *a = (struct segmap_crargs *)argsp;
300 300 struct smaphash *shashp;
301 301 union segmap_cpu *scpu;
302 302 long i, npages;
303 303 size_t hashsz;
304 304 uint_t nfreelist;
305 305 extern void prefetch_smap_w(void *);
306 306 extern int max_ncpus;
307 307
308 308 ASSERT(seg->s_as && RW_WRITE_HELD(&seg->s_as->a_lock));
309 309
310 310 if (((uintptr_t)seg->s_base | seg->s_size) & MAXBOFFSET) {
311 311 panic("segkmap not MAXBSIZE aligned");
312 312 /*NOTREACHED*/
313 313 }
314 314
315 315 smd = kmem_zalloc(sizeof (struct segmap_data), KM_SLEEP);
316 316
317 317 seg->s_data = (void *)smd;
318 318 seg->s_ops = &segmap_ops;
319 319 smd->smd_prot = a->prot;
320 320
321 321 /*
322 322 * Scale the number of smap freelists to be
323 323 * proportional to max_ncpus * number of virtual colors.
324 324 * The caller can over-ride this scaling by providing
325 325 * a non-zero a->nfreelist argument.
326 326 */
327 327 nfreelist = a->nfreelist;
328 328 if (nfreelist == 0)
329 329 nfreelist = max_ncpus;
330 330 else if (nfreelist < 0 || nfreelist > 4 * max_ncpus) {
331 331 cmn_err(CE_WARN, "segmap_create: nfreelist out of range "
332 332 "%d, using %d", nfreelist, max_ncpus);
333 333 nfreelist = max_ncpus;
334 334 }
335 335 if (!ISP2(nfreelist)) {
336 336 /* round up nfreelist to the next power of two. */
337 337 nfreelist = 1 << (highbit(nfreelist));
338 338 }
339 339
340 340 /*
341 341 * Get the number of virtual colors - must be a power of 2.
342 342 */
343 343 if (a->shmsize)
344 344 smd_ncolor = a->shmsize >> MAXBSHIFT;
345 345 else
346 346 smd_ncolor = 1;
347 347 ASSERT((smd_ncolor & (smd_ncolor - 1)) == 0);
348 348 ASSERT(smd_ncolor <= SEGMAP_MAXCOLOR);
349 349 smd_colormsk = smd_ncolor - 1;
350 350 smd->smd_nfree = smd_nfree = smd_ncolor * nfreelist;
351 351 smd_freemsk = smd_nfree - 1;
352 352
353 353 /*
354 354 * Allocate and initialize the freelist headers.
355 355 * Note that sm_freeq[1] starts out as the release queue. This
356 356 * is known when the smap structures are initialized below.
357 357 */
358 358 smd_free = smd->smd_free =
359 359 kmem_zalloc(smd_nfree * sizeof (struct smfree), KM_SLEEP);
360 360 for (i = 0; i < smd_nfree; i++) {
361 361 sm = &smd->smd_free[i];
362 362 mutex_init(&sm->sm_freeq[0].smq_mtx, NULL, MUTEX_DEFAULT, NULL);
363 363 mutex_init(&sm->sm_freeq[1].smq_mtx, NULL, MUTEX_DEFAULT, NULL);
364 364 sm->sm_allocq = &sm->sm_freeq[0];
365 365 sm->sm_releq = &sm->sm_freeq[1];
366 366 }
367 367
368 368 /*
369 369 * Allocate and initialize the smap hash chain headers.
370 370 * Compute hash size rounding down to the next power of two.
371 371 */
372 372 npages = MAP_PAGES(seg);
373 373 smd->smd_npages = npages;
374 374 hashsz = npages / SMAP_HASHAVELEN;
375 375 hashsz = 1 << (highbit(hashsz)-1);
376 376 smd_hashmsk = hashsz - 1;
377 377 smd_hash = smd->smd_hash =
378 378 kmem_alloc(hashsz * sizeof (struct smaphash), KM_SLEEP);
379 379 #ifdef SEGMAP_HASHSTATS
380 380 smd_hash_len =
381 381 kmem_zalloc(hashsz * sizeof (unsigned int), KM_SLEEP);
382 382 #endif
383 383 for (i = 0, shashp = smd_hash; i < hashsz; i++, shashp++) {
384 384 shashp->sh_hash_list = NULL;
385 385 mutex_init(&shashp->sh_mtx, NULL, MUTEX_DEFAULT, NULL);
386 386 }
387 387
388 388 /*
389 389 * Allocate and initialize the smap structures.
390 390 * Link all slots onto the appropriate freelist.
391 391 * The smap array is large enough to affect boot time
392 392 * on large systems, so use memory prefetching and only
393 393 * go through the array 1 time. Inline a optimized version
394 394 * of segmap_smapadd to add structures to freelists with
395 395 * knowledge that no locks are needed here.
396 396 */
397 397 smd_smap = smd->smd_sm =
398 398 kmem_alloc(sizeof (struct smap) * npages, KM_SLEEP);
399 399
400 400 for (smp = &smd->smd_sm[MAP_PAGES(seg) - 1];
401 401 smp >= smd->smd_sm; smp--) {
402 402 struct smap *smpfreelist;
403 403 struct sm_freeq *releq;
404 404
405 405 prefetch_smap_w((char *)smp);
406 406
407 407 smp->sm_vp = NULL;
408 408 smp->sm_hash = NULL;
409 409 smp->sm_off = 0;
410 410 smp->sm_bitmap = 0;
411 411 smp->sm_refcnt = 0;
412 412 mutex_init(&smp->sm_mtx, NULL, MUTEX_DEFAULT, NULL);
413 413 smp->sm_free_ndx = SMP2SMF_NDX(smp);
414 414
415 415 sm = SMP2SMF(smp);
416 416 releq = sm->sm_releq;
417 417
418 418 smpfreelist = releq->smq_free;
419 419 if (smpfreelist == 0) {
420 420 releq->smq_free = smp->sm_next = smp->sm_prev = smp;
421 421 } else {
422 422 smp->sm_next = smpfreelist;
423 423 smp->sm_prev = smpfreelist->sm_prev;
424 424 smpfreelist->sm_prev = smp;
425 425 smp->sm_prev->sm_next = smp;
426 426 releq->smq_free = smp->sm_next;
427 427 }
428 428
429 429 /*
430 430 * sm_flag = 0 (no SM_QNDX_ZERO) implies smap on sm_freeq[1]
431 431 */
432 432 smp->sm_flags = 0;
433 433
434 434 #ifdef SEGKPM_SUPPORT
435 435 /*
436 436 * Due to the fragile prefetch loop no
437 437 * separate function is used here.
438 438 */
439 439 smp->sm_kpme_next = NULL;
440 440 smp->sm_kpme_prev = NULL;
441 441 smp->sm_kpme_page = NULL;
442 442 #endif
443 443 }
444 444
445 445 /*
446 446 * Allocate the per color indices that distribute allocation
447 447 * requests over the free lists. Each cpu will have a private
448 448 * rotor index to spread the allocations even across the available
449 449 * smap freelists. Init the scpu_last_smap field to the first
450 450 * smap element so there is no need to check for NULL.
451 451 */
452 452 smd_cpu =
453 453 kmem_zalloc(sizeof (union segmap_cpu) * max_ncpus, KM_SLEEP);
454 454 for (i = 0, scpu = smd_cpu; i < max_ncpus; i++, scpu++) {
455 455 int j;
456 456 for (j = 0; j < smd_ncolor; j++)
457 457 scpu->scpu.scpu_free_ndx[j] = j;
458 458 scpu->scpu.scpu_last_smap = smd_smap;
459 459 }
460 460
461 461 vpm_init();
462 462
463 463 #ifdef DEBUG
464 464 /*
465 465 * Keep track of which colors are used more often.
466 466 */
467 467 colors_used = kmem_zalloc(smd_nfree * sizeof (int), KM_SLEEP);
468 468 #endif /* DEBUG */
469 469
470 470 return (0);
471 471 }
472 472
473 473 static void
474 474 segmap_free(seg)
475 475 struct seg *seg;
476 476 {
477 477 ASSERT(seg->s_as && RW_WRITE_HELD(&seg->s_as->a_lock));
478 478 }
479 479
480 480 /*
481 481 * Do a F_SOFTUNLOCK call over the range requested.
482 482 * The range must have already been F_SOFTLOCK'ed.
483 483 */
484 484 static void
485 485 segmap_unlock(
486 486 struct hat *hat,
487 487 struct seg *seg,
488 488 caddr_t addr,
489 489 size_t len,
490 490 enum seg_rw rw,
491 491 struct smap *smp)
492 492 {
493 493 page_t *pp;
494 494 caddr_t adr;
495 495 u_offset_t off;
496 496 struct vnode *vp;
497 497 kmutex_t *smtx;
498 498
499 499 ASSERT(smp->sm_refcnt > 0);
500 500
501 501 #ifdef lint
502 502 seg = seg;
503 503 #endif
504 504
505 505 if (segmap_kpm && IS_KPM_ADDR(addr)) {
506 506
507 507 /*
508 508 * We're called only from segmap_fault and this was a
509 509 * NOP in case of a kpm based smap, so dangerous things
510 510 * must have happened in the meantime. Pages are prefaulted
511 511 * and locked in segmap_getmapflt and they will not be
512 512 * unlocked until segmap_release.
513 513 */
514 514 panic("segmap_unlock: called with kpm addr %p", (void *)addr);
515 515 /*NOTREACHED*/
516 516 }
517 517
518 518 vp = smp->sm_vp;
519 519 off = smp->sm_off + (u_offset_t)((uintptr_t)addr & MAXBOFFSET);
520 520
521 521 hat_unlock(hat, addr, P2ROUNDUP(len, PAGESIZE));
522 522 for (adr = addr; adr < addr + len; adr += PAGESIZE, off += PAGESIZE) {
523 523 ushort_t bitmask;
524 524
525 525 /*
526 526 * Use page_find() instead of page_lookup() to
527 527 * find the page since we know that it has
528 528 * "shared" lock.
529 529 */
530 530 pp = page_find(vp, off);
531 531 if (pp == NULL) {
532 532 panic("segmap_unlock: page not found");
533 533 /*NOTREACHED*/
534 534 }
535 535
536 536 if (rw == S_WRITE) {
537 537 hat_setrefmod(pp);
538 538 } else if (rw != S_OTHER) {
539 539 TRACE_3(TR_FAC_VM, TR_SEGMAP_FAULT,
540 540 "segmap_fault:pp %p vp %p offset %llx", pp, vp, off);
541 541 hat_setref(pp);
542 542 }
543 543
544 544 /*
545 545 * Clear bitmap, if the bit corresponding to "off" is set,
546 546 * since the page and translation are being unlocked.
547 547 */
548 548 bitmask = SMAP_BIT_MASK((off - smp->sm_off) >> PAGESHIFT);
549 549
550 550 /*
551 551 * Large Files: Following assertion is to verify
552 552 * the correctness of the cast to (int) above.
553 553 */
554 554 ASSERT((u_offset_t)(off - smp->sm_off) <= INT_MAX);
555 555 smtx = SMAPMTX(smp);
556 556 mutex_enter(smtx);
557 557 if (smp->sm_bitmap & bitmask) {
558 558 smp->sm_bitmap &= ~bitmask;
559 559 }
560 560 mutex_exit(smtx);
561 561
562 562 page_unlock(pp);
563 563 }
564 564 }
565 565
566 566 #define MAXPPB (MAXBSIZE/4096) /* assumes minimum page size of 4k */
567 567
568 568 /*
569 569 * This routine is called via a machine specific fault handling
570 570 * routine. It is also called by software routines wishing to
571 571 * lock or unlock a range of addresses.
572 572 *
573 573 * Note that this routine expects a page-aligned "addr".
574 574 */
575 575 faultcode_t
576 576 segmap_fault(
577 577 struct hat *hat,
578 578 struct seg *seg,
579 579 caddr_t addr,
580 580 size_t len,
581 581 enum fault_type type,
582 582 enum seg_rw rw)
583 583 {
584 584 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
585 585 struct smap *smp;
586 586 page_t *pp, **ppp;
587 587 struct vnode *vp;
588 588 u_offset_t off;
589 589 page_t *pl[MAXPPB + 1];
590 590 uint_t prot;
591 591 u_offset_t addroff;
592 592 caddr_t adr;
593 593 int err;
594 594 u_offset_t sm_off;
595 595 int hat_flag;
596 596
597 597 if (segmap_kpm && IS_KPM_ADDR(addr)) {
598 598 int newpage;
599 599 kmutex_t *smtx;
600 600
601 601 /*
602 602 * Pages are successfully prefaulted and locked in
603 603 * segmap_getmapflt and can't be unlocked until
604 604 * segmap_release. No hat mappings have to be locked
605 605 * and they also can't be unlocked as long as the
606 606 * caller owns an active kpm addr.
607 607 */
608 608 #ifndef DEBUG
609 609 if (type != F_SOFTUNLOCK)
610 610 return (0);
611 611 #endif
612 612
613 613 if ((smp = get_smap_kpm(addr, NULL)) == NULL) {
614 614 panic("segmap_fault: smap not found "
615 615 "for addr %p", (void *)addr);
616 616 /*NOTREACHED*/
617 617 }
618 618
619 619 smtx = SMAPMTX(smp);
620 620 #ifdef DEBUG
621 621 newpage = smp->sm_flags & SM_KPM_NEWPAGE;
622 622 if (newpage) {
623 623 cmn_err(CE_WARN, "segmap_fault: newpage? smp %p",
624 624 (void *)smp);
625 625 }
626 626
627 627 if (type != F_SOFTUNLOCK) {
628 628 mutex_exit(smtx);
629 629 return (0);
630 630 }
631 631 #endif
632 632 mutex_exit(smtx);
633 633 vp = smp->sm_vp;
634 634 sm_off = smp->sm_off;
635 635
636 636 if (vp == NULL)
637 637 return (FC_MAKE_ERR(EIO));
638 638
639 639 ASSERT(smp->sm_refcnt > 0);
640 640
641 641 addroff = (u_offset_t)((uintptr_t)addr & MAXBOFFSET);
642 642 if (addroff + len > MAXBSIZE)
643 643 panic("segmap_fault: endaddr %p exceeds MAXBSIZE chunk",
644 644 (void *)(addr + len));
645 645
646 646 off = sm_off + addroff;
647 647
648 648 pp = page_find(vp, off);
649 649
650 650 if (pp == NULL)
651 651 panic("segmap_fault: softunlock page not found");
652 652
653 653 /*
654 654 * Set ref bit also here in case of S_OTHER to avoid the
655 655 * overhead of supporting other cases than F_SOFTUNLOCK
656 656 * with segkpm. We can do this because the underlying
657 657 * pages are locked anyway.
658 658 */
659 659 if (rw == S_WRITE) {
660 660 hat_setrefmod(pp);
661 661 } else {
662 662 TRACE_3(TR_FAC_VM, TR_SEGMAP_FAULT,
663 663 "segmap_fault:pp %p vp %p offset %llx",
664 664 pp, vp, off);
665 665 hat_setref(pp);
666 666 }
667 667
668 668 return (0);
669 669 }
670 670
671 671 smd_cpu[CPU->cpu_seqid].scpu.scpu_fault++;
672 672 smp = GET_SMAP(seg, addr);
673 673 vp = smp->sm_vp;
674 674 sm_off = smp->sm_off;
675 675
676 676 if (vp == NULL)
677 677 return (FC_MAKE_ERR(EIO));
678 678
679 679 ASSERT(smp->sm_refcnt > 0);
680 680
681 681 addroff = (u_offset_t)((uintptr_t)addr & MAXBOFFSET);
682 682 if (addroff + len > MAXBSIZE) {
683 683 panic("segmap_fault: endaddr %p "
684 684 "exceeds MAXBSIZE chunk", (void *)(addr + len));
685 685 /*NOTREACHED*/
686 686 }
687 687 off = sm_off + addroff;
688 688
689 689 /*
690 690 * First handle the easy stuff
691 691 */
692 692 if (type == F_SOFTUNLOCK) {
693 693 segmap_unlock(hat, seg, addr, len, rw, smp);
694 694 return (0);
695 695 }
696 696
697 697 TRACE_3(TR_FAC_VM, TR_SEGMAP_GETPAGE,
698 698 "segmap_getpage:seg %p addr %p vp %p", seg, addr, vp);
699 699 err = VOP_GETPAGE(vp, (offset_t)off, len, &prot, pl, MAXBSIZE,
700 700 seg, addr, rw, CRED(), NULL);
701 701
702 702 if (err)
703 703 return (FC_MAKE_ERR(err));
704 704
705 705 prot &= smd->smd_prot;
706 706
707 707 /*
708 708 * Handle all pages returned in the pl[] array.
709 709 * This loop is coded on the assumption that if
710 710 * there was no error from the VOP_GETPAGE routine,
711 711 * that the page list returned will contain all the
712 712 * needed pages for the vp from [off..off + len].
713 713 */
714 714 ppp = pl;
715 715 while ((pp = *ppp++) != NULL) {
716 716 u_offset_t poff;
717 717 ASSERT(pp->p_vnode == vp);
718 718 hat_flag = HAT_LOAD;
719 719
720 720 /*
721 721 * Verify that the pages returned are within the range
722 722 * of this segmap region. Note that it is theoretically
723 723 * possible for pages outside this range to be returned,
724 724 * but it is not very likely. If we cannot use the
725 725 * page here, just release it and go on to the next one.
726 726 */
727 727 if (pp->p_offset < sm_off ||
728 728 pp->p_offset >= sm_off + MAXBSIZE) {
729 729 (void) page_release(pp, 1);
730 730 continue;
731 731 }
732 732
733 733 ASSERT(hat == kas.a_hat);
734 734 poff = pp->p_offset;
735 735 adr = addr + (poff - off);
736 736 if (adr >= addr && adr < addr + len) {
737 737 hat_setref(pp);
738 738 TRACE_3(TR_FAC_VM, TR_SEGMAP_FAULT,
739 739 "segmap_fault:pp %p vp %p offset %llx",
740 740 pp, vp, poff);
741 741 if (type == F_SOFTLOCK)
742 742 hat_flag = HAT_LOAD_LOCK;
743 743 }
744 744
745 745 /*
746 746 * Deal with VMODSORT pages here. If we know this is a write
747 747 * do the setmod now and allow write protection.
748 748 * As long as it's modified or not S_OTHER, remove write
749 749 * protection. With S_OTHER it's up to the FS to deal with this.
750 750 */
751 751 if (IS_VMODSORT(vp)) {
752 752 if (rw == S_WRITE)
753 753 hat_setmod(pp);
754 754 else if (rw != S_OTHER && !hat_ismod(pp))
755 755 prot &= ~PROT_WRITE;
756 756 }
757 757
758 758 hat_memload(hat, adr, pp, prot, hat_flag);
759 759 if (hat_flag != HAT_LOAD_LOCK)
760 760 page_unlock(pp);
761 761 }
762 762 return (0);
763 763 }
764 764
765 765 /*
766 766 * This routine is used to start I/O on pages asynchronously.
767 767 */
768 768 static faultcode_t
769 769 segmap_faulta(struct seg *seg, caddr_t addr)
770 770 {
771 771 struct smap *smp;
772 772 struct vnode *vp;
773 773 u_offset_t off;
774 774 int err;
775 775
776 776 if (segmap_kpm && IS_KPM_ADDR(addr)) {
777 777 int newpage;
778 778 kmutex_t *smtx;
779 779
780 780 /*
781 781 * Pages are successfully prefaulted and locked in
782 782 * segmap_getmapflt and can't be unlocked until
783 783 * segmap_release. No hat mappings have to be locked
784 784 * and they also can't be unlocked as long as the
785 785 * caller owns an active kpm addr.
786 786 */
787 787 #ifdef DEBUG
788 788 if ((smp = get_smap_kpm(addr, NULL)) == NULL) {
789 789 panic("segmap_faulta: smap not found "
790 790 "for addr %p", (void *)addr);
791 791 /*NOTREACHED*/
792 792 }
793 793
794 794 smtx = SMAPMTX(smp);
795 795 newpage = smp->sm_flags & SM_KPM_NEWPAGE;
796 796 mutex_exit(smtx);
797 797 if (newpage)
798 798 cmn_err(CE_WARN, "segmap_faulta: newpage? smp %p",
799 799 (void *)smp);
800 800 #endif
801 801 return (0);
802 802 }
803 803
804 804 segmapcnt.smp_faulta.value.ul++;
805 805 smp = GET_SMAP(seg, addr);
806 806
807 807 ASSERT(smp->sm_refcnt > 0);
808 808
809 809 vp = smp->sm_vp;
810 810 off = smp->sm_off;
811 811
812 812 if (vp == NULL) {
813 813 cmn_err(CE_WARN, "segmap_faulta - no vp");
814 814 return (FC_MAKE_ERR(EIO));
815 815 }
816 816
817 817 TRACE_3(TR_FAC_VM, TR_SEGMAP_GETPAGE,
818 818 "segmap_getpage:seg %p addr %p vp %p", seg, addr, vp);
819 819
820 820 err = VOP_GETPAGE(vp, (offset_t)(off + ((offset_t)((uintptr_t)addr
821 821 & MAXBOFFSET))), PAGESIZE, (uint_t *)NULL, (page_t **)NULL, 0,
822 822 seg, addr, S_READ, CRED(), NULL);
823 823
824 824 if (err)
825 825 return (FC_MAKE_ERR(err));
826 826 return (0);
827 827 }
828 828
829 829 /*ARGSUSED*/
830 830 static int
831 831 segmap_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
832 832 {
833 833 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
834 834
835 835 ASSERT(seg->s_as && RW_LOCK_HELD(&seg->s_as->a_lock));
836 836
837 837 /*
838 838 * Need not acquire the segment lock since
839 839 * "smd_prot" is a read-only field.
840 840 */
841 841 return (((smd->smd_prot & prot) != prot) ? EACCES : 0);
842 842 }
843 843
844 844 static int
845 845 segmap_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
846 846 {
847 847 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
848 848 size_t pgno = seg_page(seg, addr + len) - seg_page(seg, addr) + 1;
849 849
850 850 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
851 851
852 852 if (pgno != 0) {
853 853 do {
854 854 protv[--pgno] = smd->smd_prot;
855 855 } while (pgno != 0);
856 856 }
857 857 return (0);
858 858 }
859 859
860 860 static u_offset_t
861 861 segmap_getoffset(struct seg *seg, caddr_t addr)
862 862 {
863 863 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
864 864
865 865 ASSERT(seg->s_as && RW_READ_HELD(&seg->s_as->a_lock));
866 866
867 867 return ((u_offset_t)smd->smd_sm->sm_off + (addr - seg->s_base));
868 868 }
869 869
870 870 /*ARGSUSED*/
871 871 static int
872 872 segmap_gettype(struct seg *seg, caddr_t addr)
873 873 {
874 874 ASSERT(seg->s_as && RW_READ_HELD(&seg->s_as->a_lock));
875 875
876 876 return (MAP_SHARED);
877 877 }
878 878
879 879 /*ARGSUSED*/
880 880 static int
881 881 segmap_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
882 882 {
883 883 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
884 884
885 885 ASSERT(seg->s_as && RW_READ_HELD(&seg->s_as->a_lock));
886 886
887 887 /* XXX - This doesn't make any sense */
888 888 *vpp = smd->smd_sm->sm_vp;
889 889 return (0);
890 890 }
891 891
892 892 /*
893 893 * Check to see if it makes sense to do kluster/read ahead to
894 894 * addr + delta relative to the mapping at addr. We assume here
895 895 * that delta is a signed PAGESIZE'd multiple (which can be negative).
896 896 *
897 897 * For segmap we always "approve" of this action from our standpoint.
898 898 */
899 899 /*ARGSUSED*/
900 900 static int
901 901 segmap_kluster(struct seg *seg, caddr_t addr, ssize_t delta)
902 902 {
903 903 return (0);
904 904 }
905 905
906 906 static void
907 907 segmap_badop()
908 908 {
909 909 panic("segmap_badop");
910 910 /*NOTREACHED*/
911 911 }
912 912
913 913 /*
914 914 * Special private segmap operations
915 915 */
916 916
917 917 /*
918 918 * Add smap to the appropriate free list.
919 919 */
920 920 static void
921 921 segmap_smapadd(struct smap *smp)
922 922 {
923 923 struct smfree *sm;
924 924 struct smap *smpfreelist;
925 925 struct sm_freeq *releq;
926 926
927 927 ASSERT(MUTEX_HELD(SMAPMTX(smp)));
928 928
929 929 if (smp->sm_refcnt != 0) {
930 930 panic("segmap_smapadd");
931 931 /*NOTREACHED*/
932 932 }
933 933
934 934 sm = &smd_free[smp->sm_free_ndx];
935 935 /*
936 936 * Add to the tail of the release queue
937 937 * Note that sm_releq and sm_allocq could toggle
938 938 * before we get the lock. This does not affect
939 939 * correctness as the 2 queues are only maintained
940 940 * to reduce lock pressure.
941 941 */
942 942 releq = sm->sm_releq;
943 943 if (releq == &sm->sm_freeq[0])
944 944 smp->sm_flags |= SM_QNDX_ZERO;
945 945 else
946 946 smp->sm_flags &= ~SM_QNDX_ZERO;
947 947 mutex_enter(&releq->smq_mtx);
948 948 smpfreelist = releq->smq_free;
949 949 if (smpfreelist == 0) {
950 950 int want;
951 951
952 952 releq->smq_free = smp->sm_next = smp->sm_prev = smp;
953 953 /*
954 954 * Both queue mutexes held to set sm_want;
955 955 * snapshot the value before dropping releq mutex.
956 956 * If sm_want appears after the releq mutex is dropped,
957 957 * then the smap just freed is already gone.
958 958 */
959 959 want = sm->sm_want;
960 960 mutex_exit(&releq->smq_mtx);
961 961 /*
962 962 * See if there was a waiter before dropping the releq mutex
963 963 * then recheck after obtaining sm_freeq[0] mutex as
964 964 * the another thread may have already signaled.
965 965 */
966 966 if (want) {
967 967 mutex_enter(&sm->sm_freeq[0].smq_mtx);
968 968 if (sm->sm_want)
969 969 cv_signal(&sm->sm_free_cv);
970 970 mutex_exit(&sm->sm_freeq[0].smq_mtx);
971 971 }
972 972 } else {
973 973 smp->sm_next = smpfreelist;
974 974 smp->sm_prev = smpfreelist->sm_prev;
975 975 smpfreelist->sm_prev = smp;
976 976 smp->sm_prev->sm_next = smp;
977 977 mutex_exit(&releq->smq_mtx);
978 978 }
979 979 }
980 980
981 981
982 982 static struct smap *
983 983 segmap_hashin(struct smap *smp, struct vnode *vp, u_offset_t off, int hashid)
984 984 {
985 985 struct smap **hpp;
986 986 struct smap *tmp;
987 987 kmutex_t *hmtx;
988 988
989 989 ASSERT(MUTEX_HELD(SMAPMTX(smp)));
990 990 ASSERT(smp->sm_vp == NULL);
991 991 ASSERT(smp->sm_hash == NULL);
992 992 ASSERT(smp->sm_prev == NULL);
993 993 ASSERT(smp->sm_next == NULL);
994 994 ASSERT(hashid >= 0 && hashid <= smd_hashmsk);
995 995
996 996 hmtx = SHASHMTX(hashid);
997 997
998 998 mutex_enter(hmtx);
999 999 /*
1000 1000 * First we need to verify that no one has created a smp
1001 1001 * with (vp,off) as its tag before we us.
1002 1002 */
1003 1003 for (tmp = smd_hash[hashid].sh_hash_list;
1004 1004 tmp != NULL; tmp = tmp->sm_hash)
1005 1005 if (tmp->sm_vp == vp && tmp->sm_off == off)
1006 1006 break;
1007 1007
1008 1008 if (tmp == NULL) {
1009 1009 /*
1010 1010 * No one created one yet.
1011 1011 *
1012 1012 * Funniness here - we don't increment the ref count on the
1013 1013 * vnode * even though we have another pointer to it here.
1014 1014 * The reason for this is that we don't want the fact that
1015 1015 * a seg_map entry somewhere refers to a vnode to prevent the
1016 1016 * vnode * itself from going away. This is because this
1017 1017 * reference to the vnode is a "soft one". In the case where
1018 1018 * a mapping is being used by a rdwr [or directory routine?]
1019 1019 * there already has to be a non-zero ref count on the vnode.
1020 1020 * In the case where the vp has been freed and the the smap
1021 1021 * structure is on the free list, there are no pages in memory
1022 1022 * that can refer to the vnode. Thus even if we reuse the same
1023 1023 * vnode/smap structure for a vnode which has the same
1024 1024 * address but represents a different object, we are ok.
1025 1025 */
1026 1026 smp->sm_vp = vp;
1027 1027 smp->sm_off = off;
1028 1028
1029 1029 hpp = &smd_hash[hashid].sh_hash_list;
1030 1030 smp->sm_hash = *hpp;
1031 1031 *hpp = smp;
1032 1032 #ifdef SEGMAP_HASHSTATS
1033 1033 smd_hash_len[hashid]++;
1034 1034 #endif
1035 1035 }
1036 1036 mutex_exit(hmtx);
1037 1037
1038 1038 return (tmp);
1039 1039 }
1040 1040
1041 1041 static void
1042 1042 segmap_hashout(struct smap *smp)
1043 1043 {
1044 1044 struct smap **hpp, *hp;
1045 1045 struct vnode *vp;
1046 1046 kmutex_t *mtx;
1047 1047 int hashid;
1048 1048 u_offset_t off;
1049 1049
1050 1050 ASSERT(MUTEX_HELD(SMAPMTX(smp)));
1051 1051
1052 1052 vp = smp->sm_vp;
1053 1053 off = smp->sm_off;
1054 1054
1055 1055 SMAP_HASHFUNC(vp, off, hashid); /* macro assigns hashid */
1056 1056 mtx = SHASHMTX(hashid);
1057 1057 mutex_enter(mtx);
1058 1058
1059 1059 hpp = &smd_hash[hashid].sh_hash_list;
1060 1060 for (;;) {
1061 1061 hp = *hpp;
1062 1062 if (hp == NULL) {
1063 1063 panic("segmap_hashout");
1064 1064 /*NOTREACHED*/
1065 1065 }
1066 1066 if (hp == smp)
1067 1067 break;
1068 1068 hpp = &hp->sm_hash;
1069 1069 }
1070 1070
1071 1071 *hpp = smp->sm_hash;
1072 1072 smp->sm_hash = NULL;
1073 1073 #ifdef SEGMAP_HASHSTATS
1074 1074 smd_hash_len[hashid]--;
1075 1075 #endif
1076 1076 mutex_exit(mtx);
1077 1077
1078 1078 smp->sm_vp = NULL;
1079 1079 smp->sm_off = (u_offset_t)0;
1080 1080
1081 1081 }
1082 1082
1083 1083 /*
1084 1084 * Attempt to free unmodified, unmapped, and non locked segmap
1085 1085 * pages.
1086 1086 */
1087 1087 void
1088 1088 segmap_pagefree(struct vnode *vp, u_offset_t off)
1089 1089 {
1090 1090 u_offset_t pgoff;
1091 1091 page_t *pp;
1092 1092
1093 1093 for (pgoff = off; pgoff < off + MAXBSIZE; pgoff += PAGESIZE) {
1094 1094
1095 1095 if ((pp = page_lookup_nowait(vp, pgoff, SE_EXCL)) == NULL)
1096 1096 continue;
1097 1097
1098 1098 switch (page_release(pp, 1)) {
1099 1099 case PGREL_NOTREL:
1100 1100 segmapcnt.smp_free_notfree.value.ul++;
1101 1101 break;
1102 1102 case PGREL_MOD:
1103 1103 segmapcnt.smp_free_dirty.value.ul++;
1104 1104 break;
1105 1105 case PGREL_CLEAN:
1106 1106 segmapcnt.smp_free.value.ul++;
1107 1107 break;
1108 1108 }
1109 1109 }
1110 1110 }
1111 1111
1112 1112 /*
1113 1113 * Locks held on entry: smap lock
1114 1114 * Locks held on exit : smap lock.
1115 1115 */
1116 1116
1117 1117 static void
1118 1118 grab_smp(struct smap *smp, page_t *pp)
1119 1119 {
1120 1120 ASSERT(MUTEX_HELD(SMAPMTX(smp)));
1121 1121 ASSERT(smp->sm_refcnt == 0);
1122 1122
1123 1123 if (smp->sm_vp != (struct vnode *)NULL) {
1124 1124 struct vnode *vp = smp->sm_vp;
1125 1125 u_offset_t off = smp->sm_off;
1126 1126 /*
1127 1127 * Destroy old vnode association and
1128 1128 * unload any hardware translations to
1129 1129 * the old object.
1130 1130 */
1131 1131 smd_cpu[CPU->cpu_seqid].scpu.scpu_get_reuse++;
1132 1132 segmap_hashout(smp);
1133 1133
1134 1134 /*
1135 1135 * This node is off freelist and hashlist,
1136 1136 * so there is no reason to drop/reacquire sm_mtx
1137 1137 * across calls to hat_unload.
1138 1138 */
1139 1139 if (segmap_kpm) {
1140 1140 caddr_t vaddr;
1141 1141 int hat_unload_needed = 0;
1142 1142
1143 1143 /*
1144 1144 * unload kpm mapping
1145 1145 */
1146 1146 if (pp != NULL) {
1147 1147 vaddr = hat_kpm_page2va(pp, 1);
1148 1148 hat_kpm_mapout(pp, GET_KPME(smp), vaddr);
1149 1149 page_unlock(pp);
1150 1150 }
1151 1151
1152 1152 /*
1153 1153 * Check if we have (also) the rare case of a
1154 1154 * non kpm mapping.
1155 1155 */
1156 1156 if (smp->sm_flags & SM_NOTKPM_RELEASED) {
1157 1157 hat_unload_needed = 1;
1158 1158 smp->sm_flags &= ~SM_NOTKPM_RELEASED;
1159 1159 }
1160 1160
1161 1161 if (hat_unload_needed) {
1162 1162 hat_unload(kas.a_hat, segkmap->s_base +
1163 1163 ((smp - smd_smap) * MAXBSIZE),
1164 1164 MAXBSIZE, HAT_UNLOAD);
1165 1165 }
1166 1166
1167 1167 } else {
1168 1168 ASSERT(smp->sm_flags & SM_NOTKPM_RELEASED);
1169 1169 smp->sm_flags &= ~SM_NOTKPM_RELEASED;
1170 1170 hat_unload(kas.a_hat, segkmap->s_base +
1171 1171 ((smp - smd_smap) * MAXBSIZE),
1172 1172 MAXBSIZE, HAT_UNLOAD);
1173 1173 }
1174 1174 segmap_pagefree(vp, off);
1175 1175 }
1176 1176 }
1177 1177
1178 1178 static struct smap *
1179 1179 get_free_smp(int free_ndx)
1180 1180 {
1181 1181 struct smfree *sm;
1182 1182 kmutex_t *smtx;
1183 1183 struct smap *smp, *first;
1184 1184 struct sm_freeq *allocq, *releq;
1185 1185 struct kpme *kpme;
1186 1186 page_t *pp = NULL;
1187 1187 int end_ndx, page_locked = 0;
1188 1188
1189 1189 end_ndx = free_ndx;
1190 1190 sm = &smd_free[free_ndx];
1191 1191
1192 1192 retry_queue:
1193 1193 allocq = sm->sm_allocq;
1194 1194 mutex_enter(&allocq->smq_mtx);
1195 1195
1196 1196 if ((smp = allocq->smq_free) == NULL) {
1197 1197
1198 1198 skip_queue:
1199 1199 /*
1200 1200 * The alloc list is empty or this queue is being skipped;
1201 1201 * first see if the allocq toggled.
1202 1202 */
1203 1203 if (sm->sm_allocq != allocq) {
1204 1204 /* queue changed */
1205 1205 mutex_exit(&allocq->smq_mtx);
1206 1206 goto retry_queue;
1207 1207 }
1208 1208 releq = sm->sm_releq;
1209 1209 if (!mutex_tryenter(&releq->smq_mtx)) {
1210 1210 /* cannot get releq; a free smp may be there now */
1211 1211 mutex_exit(&allocq->smq_mtx);
1212 1212
1213 1213 /*
1214 1214 * This loop could spin forever if this thread has
1215 1215 * higher priority than the thread that is holding
1216 1216 * releq->smq_mtx. In order to force the other thread
1217 1217 * to run, we'll lock/unlock the mutex which is safe
1218 1218 * since we just unlocked the allocq mutex.
1219 1219 */
1220 1220 mutex_enter(&releq->smq_mtx);
1221 1221 mutex_exit(&releq->smq_mtx);
1222 1222 goto retry_queue;
1223 1223 }
1224 1224 if (releq->smq_free == NULL) {
1225 1225 /*
1226 1226 * This freelist is empty.
1227 1227 * This should not happen unless clients
1228 1228 * are failing to release the segmap
1229 1229 * window after accessing the data.
1230 1230 * Before resorting to sleeping, try
1231 1231 * the next list of the same color.
1232 1232 */
1233 1233 free_ndx = (free_ndx + smd_ncolor) & smd_freemsk;
1234 1234 if (free_ndx != end_ndx) {
1235 1235 mutex_exit(&releq->smq_mtx);
1236 1236 mutex_exit(&allocq->smq_mtx);
1237 1237 sm = &smd_free[free_ndx];
1238 1238 goto retry_queue;
1239 1239 }
1240 1240 /*
1241 1241 * Tried all freelists of the same color once,
1242 1242 * wait on this list and hope something gets freed.
1243 1243 */
1244 1244 segmapcnt.smp_get_nofree.value.ul++;
1245 1245 sm->sm_want++;
1246 1246 mutex_exit(&sm->sm_freeq[1].smq_mtx);
1247 1247 cv_wait(&sm->sm_free_cv,
1248 1248 &sm->sm_freeq[0].smq_mtx);
1249 1249 sm->sm_want--;
1250 1250 mutex_exit(&sm->sm_freeq[0].smq_mtx);
1251 1251 sm = &smd_free[free_ndx];
1252 1252 goto retry_queue;
1253 1253 } else {
1254 1254 /*
1255 1255 * Something on the rele queue; flip the alloc
1256 1256 * and rele queues and retry.
1257 1257 */
1258 1258 sm->sm_allocq = releq;
1259 1259 sm->sm_releq = allocq;
1260 1260 mutex_exit(&allocq->smq_mtx);
1261 1261 mutex_exit(&releq->smq_mtx);
1262 1262 if (page_locked) {
1263 1263 delay(hz >> 2);
1264 1264 page_locked = 0;
1265 1265 }
1266 1266 goto retry_queue;
1267 1267 }
1268 1268 } else {
1269 1269 /*
1270 1270 * Fastpath the case we get the smap mutex
1271 1271 * on the first try.
1272 1272 */
1273 1273 first = smp;
1274 1274 next_smap:
1275 1275 smtx = SMAPMTX(smp);
1276 1276 if (!mutex_tryenter(smtx)) {
1277 1277 /*
1278 1278 * Another thread is trying to reclaim this slot.
1279 1279 * Skip to the next queue or smap.
1280 1280 */
1281 1281 if ((smp = smp->sm_next) == first) {
1282 1282 goto skip_queue;
1283 1283 } else {
1284 1284 goto next_smap;
1285 1285 }
1286 1286 } else {
1287 1287 /*
1288 1288 * if kpme exists, get shared lock on the page
1289 1289 */
1290 1290 if (segmap_kpm && smp->sm_vp != NULL) {
1291 1291
1292 1292 kpme = GET_KPME(smp);
1293 1293 pp = kpme->kpe_page;
1294 1294
1295 1295 if (pp != NULL) {
1296 1296 if (!page_trylock(pp, SE_SHARED)) {
1297 1297 smp = smp->sm_next;
1298 1298 mutex_exit(smtx);
1299 1299 page_locked = 1;
1300 1300
1301 1301 pp = NULL;
1302 1302
1303 1303 if (smp == first) {
1304 1304 goto skip_queue;
1305 1305 } else {
1306 1306 goto next_smap;
1307 1307 }
1308 1308 } else {
1309 1309 if (kpme->kpe_page == NULL) {
1310 1310 page_unlock(pp);
1311 1311 pp = NULL;
1312 1312 }
1313 1313 }
1314 1314 }
1315 1315 }
1316 1316
1317 1317 /*
1318 1318 * At this point, we've selected smp. Remove smp
1319 1319 * from its freelist. If smp is the first one in
1320 1320 * the freelist, update the head of the freelist.
1321 1321 */
1322 1322 if (first == smp) {
1323 1323 ASSERT(first == allocq->smq_free);
1324 1324 allocq->smq_free = smp->sm_next;
1325 1325 }
1326 1326
1327 1327 /*
1328 1328 * if the head of the freelist still points to smp,
1329 1329 * then there are no more free smaps in that list.
1330 1330 */
1331 1331 if (allocq->smq_free == smp)
1332 1332 /*
1333 1333 * Took the last one
1334 1334 */
1335 1335 allocq->smq_free = NULL;
1336 1336 else {
1337 1337 smp->sm_prev->sm_next = smp->sm_next;
1338 1338 smp->sm_next->sm_prev = smp->sm_prev;
1339 1339 }
1340 1340 mutex_exit(&allocq->smq_mtx);
1341 1341 smp->sm_prev = smp->sm_next = NULL;
1342 1342
1343 1343 /*
1344 1344 * if pp != NULL, pp must have been locked;
1345 1345 * grab_smp() unlocks pp.
1346 1346 */
1347 1347 ASSERT((pp == NULL) || PAGE_LOCKED(pp));
1348 1348 grab_smp(smp, pp);
1349 1349 /* return smp locked. */
1350 1350 ASSERT(SMAPMTX(smp) == smtx);
1351 1351 ASSERT(MUTEX_HELD(smtx));
1352 1352 return (smp);
1353 1353 }
1354 1354 }
1355 1355 }
1356 1356
1357 1357 /*
1358 1358 * Special public segmap operations
1359 1359 */
1360 1360
1361 1361 /*
1362 1362 * Create pages (without using VOP_GETPAGE) and load up translations to them.
1363 1363 * If softlock is TRUE, then set things up so that it looks like a call
1364 1364 * to segmap_fault with F_SOFTLOCK.
1365 1365 *
1366 1366 * Returns 1, if a page is created by calling page_create_va(), or 0 otherwise.
1367 1367 *
1368 1368 * All fields in the generic segment (struct seg) are considered to be
1369 1369 * read-only for "segmap" even though the kernel address space (kas) may
1370 1370 * not be locked, hence no lock is needed to access them.
1371 1371 */
1372 1372 int
1373 1373 segmap_pagecreate(struct seg *seg, caddr_t addr, size_t len, int softlock)
1374 1374 {
1375 1375 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
1376 1376 page_t *pp;
1377 1377 u_offset_t off;
1378 1378 struct smap *smp;
1379 1379 struct vnode *vp;
1380 1380 caddr_t eaddr;
1381 1381 int newpage = 0;
1382 1382 uint_t prot;
1383 1383 kmutex_t *smtx;
1384 1384 int hat_flag;
1385 1385
1386 1386 ASSERT(seg->s_as == &kas);
1387 1387
1388 1388 if (segmap_kpm && IS_KPM_ADDR(addr)) {
1389 1389 /*
1390 1390 * Pages are successfully prefaulted and locked in
1391 1391 * segmap_getmapflt and can't be unlocked until
1392 1392 * segmap_release. The SM_KPM_NEWPAGE flag is set
1393 1393 * in segmap_pagecreate_kpm when new pages are created.
1394 1394 * and it is returned as "newpage" indication here.
1395 1395 */
1396 1396 if ((smp = get_smap_kpm(addr, NULL)) == NULL) {
1397 1397 panic("segmap_pagecreate: smap not found "
1398 1398 "for addr %p", (void *)addr);
1399 1399 /*NOTREACHED*/
1400 1400 }
1401 1401
1402 1402 smtx = SMAPMTX(smp);
1403 1403 newpage = smp->sm_flags & SM_KPM_NEWPAGE;
1404 1404 smp->sm_flags &= ~SM_KPM_NEWPAGE;
1405 1405 mutex_exit(smtx);
1406 1406
1407 1407 return (newpage);
1408 1408 }
1409 1409
1410 1410 smd_cpu[CPU->cpu_seqid].scpu.scpu_pagecreate++;
1411 1411
1412 1412 eaddr = addr + len;
1413 1413 addr = (caddr_t)((uintptr_t)addr & (uintptr_t)PAGEMASK);
1414 1414
1415 1415 smp = GET_SMAP(seg, addr);
1416 1416
1417 1417 /*
1418 1418 * We don't grab smp mutex here since we assume the smp
1419 1419 * has a refcnt set already which prevents the slot from
1420 1420 * changing its id.
1421 1421 */
1422 1422 ASSERT(smp->sm_refcnt > 0);
1423 1423
1424 1424 vp = smp->sm_vp;
1425 1425 off = smp->sm_off + ((u_offset_t)((uintptr_t)addr & MAXBOFFSET));
1426 1426 prot = smd->smd_prot;
1427 1427
1428 1428 for (; addr < eaddr; addr += PAGESIZE, off += PAGESIZE) {
1429 1429 hat_flag = HAT_LOAD;
1430 1430 pp = page_lookup(vp, off, SE_SHARED);
1431 1431 if (pp == NULL) {
1432 1432 ushort_t bitindex;
1433 1433
1434 1434 if ((pp = page_create_va(vp, off,
1435 1435 PAGESIZE, PG_WAIT, seg, addr)) == NULL) {
1436 1436 panic("segmap_pagecreate: page_create failed");
1437 1437 /*NOTREACHED*/
1438 1438 }
1439 1439 newpage = 1;
1440 1440 page_io_unlock(pp);
1441 1441
1442 1442 /*
1443 1443 * Since pages created here do not contain valid
1444 1444 * data until the caller writes into them, the
1445 1445 * "exclusive" lock will not be dropped to prevent
1446 1446 * other users from accessing the page. We also
1447 1447 * have to lock the translation to prevent a fault
1448 1448 * from occurring when the virtual address mapped by
1449 1449 * this page is written into. This is necessary to
1450 1450 * avoid a deadlock since we haven't dropped the
1451 1451 * "exclusive" lock.
1452 1452 */
1453 1453 bitindex = (ushort_t)((off - smp->sm_off) >> PAGESHIFT);
1454 1454
1455 1455 /*
1456 1456 * Large Files: The following assertion is to
1457 1457 * verify the cast above.
1458 1458 */
1459 1459 ASSERT((u_offset_t)(off - smp->sm_off) <= INT_MAX);
1460 1460 smtx = SMAPMTX(smp);
1461 1461 mutex_enter(smtx);
1462 1462 smp->sm_bitmap |= SMAP_BIT_MASK(bitindex);
1463 1463 mutex_exit(smtx);
1464 1464
1465 1465 hat_flag = HAT_LOAD_LOCK;
1466 1466 } else if (softlock) {
1467 1467 hat_flag = HAT_LOAD_LOCK;
1468 1468 }
1469 1469
1470 1470 if (IS_VMODSORT(pp->p_vnode) && (prot & PROT_WRITE))
1471 1471 hat_setmod(pp);
1472 1472
1473 1473 hat_memload(kas.a_hat, addr, pp, prot, hat_flag);
1474 1474
1475 1475 if (hat_flag != HAT_LOAD_LOCK)
1476 1476 page_unlock(pp);
1477 1477
1478 1478 TRACE_5(TR_FAC_VM, TR_SEGMAP_PAGECREATE,
1479 1479 "segmap_pagecreate:seg %p addr %p pp %p vp %p offset %llx",
1480 1480 seg, addr, pp, vp, off);
1481 1481 }
1482 1482
1483 1483 return (newpage);
1484 1484 }
1485 1485
1486 1486 void
1487 1487 segmap_pageunlock(struct seg *seg, caddr_t addr, size_t len, enum seg_rw rw)
1488 1488 {
1489 1489 struct smap *smp;
1490 1490 ushort_t bitmask;
1491 1491 page_t *pp;
1492 1492 struct vnode *vp;
1493 1493 u_offset_t off;
1494 1494 caddr_t eaddr;
1495 1495 kmutex_t *smtx;
1496 1496
1497 1497 ASSERT(seg->s_as == &kas);
1498 1498
1499 1499 eaddr = addr + len;
1500 1500 addr = (caddr_t)((uintptr_t)addr & (uintptr_t)PAGEMASK);
1501 1501
1502 1502 if (segmap_kpm && IS_KPM_ADDR(addr)) {
1503 1503 /*
1504 1504 * Pages are successfully prefaulted and locked in
1505 1505 * segmap_getmapflt and can't be unlocked until
1506 1506 * segmap_release, so no pages or hat mappings have
1507 1507 * to be unlocked at this point.
1508 1508 */
1509 1509 #ifdef DEBUG
1510 1510 if ((smp = get_smap_kpm(addr, NULL)) == NULL) {
1511 1511 panic("segmap_pageunlock: smap not found "
1512 1512 "for addr %p", (void *)addr);
1513 1513 /*NOTREACHED*/
1514 1514 }
1515 1515
1516 1516 ASSERT(smp->sm_refcnt > 0);
1517 1517 mutex_exit(SMAPMTX(smp));
1518 1518 #endif
1519 1519 return;
1520 1520 }
1521 1521
1522 1522 smp = GET_SMAP(seg, addr);
1523 1523 smtx = SMAPMTX(smp);
1524 1524
1525 1525 ASSERT(smp->sm_refcnt > 0);
1526 1526
1527 1527 vp = smp->sm_vp;
1528 1528 off = smp->sm_off + ((u_offset_t)((uintptr_t)addr & MAXBOFFSET));
1529 1529
1530 1530 for (; addr < eaddr; addr += PAGESIZE, off += PAGESIZE) {
1531 1531 bitmask = SMAP_BIT_MASK((int)(off - smp->sm_off) >> PAGESHIFT);
1532 1532
1533 1533 /*
1534 1534 * Large Files: Following assertion is to verify
1535 1535 * the correctness of the cast to (int) above.
1536 1536 */
1537 1537 ASSERT((u_offset_t)(off - smp->sm_off) <= INT_MAX);
1538 1538
1539 1539 /*
1540 1540 * If the bit corresponding to "off" is set,
1541 1541 * clear this bit in the bitmap, unlock translations,
1542 1542 * and release the "exclusive" lock on the page.
1543 1543 */
1544 1544 if (smp->sm_bitmap & bitmask) {
1545 1545 mutex_enter(smtx);
1546 1546 smp->sm_bitmap &= ~bitmask;
1547 1547 mutex_exit(smtx);
1548 1548
1549 1549 hat_unlock(kas.a_hat, addr, PAGESIZE);
1550 1550
1551 1551 /*
1552 1552 * Use page_find() instead of page_lookup() to
1553 1553 * find the page since we know that it has
1554 1554 * "exclusive" lock.
1555 1555 */
1556 1556 pp = page_find(vp, off);
1557 1557 if (pp == NULL) {
1558 1558 panic("segmap_pageunlock: page not found");
1559 1559 /*NOTREACHED*/
1560 1560 }
1561 1561 if (rw == S_WRITE) {
1562 1562 hat_setrefmod(pp);
1563 1563 } else if (rw != S_OTHER) {
1564 1564 hat_setref(pp);
1565 1565 }
1566 1566
1567 1567 page_unlock(pp);
1568 1568 }
1569 1569 }
1570 1570 }
1571 1571
1572 1572 caddr_t
1573 1573 segmap_getmap(struct seg *seg, struct vnode *vp, u_offset_t off)
1574 1574 {
1575 1575 return (segmap_getmapflt(seg, vp, off, MAXBSIZE, 0, S_OTHER));
1576 1576 }
1577 1577
1578 1578 /*
1579 1579 * This is the magic virtual address that offset 0 of an ELF
1580 1580 * file gets mapped to in user space. This is used to pick
1581 1581 * the vac color on the freelist.
1582 1582 */
1583 1583 #define ELF_OFFZERO_VA (0x10000)
1584 1584 /*
1585 1585 * segmap_getmap allocates a MAXBSIZE big slot to map the vnode vp
1586 1586 * in the range <off, off + len). off doesn't need to be MAXBSIZE aligned.
1587 1587 * The return address is always MAXBSIZE aligned.
1588 1588 *
1589 1589 * If forcefault is nonzero and the MMU translations haven't yet been created,
1590 1590 * segmap_getmap will call segmap_fault(..., F_INVAL, rw) to create them.
1591 1591 */
1592 1592 caddr_t
1593 1593 segmap_getmapflt(
1594 1594 struct seg *seg,
1595 1595 struct vnode *vp,
1596 1596 u_offset_t off,
1597 1597 size_t len,
1598 1598 int forcefault,
1599 1599 enum seg_rw rw)
1600 1600 {
1601 1601 struct smap *smp, *nsmp;
1602 1602 extern struct vnode *common_specvp();
1603 1603 caddr_t baseaddr; /* MAXBSIZE aligned */
1604 1604 u_offset_t baseoff;
1605 1605 int newslot;
1606 1606 caddr_t vaddr;
1607 1607 int color, hashid;
1608 1608 kmutex_t *hashmtx, *smapmtx;
1609 1609 struct smfree *sm;
1610 1610 page_t *pp;
1611 1611 struct kpme *kpme;
1612 1612 uint_t prot;
1613 1613 caddr_t base;
1614 1614 page_t *pl[MAXPPB + 1];
1615 1615 int error;
1616 1616 int is_kpm = 1;
1617 1617
1618 1618 ASSERT(seg->s_as == &kas);
1619 1619 ASSERT(seg == segkmap);
1620 1620
1621 1621 baseoff = off & (offset_t)MAXBMASK;
1622 1622 if (off + len > baseoff + MAXBSIZE) {
1623 1623 panic("segmap_getmap bad len");
1624 1624 /*NOTREACHED*/
1625 1625 }
1626 1626
1627 1627 /*
1628 1628 * If this is a block device we have to be sure to use the
1629 1629 * "common" block device vnode for the mapping.
1630 1630 */
1631 1631 if (vp->v_type == VBLK)
1632 1632 vp = common_specvp(vp);
1633 1633
1634 1634 smd_cpu[CPU->cpu_seqid].scpu.scpu_getmap++;
1635 1635
1636 1636 if (segmap_kpm == 0 ||
1637 1637 (forcefault == SM_PAGECREATE && rw != S_WRITE)) {
1638 1638 is_kpm = 0;
1639 1639 }
1640 1640
1641 1641 SMAP_HASHFUNC(vp, off, hashid); /* macro assigns hashid */
1642 1642 hashmtx = SHASHMTX(hashid);
1643 1643
1644 1644 retry_hash:
1645 1645 mutex_enter(hashmtx);
1646 1646 for (smp = smd_hash[hashid].sh_hash_list;
1647 1647 smp != NULL; smp = smp->sm_hash)
1648 1648 if (smp->sm_vp == vp && smp->sm_off == baseoff)
1649 1649 break;
1650 1650 mutex_exit(hashmtx);
1651 1651
1652 1652 vrfy_smp:
1653 1653 if (smp != NULL) {
1654 1654
1655 1655 ASSERT(vp->v_count != 0);
1656 1656
1657 1657 /*
1658 1658 * Get smap lock and recheck its tag. The hash lock
1659 1659 * is dropped since the hash is based on (vp, off)
1660 1660 * and (vp, off) won't change when we have smap mtx.
1661 1661 */
1662 1662 smapmtx = SMAPMTX(smp);
1663 1663 mutex_enter(smapmtx);
1664 1664 if (smp->sm_vp != vp || smp->sm_off != baseoff) {
1665 1665 mutex_exit(smapmtx);
1666 1666 goto retry_hash;
1667 1667 }
1668 1668
1669 1669 if (smp->sm_refcnt == 0) {
1670 1670
1671 1671 smd_cpu[CPU->cpu_seqid].scpu.scpu_get_reclaim++;
1672 1672
1673 1673 /*
1674 1674 * Could still be on the free list. However, this
1675 1675 * could also be an smp that is transitioning from
1676 1676 * the free list when we have too much contention
1677 1677 * for the smapmtx's. In this case, we have an
1678 1678 * unlocked smp that is not on the free list any
1679 1679 * longer, but still has a 0 refcnt. The only way
1680 1680 * to be sure is to check the freelist pointers.
1681 1681 * Since we now have the smapmtx, we are guaranteed
1682 1682 * that the (vp, off) won't change, so we are safe
1683 1683 * to reclaim it. get_free_smp() knows that this
1684 1684 * can happen, and it will check the refcnt.
1685 1685 */
1686 1686
1687 1687 if ((smp->sm_next != NULL)) {
1688 1688 struct sm_freeq *freeq;
1689 1689
1690 1690 ASSERT(smp->sm_prev != NULL);
1691 1691 sm = &smd_free[smp->sm_free_ndx];
1692 1692
1693 1693 if (smp->sm_flags & SM_QNDX_ZERO)
1694 1694 freeq = &sm->sm_freeq[0];
1695 1695 else
1696 1696 freeq = &sm->sm_freeq[1];
1697 1697
1698 1698 mutex_enter(&freeq->smq_mtx);
1699 1699 if (freeq->smq_free != smp) {
1700 1700 /*
1701 1701 * fastpath normal case
1702 1702 */
1703 1703 smp->sm_prev->sm_next = smp->sm_next;
1704 1704 smp->sm_next->sm_prev = smp->sm_prev;
1705 1705 } else if (smp == smp->sm_next) {
1706 1706 /*
1707 1707 * Taking the last smap on freelist
1708 1708 */
1709 1709 freeq->smq_free = NULL;
1710 1710 } else {
1711 1711 /*
1712 1712 * Reclaiming 1st smap on list
1713 1713 */
1714 1714 freeq->smq_free = smp->sm_next;
1715 1715 smp->sm_prev->sm_next = smp->sm_next;
1716 1716 smp->sm_next->sm_prev = smp->sm_prev;
1717 1717 }
1718 1718 mutex_exit(&freeq->smq_mtx);
1719 1719 smp->sm_prev = smp->sm_next = NULL;
1720 1720 } else {
1721 1721 ASSERT(smp->sm_prev == NULL);
1722 1722 segmapcnt.smp_stolen.value.ul++;
1723 1723 }
1724 1724
1725 1725 } else {
1726 1726 segmapcnt.smp_get_use.value.ul++;
1727 1727 }
1728 1728 smp->sm_refcnt++; /* another user */
1729 1729
1730 1730 /*
1731 1731 * We don't invoke segmap_fault via TLB miss, so we set ref
1732 1732 * and mod bits in advance. For S_OTHER we set them in
1733 1733 * segmap_fault F_SOFTUNLOCK.
1734 1734 */
1735 1735 if (is_kpm) {
1736 1736 if (rw == S_WRITE) {
1737 1737 smp->sm_flags |= SM_WRITE_DATA;
1738 1738 } else if (rw == S_READ) {
1739 1739 smp->sm_flags |= SM_READ_DATA;
1740 1740 }
1741 1741 }
1742 1742 mutex_exit(smapmtx);
1743 1743
1744 1744 newslot = 0;
1745 1745 } else {
1746 1746
1747 1747 uint32_t free_ndx, *free_ndxp;
1748 1748 union segmap_cpu *scpu;
1749 1749
1750 1750 /*
1751 1751 * On a PAC machine or a machine with anti-alias
1752 1752 * hardware, smd_colormsk will be zero.
1753 1753 *
1754 1754 * On a VAC machine- pick color by offset in the file
1755 1755 * so we won't get VAC conflicts on elf files.
1756 1756 * On data files, color does not matter but we
1757 1757 * don't know what kind of file it is so we always
1758 1758 * pick color by offset. This causes color
1759 1759 * corresponding to file offset zero to be used more
1760 1760 * heavily.
1761 1761 */
1762 1762 color = (baseoff >> MAXBSHIFT) & smd_colormsk;
1763 1763 scpu = smd_cpu+CPU->cpu_seqid;
1764 1764 free_ndxp = &scpu->scpu.scpu_free_ndx[color];
1765 1765 free_ndx = (*free_ndxp += smd_ncolor) & smd_freemsk;
1766 1766 #ifdef DEBUG
1767 1767 colors_used[free_ndx]++;
1768 1768 #endif /* DEBUG */
1769 1769
1770 1770 /*
1771 1771 * Get a locked smp slot from the free list.
1772 1772 */
1773 1773 smp = get_free_smp(free_ndx);
1774 1774 smapmtx = SMAPMTX(smp);
1775 1775
1776 1776 ASSERT(smp->sm_vp == NULL);
1777 1777
1778 1778 if ((nsmp = segmap_hashin(smp, vp, baseoff, hashid)) != NULL) {
1779 1779 /*
1780 1780 * Failed to hashin, there exists one now.
1781 1781 * Return the smp we just allocated.
1782 1782 */
1783 1783 segmap_smapadd(smp);
1784 1784 mutex_exit(smapmtx);
1785 1785
1786 1786 smp = nsmp;
1787 1787 goto vrfy_smp;
1788 1788 }
1789 1789 smp->sm_refcnt++; /* another user */
1790 1790
1791 1791 /*
1792 1792 * We don't invoke segmap_fault via TLB miss, so we set ref
1793 1793 * and mod bits in advance. For S_OTHER we set them in
1794 1794 * segmap_fault F_SOFTUNLOCK.
1795 1795 */
1796 1796 if (is_kpm) {
1797 1797 if (rw == S_WRITE) {
1798 1798 smp->sm_flags |= SM_WRITE_DATA;
1799 1799 } else if (rw == S_READ) {
1800 1800 smp->sm_flags |= SM_READ_DATA;
1801 1801 }
1802 1802 }
1803 1803 mutex_exit(smapmtx);
1804 1804
1805 1805 newslot = 1;
1806 1806 }
1807 1807
1808 1808 if (!is_kpm)
1809 1809 goto use_segmap_range;
1810 1810
1811 1811 /*
1812 1812 * Use segkpm
1813 1813 */
1814 1814 /* Lint directive required until 6746211 is fixed */
1815 1815 /*CONSTCOND*/
1816 1816 ASSERT(PAGESIZE == MAXBSIZE);
1817 1817
1818 1818 /*
1819 1819 * remember the last smp faulted on this cpu.
1820 1820 */
1821 1821 (smd_cpu+CPU->cpu_seqid)->scpu.scpu_last_smap = smp;
1822 1822
1823 1823 if (forcefault == SM_PAGECREATE) {
1824 1824 baseaddr = segmap_pagecreate_kpm(seg, vp, baseoff, smp, rw);
1825 1825 return (baseaddr);
1826 1826 }
1827 1827
1828 1828 if (newslot == 0 &&
1829 1829 (pp = GET_KPME(smp)->kpe_page) != NULL) {
1830 1830
1831 1831 /* fastpath */
1832 1832 switch (rw) {
1833 1833 case S_READ:
1834 1834 case S_WRITE:
1835 1835 if (page_trylock(pp, SE_SHARED)) {
1836 1836 if (PP_ISFREE(pp) ||
1837 1837 !(pp->p_vnode == vp &&
1838 1838 pp->p_offset == baseoff)) {
1839 1839 page_unlock(pp);
1840 1840 pp = page_lookup(vp, baseoff,
1841 1841 SE_SHARED);
1842 1842 }
1843 1843 } else {
1844 1844 pp = page_lookup(vp, baseoff, SE_SHARED);
1845 1845 }
1846 1846
1847 1847 if (pp == NULL) {
1848 1848 ASSERT(GET_KPME(smp)->kpe_page == NULL);
1849 1849 break;
1850 1850 }
1851 1851
1852 1852 if (rw == S_WRITE &&
1853 1853 hat_page_getattr(pp, P_MOD | P_REF) !=
1854 1854 (P_MOD | P_REF)) {
1855 1855 page_unlock(pp);
1856 1856 break;
1857 1857 }
1858 1858
1859 1859 /*
1860 1860 * We have the p_selock as reader, grab_smp
1861 1861 * can't hit us, we have bumped the smap
1862 1862 * refcnt and hat_pageunload needs the
1863 1863 * p_selock exclusive.
1864 1864 */
1865 1865 kpme = GET_KPME(smp);
1866 1866 if (kpme->kpe_page == pp) {
1867 1867 baseaddr = hat_kpm_page2va(pp, 0);
1868 1868 } else if (kpme->kpe_page == NULL) {
1869 1869 baseaddr = hat_kpm_mapin(pp, kpme);
1870 1870 } else {
1871 1871 panic("segmap_getmapflt: stale "
1872 1872 "kpme page, kpme %p", (void *)kpme);
1873 1873 /*NOTREACHED*/
1874 1874 }
1875 1875
1876 1876 /*
1877 1877 * We don't invoke segmap_fault via TLB miss,
1878 1878 * so we set ref and mod bits in advance.
1879 1879 * For S_OTHER and we set them in segmap_fault
1880 1880 * F_SOFTUNLOCK.
1881 1881 */
1882 1882 if (rw == S_READ && !hat_isref(pp))
1883 1883 hat_setref(pp);
1884 1884
1885 1885 return (baseaddr);
1886 1886 default:
1887 1887 break;
1888 1888 }
1889 1889 }
1890 1890
1891 1891 base = segkpm_create_va(baseoff);
1892 1892 error = VOP_GETPAGE(vp, (offset_t)baseoff, len, &prot, pl, MAXBSIZE,
1893 1893 seg, base, rw, CRED(), NULL);
1894 1894
1895 1895 pp = pl[0];
1896 1896 if (error || pp == NULL) {
1897 1897 /*
1898 1898 * Use segmap address slot and let segmap_fault deal
1899 1899 * with the error cases. There is no error return
1900 1900 * possible here.
1901 1901 */
1902 1902 goto use_segmap_range;
1903 1903 }
1904 1904
1905 1905 ASSERT(pl[1] == NULL);
1906 1906
1907 1907 /*
1908 1908 * When prot is not returned w/ PROT_ALL the returned pages
1909 1909 * are not backed by fs blocks. For most of the segmap users
1910 1910 * this is no problem, they don't write to the pages in the
1911 1911 * same request and therefore don't rely on a following
1912 1912 * trap driven segmap_fault. With SM_LOCKPROTO users it
1913 1913 * is more secure to use segkmap adresses to allow
1914 1914 * protection segmap_fault's.
1915 1915 */
1916 1916 if (prot != PROT_ALL && forcefault == SM_LOCKPROTO) {
1917 1917 /*
1918 1918 * Use segmap address slot and let segmap_fault
1919 1919 * do the error return.
1920 1920 */
1921 1921 ASSERT(rw != S_WRITE);
1922 1922 ASSERT(PAGE_LOCKED(pp));
1923 1923 page_unlock(pp);
1924 1924 forcefault = 0;
1925 1925 goto use_segmap_range;
1926 1926 }
1927 1927
1928 1928 /*
1929 1929 * We have the p_selock as reader, grab_smp can't hit us, we
1930 1930 * have bumped the smap refcnt and hat_pageunload needs the
1931 1931 * p_selock exclusive.
1932 1932 */
1933 1933 kpme = GET_KPME(smp);
1934 1934 if (kpme->kpe_page == pp) {
1935 1935 baseaddr = hat_kpm_page2va(pp, 0);
1936 1936 } else if (kpme->kpe_page == NULL) {
1937 1937 baseaddr = hat_kpm_mapin(pp, kpme);
1938 1938 } else {
1939 1939 panic("segmap_getmapflt: stale kpme page after "
1940 1940 "VOP_GETPAGE, kpme %p", (void *)kpme);
1941 1941 /*NOTREACHED*/
1942 1942 }
1943 1943
1944 1944 smd_cpu[CPU->cpu_seqid].scpu.scpu_fault++;
1945 1945
1946 1946 return (baseaddr);
1947 1947
1948 1948
1949 1949 use_segmap_range:
1950 1950 baseaddr = seg->s_base + ((smp - smd_smap) * MAXBSIZE);
1951 1951 TRACE_4(TR_FAC_VM, TR_SEGMAP_GETMAP,
1952 1952 "segmap_getmap:seg %p addr %p vp %p offset %llx",
1953 1953 seg, baseaddr, vp, baseoff);
1954 1954
1955 1955 /*
1956 1956 * Prefault the translations
1957 1957 */
1958 1958 vaddr = baseaddr + (off - baseoff);
1959 1959 if (forcefault && (newslot || !hat_probe(kas.a_hat, vaddr))) {
1960 1960
1961 1961 caddr_t pgaddr = (caddr_t)((uintptr_t)vaddr &
1962 1962 (uintptr_t)PAGEMASK);
1963 1963
1964 1964 (void) segmap_fault(kas.a_hat, seg, pgaddr,
1965 1965 (vaddr + len - pgaddr + PAGESIZE - 1) & (uintptr_t)PAGEMASK,
1966 1966 F_INVAL, rw);
1967 1967 }
1968 1968
1969 1969 return (baseaddr);
1970 1970 }
1971 1971
1972 1972 int
1973 1973 segmap_release(struct seg *seg, caddr_t addr, uint_t flags)
1974 1974 {
1975 1975 struct smap *smp;
1976 1976 int error;
1977 1977 int bflags = 0;
1978 1978 struct vnode *vp;
1979 1979 u_offset_t offset;
1980 1980 kmutex_t *smtx;
1981 1981 int is_kpm = 0;
1982 1982 page_t *pp;
1983 1983
1984 1984 if (segmap_kpm && IS_KPM_ADDR(addr)) {
1985 1985
1986 1986 if (((uintptr_t)addr & MAXBOFFSET) != 0) {
1987 1987 panic("segmap_release: addr %p not "
1988 1988 "MAXBSIZE aligned", (void *)addr);
1989 1989 /*NOTREACHED*/
1990 1990 }
1991 1991
1992 1992 if ((smp = get_smap_kpm(addr, &pp)) == NULL) {
1993 1993 panic("segmap_release: smap not found "
1994 1994 "for addr %p", (void *)addr);
1995 1995 /*NOTREACHED*/
1996 1996 }
1997 1997
1998 1998 TRACE_3(TR_FAC_VM, TR_SEGMAP_RELMAP,
1999 1999 "segmap_relmap:seg %p addr %p smp %p",
2000 2000 seg, addr, smp);
2001 2001
2002 2002 smtx = SMAPMTX(smp);
2003 2003
2004 2004 /*
2005 2005 * For compatibility reasons segmap_pagecreate_kpm sets this
2006 2006 * flag to allow a following segmap_pagecreate to return
2007 2007 * this as "newpage" flag. When segmap_pagecreate is not
2008 2008 * called at all we clear it now.
2009 2009 */
2010 2010 smp->sm_flags &= ~SM_KPM_NEWPAGE;
2011 2011 is_kpm = 1;
2012 2012 if (smp->sm_flags & SM_WRITE_DATA) {
2013 2013 hat_setrefmod(pp);
2014 2014 } else if (smp->sm_flags & SM_READ_DATA) {
2015 2015 hat_setref(pp);
2016 2016 }
2017 2017 } else {
2018 2018 if (addr < seg->s_base || addr >= seg->s_base + seg->s_size ||
2019 2019 ((uintptr_t)addr & MAXBOFFSET) != 0) {
2020 2020 panic("segmap_release: bad addr %p", (void *)addr);
2021 2021 /*NOTREACHED*/
2022 2022 }
2023 2023 smp = GET_SMAP(seg, addr);
2024 2024
2025 2025 TRACE_3(TR_FAC_VM, TR_SEGMAP_RELMAP,
2026 2026 "segmap_relmap:seg %p addr %p smp %p",
2027 2027 seg, addr, smp);
2028 2028
2029 2029 smtx = SMAPMTX(smp);
2030 2030 mutex_enter(smtx);
2031 2031 smp->sm_flags |= SM_NOTKPM_RELEASED;
2032 2032 }
2033 2033
2034 2034 ASSERT(smp->sm_refcnt > 0);
2035 2035
2036 2036 /*
2037 2037 * Need to call VOP_PUTPAGE() if any flags (except SM_DONTNEED)
2038 2038 * are set.
2039 2039 */
2040 2040 if ((flags & ~SM_DONTNEED) != 0) {
2041 2041 if (flags & SM_WRITE)
2042 2042 segmapcnt.smp_rel_write.value.ul++;
2043 2043 if (flags & SM_ASYNC) {
2044 2044 bflags |= B_ASYNC;
2045 2045 segmapcnt.smp_rel_async.value.ul++;
2046 2046 }
2047 2047 if (flags & SM_INVAL) {
2048 2048 bflags |= B_INVAL;
2049 2049 segmapcnt.smp_rel_abort.value.ul++;
2050 2050 }
2051 2051 if (flags & SM_DESTROY) {
2052 2052 bflags |= (B_INVAL|B_TRUNC);
2053 2053 segmapcnt.smp_rel_abort.value.ul++;
2054 2054 }
2055 2055 if (smp->sm_refcnt == 1) {
2056 2056 /*
2057 2057 * We only bother doing the FREE and DONTNEED flags
2058 2058 * if no one else is still referencing this mapping.
2059 2059 */
2060 2060 if (flags & SM_FREE) {
2061 2061 bflags |= B_FREE;
2062 2062 segmapcnt.smp_rel_free.value.ul++;
2063 2063 }
2064 2064 if (flags & SM_DONTNEED) {
2065 2065 bflags |= B_DONTNEED;
2066 2066 segmapcnt.smp_rel_dontneed.value.ul++;
2067 2067 }
2068 2068 }
2069 2069 } else {
2070 2070 smd_cpu[CPU->cpu_seqid].scpu.scpu_release++;
2071 2071 }
2072 2072
2073 2073 vp = smp->sm_vp;
2074 2074 offset = smp->sm_off;
2075 2075
2076 2076 if (--smp->sm_refcnt == 0) {
2077 2077
2078 2078 smp->sm_flags &= ~(SM_WRITE_DATA | SM_READ_DATA);
2079 2079
2080 2080 if (flags & (SM_INVAL|SM_DESTROY)) {
2081 2081 segmap_hashout(smp); /* remove map info */
2082 2082 if (is_kpm) {
2083 2083 hat_kpm_mapout(pp, GET_KPME(smp), addr);
2084 2084 if (smp->sm_flags & SM_NOTKPM_RELEASED) {
2085 2085 smp->sm_flags &= ~SM_NOTKPM_RELEASED;
2086 2086 hat_unload(kas.a_hat, segkmap->s_base +
2087 2087 ((smp - smd_smap) * MAXBSIZE),
2088 2088 MAXBSIZE, HAT_UNLOAD);
2089 2089 }
2090 2090
2091 2091 } else {
2092 2092 if (segmap_kpm)
2093 2093 segkpm_mapout_validkpme(GET_KPME(smp));
2094 2094
2095 2095 smp->sm_flags &= ~SM_NOTKPM_RELEASED;
2096 2096 hat_unload(kas.a_hat, addr, MAXBSIZE,
2097 2097 HAT_UNLOAD);
2098 2098 }
2099 2099 }
2100 2100 segmap_smapadd(smp); /* add to free list */
2101 2101 }
2102 2102
2103 2103 mutex_exit(smtx);
2104 2104
2105 2105 if (is_kpm)
2106 2106 page_unlock(pp);
2107 2107 /*
2108 2108 * Now invoke VOP_PUTPAGE() if any flags (except SM_DONTNEED)
2109 2109 * are set.
2110 2110 */
2111 2111 if ((flags & ~SM_DONTNEED) != 0) {
2112 2112 error = VOP_PUTPAGE(vp, offset, MAXBSIZE,
2113 2113 bflags, CRED(), NULL);
2114 2114 } else {
2115 2115 error = 0;
2116 2116 }
2117 2117
2118 2118 return (error);
2119 2119 }
2120 2120
2121 2121 /*
2122 2122 * Dump the pages belonging to this segmap segment.
2123 2123 */
2124 2124 static void
2125 2125 segmap_dump(struct seg *seg)
2126 2126 {
2127 2127 struct segmap_data *smd;
2128 2128 struct smap *smp, *smp_end;
2129 2129 page_t *pp;
2130 2130 pfn_t pfn;
2131 2131 u_offset_t off;
2132 2132 caddr_t addr;
2133 2133
2134 2134 smd = (struct segmap_data *)seg->s_data;
2135 2135 addr = seg->s_base;
2136 2136 for (smp = smd->smd_sm, smp_end = smp + smd->smd_npages;
2137 2137 smp < smp_end; smp++) {
2138 2138
2139 2139 if (smp->sm_refcnt) {
2140 2140 for (off = 0; off < MAXBSIZE; off += PAGESIZE) {
2141 2141 int we_own_it = 0;
2142 2142
2143 2143 /*
2144 2144 * If pp == NULL, the page either does
2145 2145 * not exist or is exclusively locked.
2146 2146 * So determine if it exists before
2147 2147 * searching for it.
2148 2148 */
2149 2149 if ((pp = page_lookup_nowait(smp->sm_vp,
2150 2150 smp->sm_off + off, SE_SHARED)))
2151 2151 we_own_it = 1;
2152 2152 else
2153 2153 pp = page_exists(smp->sm_vp,
2154 2154 smp->sm_off + off);
2155 2155
2156 2156 if (pp) {
2157 2157 pfn = page_pptonum(pp);
2158 2158 dump_addpage(seg->s_as,
2159 2159 addr + off, pfn);
2160 2160 if (we_own_it)
2161 2161 page_unlock(pp);
2162 2162 }
2163 2163 dump_timeleft = dump_timeout;
2164 2164 }
2165 2165 }
2166 2166 addr += MAXBSIZE;
2167 2167 }
2168 2168 }
2169 2169
2170 2170 /*ARGSUSED*/
2171 2171 static int
2172 2172 segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
2173 2173 struct page ***ppp, enum lock_type type, enum seg_rw rw)
2174 2174 {
2175 2175 return (ENOTSUP);
2176 2176 }
2177 2177
2178 2178 static int
2179 2179 segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
2180 2180 {
2181 2181 struct segmap_data *smd = (struct segmap_data *)seg->s_data;
2182 2182
2183 2183 memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
2184 2184 memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);
2185 2185 return (0);
2186 2186 }
2187 2187
2188 2188
2189 2189 #ifdef SEGKPM_SUPPORT
2190 2190
2191 2191 /*
2192 2192 * segkpm support routines
2193 2193 */
2194 2194
2195 2195 static caddr_t
2196 2196 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2197 2197 struct smap *smp, enum seg_rw rw)
2198 2198 {
2199 2199 caddr_t base;
2200 2200 page_t *pp;
2201 2201 int newpage = 0;
2202 2202 struct kpme *kpme;
2203 2203
2204 2204 ASSERT(smp->sm_refcnt > 0);
2205 2205
2206 2206 if ((pp = page_lookup(vp, off, SE_SHARED)) == NULL) {
2207 2207 kmutex_t *smtx;
2208 2208
2209 2209 base = segkpm_create_va(off);
2210 2210
2211 2211 if ((pp = page_create_va(vp, off, PAGESIZE, PG_WAIT,
2212 2212 seg, base)) == NULL) {
2213 2213 panic("segmap_pagecreate_kpm: "
2214 2214 "page_create failed");
2215 2215 /*NOTREACHED*/
2216 2216 }
2217 2217
2218 2218 newpage = 1;
2219 2219 page_io_unlock(pp);
2220 2220 ASSERT((u_offset_t)(off - smp->sm_off) <= INT_MAX);
2221 2221
2222 2222 /*
2223 2223 * Mark this here until the following segmap_pagecreate
2224 2224 * or segmap_release.
2225 2225 */
2226 2226 smtx = SMAPMTX(smp);
2227 2227 mutex_enter(smtx);
2228 2228 smp->sm_flags |= SM_KPM_NEWPAGE;
2229 2229 mutex_exit(smtx);
2230 2230 }
2231 2231
2232 2232 kpme = GET_KPME(smp);
2233 2233 if (!newpage && kpme->kpe_page == pp)
2234 2234 base = hat_kpm_page2va(pp, 0);
2235 2235 else
2236 2236 base = hat_kpm_mapin(pp, kpme);
2237 2237
2238 2238 /*
2239 2239 * FS code may decide not to call segmap_pagecreate and we
2240 2240 * don't invoke segmap_fault via TLB miss, so we have to set
2241 2241 * ref and mod bits in advance.
2242 2242 */
2243 2243 if (rw == S_WRITE) {
2244 2244 hat_setrefmod(pp);
2245 2245 } else {
2246 2246 ASSERT(rw == S_READ);
2247 2247 hat_setref(pp);
2248 2248 }
2249 2249
2250 2250 smd_cpu[CPU->cpu_seqid].scpu.scpu_pagecreate++;
2251 2251
2252 2252 return (base);
2253 2253 }
2254 2254
2255 2255 /*
2256 2256 * Find the smap structure corresponding to the
2257 2257 * KPM addr and return it locked.
2258 2258 */
2259 2259 struct smap *
2260 2260 get_smap_kpm(caddr_t addr, page_t **ppp)
2261 2261 {
2262 2262 struct smap *smp;
2263 2263 struct vnode *vp;
2264 2264 u_offset_t offset;
2265 2265 caddr_t baseaddr = (caddr_t)((uintptr_t)addr & MAXBMASK);
2266 2266 int hashid;
2267 2267 kmutex_t *hashmtx;
2268 2268 page_t *pp;
2269 2269 union segmap_cpu *scpu;
2270 2270
2271 2271 pp = hat_kpm_vaddr2page(baseaddr);
2272 2272
2273 2273 ASSERT(pp && !PP_ISFREE(pp));
2274 2274 ASSERT(PAGE_LOCKED(pp));
2275 2275 ASSERT(((uintptr_t)pp->p_offset & MAXBOFFSET) == 0);
2276 2276
2277 2277 vp = pp->p_vnode;
2278 2278 offset = pp->p_offset;
2279 2279 ASSERT(vp != NULL);
2280 2280
2281 2281 /*
2282 2282 * Assume the last smap used on this cpu is the one needed.
2283 2283 */
2284 2284 scpu = smd_cpu+CPU->cpu_seqid;
2285 2285 smp = scpu->scpu.scpu_last_smap;
2286 2286 mutex_enter(&smp->sm_mtx);
2287 2287 if (smp->sm_vp == vp && smp->sm_off == offset) {
2288 2288 ASSERT(smp->sm_refcnt > 0);
2289 2289 } else {
2290 2290 /*
2291 2291 * Assumption wrong, find the smap on the hash chain.
2292 2292 */
2293 2293 mutex_exit(&smp->sm_mtx);
2294 2294 SMAP_HASHFUNC(vp, offset, hashid); /* macro assigns hashid */
2295 2295 hashmtx = SHASHMTX(hashid);
2296 2296
2297 2297 mutex_enter(hashmtx);
2298 2298 smp = smd_hash[hashid].sh_hash_list;
2299 2299 for (; smp != NULL; smp = smp->sm_hash) {
2300 2300 if (smp->sm_vp == vp && smp->sm_off == offset)
2301 2301 break;
2302 2302 }
2303 2303 mutex_exit(hashmtx);
2304 2304 if (smp) {
2305 2305 mutex_enter(&smp->sm_mtx);
2306 2306 ASSERT(smp->sm_vp == vp && smp->sm_off == offset);
2307 2307 }
2308 2308 }
2309 2309
2310 2310 if (ppp)
2311 2311 *ppp = smp ? pp : NULL;
2312 2312
2313 2313 return (smp);
2314 2314 }
2315 2315
2316 2316 #else /* SEGKPM_SUPPORT */
2317 2317
2318 2318 /* segkpm stubs */
2319 2319
2320 2320 /*ARGSUSED*/
2321 2321 static caddr_t
2322 2322 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2323 2323 struct smap *smp, enum seg_rw rw)
2324 2324 {
2325 2325 return (NULL);
2326 2326 }
2327 2327
2328 2328 /*ARGSUSED*/
2329 2329 struct smap *
2330 2330 get_smap_kpm(caddr_t addr, page_t **ppp)
2331 2331 {
2332 2332 return (NULL);
2333 2333 }
2334 2334
2335 2335 #endif /* SEGKPM_SUPPORT */
↓ open down ↓ |
2225 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX