69 * the system) they can patch the segspt_minfree to smaller number.
70 */
71 pgcnt_t segspt_minfree = 0;
72
73 static int segspt_create(struct seg *seg, caddr_t argsp);
74 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
75 static void segspt_free(struct seg *seg);
76 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
77 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
78
79 static void
80 segspt_badop()
81 {
82 panic("segspt_badop called");
83 /*NOTREACHED*/
84 }
85
86 #define SEGSPT_BADOP(t) (t(*)())segspt_badop
87
88 struct seg_ops segspt_ops = {
89 SEGSPT_BADOP(int), /* dup */
90 segspt_unmap,
91 segspt_free,
92 SEGSPT_BADOP(int), /* fault */
93 SEGSPT_BADOP(faultcode_t), /* faulta */
94 SEGSPT_BADOP(int), /* setprot */
95 SEGSPT_BADOP(int), /* checkprot */
96 SEGSPT_BADOP(int), /* kluster */
97 SEGSPT_BADOP(size_t), /* swapout */
98 SEGSPT_BADOP(int), /* sync */
99 SEGSPT_BADOP(size_t), /* incore */
100 SEGSPT_BADOP(int), /* lockop */
101 SEGSPT_BADOP(int), /* getprot */
102 SEGSPT_BADOP(u_offset_t), /* getoffset */
103 SEGSPT_BADOP(int), /* gettype */
104 SEGSPT_BADOP(int), /* getvp */
105 SEGSPT_BADOP(int), /* advise */
106 SEGSPT_BADOP(void), /* dump */
107 SEGSPT_BADOP(int), /* pagelock */
108 SEGSPT_BADOP(int), /* setpgsz */
109 SEGSPT_BADOP(int), /* getmemid */
110 segspt_getpolicy, /* getpolicy */
111 SEGSPT_BADOP(int), /* capable */
112 seg_inherit_notsup /* inherit */
113 };
114
115 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
116 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
117 static void segspt_shmfree(struct seg *seg);
118 static faultcode_t segspt_shmfault(struct hat *hat, struct seg *seg,
119 caddr_t addr, size_t len, enum fault_type type, enum seg_rw rw);
120 static faultcode_t segspt_shmfaulta(struct seg *seg, caddr_t addr);
121 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
122 register size_t len, register uint_t prot);
123 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
124 uint_t prot);
125 static int segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
126 static size_t segspt_shmswapout(struct seg *seg);
127 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
128 register char *vec);
129 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
130 int attr, uint_t flags);
131 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
132 int attr, int op, ulong_t *lockmap, size_t pos);
133 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
134 uint_t *protv);
135 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
136 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
137 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
138 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
139 uint_t behav);
140 static void segspt_shmdump(struct seg *seg);
141 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
142 struct page ***, enum lock_type, enum seg_rw);
143 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
144 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
145 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
146 static int segspt_shmcapable(struct seg *, segcapability_t);
147
148 struct seg_ops segspt_shmops = {
149 segspt_shmdup,
150 segspt_shmunmap,
151 segspt_shmfree,
152 segspt_shmfault,
153 segspt_shmfaulta,
154 segspt_shmsetprot,
155 segspt_shmcheckprot,
156 segspt_shmkluster,
157 segspt_shmswapout,
158 segspt_shmsync,
159 segspt_shmincore,
160 segspt_shmlockop,
161 segspt_shmgetprot,
162 segspt_shmgetoffset,
163 segspt_shmgettype,
164 segspt_shmgetvp,
165 segspt_shmadvise, /* advise */
166 segspt_shmdump,
167 segspt_shmpagelock,
168 segspt_shmsetpgsz,
169 segspt_shmgetmemid,
170 segspt_shmgetpolicy,
171 segspt_shmcapable,
172 seg_inherit_notsup
173 };
174
175 static void segspt_purge(struct seg *seg);
176 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
177 enum seg_rw, int);
178 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
179 page_t **ppa);
180
181
182
183 /*ARGSUSED*/
184 int
185 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
186 uint_t prot, uint_t flags, uint_t share_szc)
187 {
188 int err;
189 struct as *newas;
190 struct segspt_crargs sptcargs;
191
192 #ifdef DEBUG
|
69 * the system) they can patch the segspt_minfree to smaller number.
70 */
71 pgcnt_t segspt_minfree = 0;
72
73 static int segspt_create(struct seg *seg, caddr_t argsp);
74 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
75 static void segspt_free(struct seg *seg);
76 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
77 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
78
79 static void
80 segspt_badop()
81 {
82 panic("segspt_badop called");
83 /*NOTREACHED*/
84 }
85
86 #define SEGSPT_BADOP(t) (t(*)())segspt_badop
87
88 struct seg_ops segspt_ops = {
89 .dup = SEGSPT_BADOP(int),
90 .unmap = segspt_unmap,
91 .free = segspt_free,
92 .fault = SEGSPT_BADOP(int),
93 .faulta = SEGSPT_BADOP(faultcode_t),
94 .setprot = SEGSPT_BADOP(int),
95 .checkprot = SEGSPT_BADOP(int),
96 .kluster = SEGSPT_BADOP(int),
97 .swapout = SEGSPT_BADOP(size_t),
98 .sync = SEGSPT_BADOP(int),
99 .incore = SEGSPT_BADOP(size_t),
100 .lockop = SEGSPT_BADOP(int),
101 .getprot = SEGSPT_BADOP(int),
102 .getoffset = SEGSPT_BADOP(u_offset_t),
103 .gettype = SEGSPT_BADOP(int),
104 .getvp = SEGSPT_BADOP(int),
105 .advise = SEGSPT_BADOP(int),
106 .dump = SEGSPT_BADOP(void),
107 .pagelock = SEGSPT_BADOP(int),
108 .setpagesize = SEGSPT_BADOP(int),
109 .getmemid = SEGSPT_BADOP(int),
110 .getpolicy = segspt_getpolicy,
111 .capable = SEGSPT_BADOP(int),
112 .inherit = seg_inherit_notsup,
113 };
114
115 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
116 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
117 static void segspt_shmfree(struct seg *seg);
118 static faultcode_t segspt_shmfault(struct hat *hat, struct seg *seg,
119 caddr_t addr, size_t len, enum fault_type type, enum seg_rw rw);
120 static faultcode_t segspt_shmfaulta(struct seg *seg, caddr_t addr);
121 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
122 register size_t len, register uint_t prot);
123 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
124 uint_t prot);
125 static int segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
126 static size_t segspt_shmswapout(struct seg *seg);
127 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
128 register char *vec);
129 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
130 int attr, uint_t flags);
131 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
132 int attr, int op, ulong_t *lockmap, size_t pos);
133 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
134 uint_t *protv);
135 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
136 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
137 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
138 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
139 uint_t behav);
140 static void segspt_shmdump(struct seg *seg);
141 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
142 struct page ***, enum lock_type, enum seg_rw);
143 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
144 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
145 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
146 static int segspt_shmcapable(struct seg *, segcapability_t);
147
148 struct seg_ops segspt_shmops = {
149 .dup = segspt_shmdup,
150 .unmap = segspt_shmunmap,
151 .free = segspt_shmfree,
152 .fault = segspt_shmfault,
153 .faulta = segspt_shmfaulta,
154 .setprot = segspt_shmsetprot,
155 .checkprot = segspt_shmcheckprot,
156 .kluster = segspt_shmkluster,
157 .swapout = segspt_shmswapout,
158 .sync = segspt_shmsync,
159 .incore = segspt_shmincore,
160 .lockop = segspt_shmlockop,
161 .getprot = segspt_shmgetprot,
162 .getoffset = segspt_shmgetoffset,
163 .gettype = segspt_shmgettype,
164 .getvp = segspt_shmgetvp,
165 .advise = segspt_shmadvise,
166 .dump = segspt_shmdump,
167 .pagelock = segspt_shmpagelock,
168 .setpagesize = segspt_shmsetpgsz,
169 .getmemid = segspt_shmgetmemid,
170 .getpolicy = segspt_shmgetpolicy,
171 .capable = segspt_shmcapable,
172 .inherit = seg_inherit_notsup,
173 };
174
175 static void segspt_purge(struct seg *seg);
176 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
177 enum seg_rw, int);
178 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
179 page_t **ppa);
180
181
182
183 /*ARGSUSED*/
184 int
185 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
186 uint_t prot, uint_t flags, uint_t share_szc)
187 {
188 int err;
189 struct as *newas;
190 struct segspt_crargs sptcargs;
191
192 #ifdef DEBUG
|