Lines Matching refs:seg
35 #include <vm/seg.h>
74 static int segspt_create(struct seg *seg, caddr_t argsp);
75 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
76 static void segspt_free(struct seg *seg);
77 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
78 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
116 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
117 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
118 static void segspt_shmfree(struct seg *seg);
119 static faultcode_t segspt_shmfault(struct hat *hat, struct seg *seg,
121 static faultcode_t segspt_shmfaulta(struct seg *seg, caddr_t addr);
122 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
124 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
126 static int segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
127 static size_t segspt_shmswapout(struct seg *seg);
128 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
130 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
132 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
134 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
136 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
137 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
138 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
139 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
141 static void segspt_shmdump(struct seg *seg);
142 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
144 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
145 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
146 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
147 static int segspt_shmcapable(struct seg *, segcapability_t);
176 static void segspt_purge(struct seg *seg);
179 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
186 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
238 * all the pages in the given seg.
241 segspt_free(struct seg *seg)
243 struct spt_data *sptd = (struct spt_data *)seg->s_data;
245 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
249 segspt_free_pages(seg, seg->s_base, sptd->spt_realsize);
264 segspt_shmsync(struct seg *seg, caddr_t addr, size_t len, int attr,
267 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
274 segspt_shmincore(struct seg *seg, caddr_t addr, size_t len, char *vec)
278 struct shm_data *shmd = (struct shm_data *)seg->s_data;
279 struct seg *sptseg;
282 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
284 seg = seg;
310 anon_index = seg_page(seg, addr);
342 segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize)
346 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
349 * seg.s_size may have been rounded up to the largest page size
359 share_size = page_get_pagesize(seg->s_szc);
362 if (raddr == seg->s_base && ssize == seg->s_size) {
363 seg_free(seg);
370 segspt_create(struct seg *seg, caddr_t argsp)
373 caddr_t addr = seg->s_base;
397 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
402 tnf_opaque, addr, addr, tnf_ulong, len, seg->s_size);
424 seg->s_ops = &segspt_ops;
429 seg->s_data = (caddr_t)sptd;
432 seg->s_szc = sptcargs->szc;
437 if (seg->s_szc > amp->a_szc) {
438 amp->a_szc = seg->s_szc;
455 share_sz = page_get_pagesize(seg->s_szc);
495 sptcargs->seg_spt = seg;
503 seg, addr, S_CREATE, cred)) != 0)
566 pgsz = page_get_pagesize(seg->s_szc);
567 pgcnt = page_get_pagecnt(seg->s_szc);
570 hat_memload_array(seg->s_as->a_hat, a, sz,
594 sptcargs->seg_spt = seg;
598 seg->s_data = NULL;
615 segspt_free_pages(struct seg *seg, caddr_t addr, size_t len)
618 struct spt_data *sptd = (struct spt_data *)seg->s_data;
633 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
645 hat_unload(seg->s_as->a_hat, addr, len, hat_flags);
779 segspt_getpolicy(struct seg *seg, caddr_t addr)
786 ASSERT(seg != NULL);
796 spt_data = (struct spt_data *)seg->s_data;
807 anon_index = seg_page(seg, addr);
824 segspt_dismpagelock(struct seg *seg, caddr_t addr, size_t len,
827 struct shm_data *shmd = (struct shm_data *)seg->s_data;
828 struct seg *sptseg = shmd->shm_sptseg;
842 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
853 pg_idx = seg_page(seg, addr);
868 seg_pinactive(seg, NULL, seg->s_base, sptd->spt_amp->size,
880 (AS_ISUNMAPWAIT(seg->s_as) &&
882 segspt_purge(seg);
890 segspt_purge(seg);
903 pplist = seg_plookup(seg, NULL, seg->s_base, sptd->spt_amp->size,
911 seg_pinactive(seg, NULL, seg->s_base,
937 pplist = seg_plookup(seg, NULL, seg->s_base, sptd->spt_amp->size,
946 seg_pinactive(seg, NULL, seg->s_base,
968 if (seg_pinsert_check(seg, NULL, seg->s_base, sptd->spt_amp->size,
1070 ret = seg_pinsert(seg, NULL, seg->s_base, sptd->spt_amp->size,
1100 seg_pinactive(seg, NULL, seg->s_base,
1131 * And we can drop the lock on the dummy seg, once we've failed
1155 if (AS_ISUNMAPWAIT(seg->s_as)) {
1156 mutex_enter(&seg->s_as->a_contents);
1157 if (AS_ISUNMAPWAIT(seg->s_as)) {
1158 AS_CLRUNMAPWAIT(seg->s_as);
1159 cv_broadcast(&seg->s_as->a_cv);
1161 mutex_exit(&seg->s_as->a_contents);
1180 segspt_shmpagelock(struct seg *seg, caddr_t addr, size_t len,
1183 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1184 struct seg *sptseg = shmd->shm_sptseg;
1197 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
1210 return (segspt_dismpagelock(seg, addr, len, ppp, type, rw));
1213 page_index = seg_page(seg, addr);
1229 seg_pinactive(seg, NULL, seg->s_base, sptd->spt_amp->size,
1240 if (AS_ISUNMAPWAIT(seg->s_as) && (shmd->shm_softlockcnt > 0)) {
1241 segspt_purge(seg);
1252 pplist = seg_plookup(seg, NULL, seg->s_base, sptd->spt_amp->size,
1271 pplist = seg_plookup(seg, NULL, seg->s_base, sptd->spt_amp->size,
1285 if (seg_pinsert_check(seg, NULL, seg->s_base, sptd->spt_amp->size,
1349 ret = seg_pinsert(seg, NULL, seg->s_base, sptd->spt_amp->size,
1393 * And we can drop the lock on the dummy seg, once we've failed
1412 if (AS_ISUNMAPWAIT(seg->s_as)) {
1413 mutex_enter(&seg->s_as->a_contents);
1414 if (AS_ISUNMAPWAIT(seg->s_as)) {
1415 AS_CLRUNMAPWAIT(seg->s_as);
1416 cv_broadcast(&seg->s_as->a_cv);
1418 mutex_exit(&seg->s_as->a_contents);
1429 segspt_purge(struct seg *seg)
1431 seg_ppurge(seg, NULL, SEGP_FORCE_WIRED);
1438 struct seg *seg = (struct seg *)ptag;
1439 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1440 struct seg *sptseg;
1455 ASSERT(async || AS_LOCK_HELD(seg->s_as));
1458 * Acquire the lock on the dummy seg and destroy the
1528 if (async || AS_ISUNMAPWAIT(seg->s_as)) {
1529 mutex_enter(&seg->s_as->a_contents);
1531 AS_SETNOUNMAPWAIT(seg->s_as);
1532 if (AS_ISUNMAPWAIT(seg->s_as)) {
1533 AS_CLRUNMAPWAIT(seg->s_as);
1534 cv_broadcast(&seg->s_as->a_cv);
1536 mutex_exit(&seg->s_as->a_contents);
1574 segspt_softunlock(struct seg *seg, caddr_t sptseg_addr,
1577 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1578 struct seg *sptseg;
1589 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
1606 * page_unlock() on the pages within this seg.
1660 if (AS_ISUNMAPWAIT(seg->s_as)) {
1661 mutex_enter(&seg->s_as->a_contents);
1662 if (AS_ISUNMAPWAIT(seg->s_as)) {
1663 AS_CLRUNMAPWAIT(seg->s_as);
1664 cv_broadcast(&seg->s_as->a_cv);
1666 mutex_exit(&seg->s_as->a_contents);
1672 segspt_shmattach(struct seg *seg, caddr_t *argsp)
1680 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
1691 NULL, 0, seg->s_size);
1695 seg->s_data = (void *)shmd;
1696 seg->s_ops = &segspt_shmops;
1697 seg->s_szc = shmd->shm_sptseg->s_szc;
1703 seg->s_data = (void *)NULL;
1709 if ((error = hat_share(seg->s_as->a_hat, seg->s_base,
1711 seg->s_size, seg->s_szc)) != 0) {
1717 error = hat_share(seg->s_as->a_hat, seg->s_base,
1719 seg->s_size, seg->s_szc);
1722 seg->s_szc = 0;
1723 seg->s_data = (void *)NULL;
1734 segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize)
1736 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1739 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
1743 segspt_purge(seg);
1750 if (ssize != seg->s_size) {
1753 ssize, seg->s_size);
1758 (void) segspt_shmlockop(seg, raddr, shmd->shm_amp->size, 0, MC_UNLOCK,
1760 hat_unshare(seg->s_as->a_hat, raddr, ssize, seg->s_szc);
1762 seg_free(seg);
1768 segspt_shmfree(struct seg *seg)
1770 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1773 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
1775 (void) segspt_shmlockop(seg, seg->s_base, shm_amp->size, 0,
1804 segspt_shmsetprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
1806 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
1821 segspt_dismfault(struct hat *hat, struct seg *seg, caddr_t addr,
1824 struct shm_data *shmd = (struct shm_data *)seg->s_data;
1825 struct seg *sptseg = shmd->shm_sptseg;
1844 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
1856 ASSERT(addr >= seg->s_base);
1857 if (((addr + len) - seg->s_base) > sptd->spt_realsize)
1881 an_idx = seg_page(seg, shm_addr);
1932 page_migrate(seg, shm_addr, ppa, npages);
1952 if (hat_share(seg->s_as->a_hat, shm_addr,
1954 seg->s_szc) != 0) {
1972 * This is a bit ugly, we pass in the real seg pointer,
1974 * dummy seg.
1976 segspt_softunlock(seg, segspt_addr, size, rw);
2004 segspt_shmfault(struct hat *hat, struct seg *seg, caddr_t addr,
2007 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2008 struct seg *sptseg = shmd->shm_sptseg;
2031 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2034 return (segspt_dismfault(hat, seg, addr, len, type, rw));
2047 ASSERT(addr >= seg->s_base);
2048 if (((addr + len) - seg->s_base) > sptd->spt_realsize)
2072 anon_index = seg_page(seg, shm_addr);
2124 if (hat_share(seg->s_as->a_hat, seg->s_base,
2135 * I see no need to lock the real seg,
2137 * dummy seg.
2182 page_migrate(seg, shm_addr, ppa, npages);
2204 * This is a bit ugly, we pass in the real seg pointer,
2206 * dummy seg.
2208 segspt_softunlock(seg, sptseg_addr, ptob(npages), rw);
2235 segspt_shmfaulta(struct seg *seg, caddr_t addr)
2242 segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta)
2249 segspt_shmswapout(struct seg *seg)
2258 segspt_shmdup(struct seg *seg, struct seg *newseg)
2260 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2263 struct seg *spt_seg = shmd->shm_sptseg;
2267 ASSERT(seg->s_as && AS_WRITE_HELD(seg->s_as));
2275 newseg->s_szc = seg->s_szc;
2276 ASSERT(seg->s_szc == shmd->shm_sptseg->s_szc);
2288 seg->s_size, seg->s_szc)) != 0) {
2296 shmd->shm_sptas->a_hat, SEGSPTADDR, seg->s_size,
2297 seg->s_szc));
2304 segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size, uint_t prot)
2306 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2309 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2323 struct seg *sptseg,
2419 * than 0 or seg->s_szc. This could be due
2479 spt_lockpages(struct seg *seg, pgcnt_t anon_index, pgcnt_t npages,
2483 struct shm_data *shmd = seg->s_data;
2567 spt_unlockpages(struct seg *seg, pgcnt_t anon_index, pgcnt_t npages,
2570 struct shm_data *shmd = seg->s_data;
2596 * in seg pcache, for pages in seg pcache availrmem was
2640 segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
2643 struct shm_data *shmd = seg->s_data;
2644 struct seg *sptseg = shmd->shm_sptseg;
2660 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2668 an_idx = seg_page(seg, addr);
2695 a_an_idx = seg_page(seg, a_addr);
2729 sts = spt_lockpages(seg, an_idx, npages,
2768 sts = spt_unlockpages(seg, an_idx, npages, &unlocked);
2784 segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
2786 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2788 spgcnt_t pgno = seg_page(seg, addr+len) - seg_page(seg, addr) + 1;
2790 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2802 segspt_shmgetoffset(struct seg *seg, caddr_t addr)
2804 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2813 segspt_shmgettype(struct seg *seg, caddr_t addr)
2815 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2818 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2830 segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
2832 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2835 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2850 segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len, uint_t behav)
2852 struct shm_data *shmd = (struct shm_data *)seg->s_data;
2861 ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
2868 pg_idx = seg_page(seg, addr);
2895 writer = AS_WRITE_HELD(seg->s_as);
2897 AS_LOCK_EXIT(seg->s_as);
2918 AS_LOCK_ENTER(seg->s_as, writer ? RW_WRITER : RW_READER);
2921 if (AS_ISUNMAPWAIT(seg->s_as)) {
2922 mutex_enter(&seg->s_as->a_contents);
2923 if (AS_ISUNMAPWAIT(seg->s_as)) {
2924 AS_CLRUNMAPWAIT(seg->s_as);
2925 cv_broadcast(&seg->s_as->a_cv);
2927 mutex_exit(&seg->s_as->a_contents);
2942 struct seg *sptseg = shmd->shm_sptseg;
2954 anon_index = seg_page(seg, shm_addr);
2988 segspt_purge(seg);
2990 page_mark_migrate(seg, shm_addr, size, amp, 0, NULL, 0, 0);
2998 segspt_shmdump(struct seg *seg)
3005 segspt_shmsetpgsz(struct seg *seg, caddr_t addr, size_t len, uint_t szc)
3014 segspt_shmgetmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
3016 struct shm_data *shmd = (struct shm_data *)seg->s_data;
3021 struct seg *sptseg = shmd->shm_sptseg;
3024 anon_index = seg_page(seg, addr);
3026 if (addr > (seg->s_base + sptd->spt_realsize)) {
3057 segspt_shmgetpolicy(struct seg *seg, caddr_t addr)
3064 ASSERT(seg != NULL);
3074 shm_data = (struct shm_data *)seg->s_data;
3085 anon_index = seg_page(seg, addr);
3093 segspt_shmcapable(struct seg *seg, segcapability_t capability)