uvm_pdpolicy_clock.c revision 1.1.6.2 1 1.1.6.2 ad /* $NetBSD: uvm_pdpolicy_clock.c,v 1.1.6.2 2007/02/01 08:48:52 ad Exp $ */
2 1.1.6.1 ad /* NetBSD: uvm_pdaemon.c,v 1.72 2006/01/05 10:47:33 yamt Exp $ */
3 1.1.6.1 ad
4 1.1.6.1 ad /*
5 1.1.6.1 ad * Copyright (c) 1997 Charles D. Cranor and Washington University.
6 1.1.6.1 ad * Copyright (c) 1991, 1993, The Regents of the University of California.
7 1.1.6.1 ad *
8 1.1.6.1 ad * All rights reserved.
9 1.1.6.1 ad *
10 1.1.6.1 ad * This code is derived from software contributed to Berkeley by
11 1.1.6.1 ad * The Mach Operating System project at Carnegie-Mellon University.
12 1.1.6.1 ad *
13 1.1.6.1 ad * Redistribution and use in source and binary forms, with or without
14 1.1.6.1 ad * modification, are permitted provided that the following conditions
15 1.1.6.1 ad * are met:
16 1.1.6.1 ad * 1. Redistributions of source code must retain the above copyright
17 1.1.6.1 ad * notice, this list of conditions and the following disclaimer.
18 1.1.6.1 ad * 2. Redistributions in binary form must reproduce the above copyright
19 1.1.6.1 ad * notice, this list of conditions and the following disclaimer in the
20 1.1.6.1 ad * documentation and/or other materials provided with the distribution.
21 1.1.6.1 ad * 3. All advertising materials mentioning features or use of this software
22 1.1.6.1 ad * must display the following acknowledgement:
23 1.1.6.1 ad * This product includes software developed by Charles D. Cranor,
24 1.1.6.1 ad * Washington University, the University of California, Berkeley and
25 1.1.6.1 ad * its contributors.
26 1.1.6.1 ad * 4. Neither the name of the University nor the names of its contributors
27 1.1.6.1 ad * may be used to endorse or promote products derived from this software
28 1.1.6.1 ad * without specific prior written permission.
29 1.1.6.1 ad *
30 1.1.6.1 ad * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 1.1.6.1 ad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 1.1.6.1 ad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 1.1.6.1 ad * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 1.1.6.1 ad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 1.1.6.1 ad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 1.1.6.1 ad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 1.1.6.1 ad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 1.1.6.1 ad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 1.1.6.1 ad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 1.1.6.1 ad * SUCH DAMAGE.
41 1.1.6.1 ad *
42 1.1.6.1 ad * @(#)vm_pageout.c 8.5 (Berkeley) 2/14/94
43 1.1.6.1 ad * from: Id: uvm_pdaemon.c,v 1.1.2.32 1998/02/06 05:26:30 chs Exp
44 1.1.6.1 ad *
45 1.1.6.1 ad *
46 1.1.6.1 ad * Copyright (c) 1987, 1990 Carnegie-Mellon University.
47 1.1.6.1 ad * All rights reserved.
48 1.1.6.1 ad *
49 1.1.6.1 ad * Permission to use, copy, modify and distribute this software and
50 1.1.6.1 ad * its documentation is hereby granted, provided that both the copyright
51 1.1.6.1 ad * notice and this permission notice appear in all copies of the
52 1.1.6.1 ad * software, derivative works or modified versions, and any portions
53 1.1.6.1 ad * thereof, and that both notices appear in supporting documentation.
54 1.1.6.1 ad *
55 1.1.6.1 ad * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
56 1.1.6.1 ad * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
57 1.1.6.1 ad * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
58 1.1.6.1 ad *
59 1.1.6.1 ad * Carnegie Mellon requests users of this software to return to
60 1.1.6.1 ad *
61 1.1.6.1 ad * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
62 1.1.6.1 ad * School of Computer Science
63 1.1.6.1 ad * Carnegie Mellon University
64 1.1.6.1 ad * Pittsburgh PA 15213-3890
65 1.1.6.1 ad *
66 1.1.6.1 ad * any improvements or extensions that they make and grant Carnegie the
67 1.1.6.1 ad * rights to redistribute these changes.
68 1.1.6.1 ad */
69 1.1.6.1 ad
70 1.1.6.1 ad #if defined(PDSIM)
71 1.1.6.1 ad
72 1.1.6.1 ad #include "pdsim.h"
73 1.1.6.1 ad
74 1.1.6.1 ad #else /* defined(PDSIM) */
75 1.1.6.1 ad
76 1.1.6.1 ad #include <sys/cdefs.h>
77 1.1.6.2 ad __KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.1.6.2 2007/02/01 08:48:52 ad Exp $");
78 1.1.6.1 ad
79 1.1.6.1 ad #include <sys/param.h>
80 1.1.6.1 ad #include <sys/proc.h>
81 1.1.6.1 ad #include <sys/systm.h>
82 1.1.6.1 ad #include <sys/kernel.h>
83 1.1.6.1 ad
84 1.1.6.1 ad #include <uvm/uvm.h>
85 1.1.6.1 ad #include <uvm/uvm_pdpolicy.h>
86 1.1.6.1 ad #include <uvm/uvm_pdpolicy_impl.h>
87 1.1.6.1 ad
88 1.1.6.1 ad #endif /* defined(PDSIM) */
89 1.1.6.1 ad
90 1.1.6.1 ad #define PQ_INACTIVE PQ_PRIVATE1 /* page is in inactive list */
91 1.1.6.1 ad #define PQ_ACTIVE PQ_PRIVATE2 /* page is in active list */
92 1.1.6.1 ad
93 1.1.6.1 ad #if !defined(CLOCK_INACTIVEPCT)
94 1.1.6.1 ad #define CLOCK_INACTIVEPCT 33
95 1.1.6.1 ad #endif /* !defined(CLOCK_INACTIVEPCT) */
96 1.1.6.1 ad
97 1.1.6.1 ad struct uvmpdpol_globalstate {
98 1.1.6.1 ad struct pglist s_activeq; /* allocated pages, in use */
99 1.1.6.1 ad struct pglist s_inactiveq; /* pages between the clock hands */
100 1.1.6.1 ad int s_active;
101 1.1.6.1 ad int s_inactive;
102 1.1.6.1 ad int s_inactarg;
103 1.1.6.1 ad struct uvm_pctparam s_anonmin;
104 1.1.6.1 ad struct uvm_pctparam s_filemin;
105 1.1.6.1 ad struct uvm_pctparam s_execmin;
106 1.1.6.1 ad struct uvm_pctparam s_anonmax;
107 1.1.6.1 ad struct uvm_pctparam s_filemax;
108 1.1.6.1 ad struct uvm_pctparam s_execmax;
109 1.1.6.1 ad struct uvm_pctparam s_inactivepct;
110 1.1.6.1 ad };
111 1.1.6.1 ad
112 1.1.6.1 ad struct uvmpdpol_scanstate {
113 1.1.6.1 ad boolean_t ss_first;
114 1.1.6.1 ad boolean_t ss_anonreact, ss_filereact, ss_execreact;
115 1.1.6.1 ad struct vm_page *ss_nextpg;
116 1.1.6.1 ad };
117 1.1.6.1 ad
118 1.1.6.1 ad static struct uvmpdpol_globalstate pdpol_state;
119 1.1.6.1 ad static struct uvmpdpol_scanstate pdpol_scanstate;
120 1.1.6.1 ad
121 1.1.6.1 ad PDPOL_EVCNT_DEFINE(reactexec)
122 1.1.6.1 ad PDPOL_EVCNT_DEFINE(reactfile)
123 1.1.6.1 ad PDPOL_EVCNT_DEFINE(reactanon)
124 1.1.6.1 ad
125 1.1.6.1 ad static void
126 1.1.6.1 ad clock_tune(void)
127 1.1.6.1 ad {
128 1.1.6.1 ad struct uvmpdpol_globalstate *s = &pdpol_state;
129 1.1.6.1 ad
130 1.1.6.1 ad s->s_inactarg = UVM_PCTPARAM_APPLY(&s->s_inactivepct,
131 1.1.6.1 ad s->s_active + s->s_inactive);
132 1.1.6.1 ad if (s->s_inactarg <= uvmexp.freetarg) {
133 1.1.6.1 ad s->s_inactarg = uvmexp.freetarg + 1;
134 1.1.6.1 ad }
135 1.1.6.1 ad }
136 1.1.6.1 ad
137 1.1.6.1 ad void
138 1.1.6.1 ad uvmpdpol_scaninit(void)
139 1.1.6.1 ad {
140 1.1.6.1 ad struct uvmpdpol_globalstate *s = &pdpol_state;
141 1.1.6.1 ad struct uvmpdpol_scanstate *ss = &pdpol_scanstate;
142 1.1.6.1 ad int t;
143 1.1.6.1 ad boolean_t anonunder, fileunder, execunder;
144 1.1.6.1 ad boolean_t anonover, fileover, execover;
145 1.1.6.1 ad boolean_t anonreact, filereact, execreact;
146 1.1.6.1 ad
147 1.1.6.1 ad /*
148 1.1.6.1 ad * decide which types of pages we want to reactivate instead of freeing
149 1.1.6.1 ad * to keep usage within the minimum and maximum usage limits.
150 1.1.6.1 ad */
151 1.1.6.1 ad
152 1.1.6.1 ad t = s->s_active + s->s_inactive + uvmexp.free;
153 1.1.6.1 ad anonunder = uvmexp.anonpages <= UVM_PCTPARAM_APPLY(&s->s_anonmin, t);
154 1.1.6.1 ad fileunder = uvmexp.filepages <= UVM_PCTPARAM_APPLY(&s->s_filemin, t);
155 1.1.6.1 ad execunder = uvmexp.execpages <= UVM_PCTPARAM_APPLY(&s->s_execmin, t);
156 1.1.6.1 ad anonover = uvmexp.anonpages > UVM_PCTPARAM_APPLY(&s->s_anonmax, t);
157 1.1.6.1 ad fileover = uvmexp.filepages > UVM_PCTPARAM_APPLY(&s->s_filemax, t);
158 1.1.6.1 ad execover = uvmexp.execpages > UVM_PCTPARAM_APPLY(&s->s_execmax, t);
159 1.1.6.1 ad anonreact = anonunder || (!anonover && (fileover || execover));
160 1.1.6.1 ad filereact = fileunder || (!fileover && (anonover || execover));
161 1.1.6.1 ad execreact = execunder || (!execover && (anonover || fileover));
162 1.1.6.1 ad if (filereact && execreact && (anonreact || uvm_swapisfull())) {
163 1.1.6.1 ad anonreact = filereact = execreact = FALSE;
164 1.1.6.1 ad }
165 1.1.6.1 ad ss->ss_anonreact = anonreact;
166 1.1.6.1 ad ss->ss_filereact = filereact;
167 1.1.6.1 ad ss->ss_execreact = execreact;
168 1.1.6.1 ad
169 1.1.6.1 ad ss->ss_first = TRUE;
170 1.1.6.1 ad }
171 1.1.6.1 ad
172 1.1.6.1 ad struct vm_page *
173 1.1.6.1 ad uvmpdpol_selectvictim(void)
174 1.1.6.1 ad {
175 1.1.6.1 ad struct uvmpdpol_scanstate *ss = &pdpol_scanstate;
176 1.1.6.1 ad struct vm_page *pg;
177 1.1.6.1 ad
178 1.1.6.1 ad UVM_LOCK_ASSERT_PAGEQ();
179 1.1.6.1 ad
180 1.1.6.1 ad while (/* CONSTCOND */ 1) {
181 1.1.6.1 ad struct vm_anon *anon;
182 1.1.6.1 ad struct uvm_object *uobj;
183 1.1.6.1 ad
184 1.1.6.1 ad if (ss->ss_first) {
185 1.1.6.1 ad pg = TAILQ_FIRST(&pdpol_state.s_inactiveq);
186 1.1.6.1 ad ss->ss_first = FALSE;
187 1.1.6.1 ad } else {
188 1.1.6.1 ad pg = ss->ss_nextpg;
189 1.1.6.1 ad if (pg != NULL && (pg->pqflags & PQ_INACTIVE) == 0) {
190 1.1.6.1 ad pg = TAILQ_FIRST(&pdpol_state.s_inactiveq);
191 1.1.6.1 ad }
192 1.1.6.1 ad }
193 1.1.6.1 ad if (pg == NULL) {
194 1.1.6.1 ad break;
195 1.1.6.1 ad }
196 1.1.6.1 ad ss->ss_nextpg = TAILQ_NEXT(pg, pageq);
197 1.1.6.1 ad
198 1.1.6.1 ad uvmexp.pdscans++;
199 1.1.6.1 ad
200 1.1.6.1 ad /*
201 1.1.6.1 ad * move referenced pages back to active queue and
202 1.1.6.1 ad * skip to next page.
203 1.1.6.1 ad */
204 1.1.6.1 ad
205 1.1.6.1 ad if (pmap_is_referenced(pg)) {
206 1.1.6.1 ad uvmpdpol_pageactivate(pg);
207 1.1.6.1 ad uvmexp.pdreact++;
208 1.1.6.1 ad continue;
209 1.1.6.1 ad }
210 1.1.6.1 ad
211 1.1.6.1 ad anon = pg->uanon;
212 1.1.6.1 ad uobj = pg->uobject;
213 1.1.6.1 ad
214 1.1.6.1 ad /*
215 1.1.6.1 ad * enforce the minimum thresholds on different
216 1.1.6.1 ad * types of memory usage. if reusing the current
217 1.1.6.1 ad * page would reduce that type of usage below its
218 1.1.6.1 ad * minimum, reactivate the page instead and move
219 1.1.6.1 ad * on to the next page.
220 1.1.6.1 ad */
221 1.1.6.1 ad
222 1.1.6.1 ad if (uobj && UVM_OBJ_IS_VTEXT(uobj) && ss->ss_execreact) {
223 1.1.6.1 ad uvmpdpol_pageactivate(pg);
224 1.1.6.1 ad PDPOL_EVCNT_INCR(reactexec);
225 1.1.6.1 ad continue;
226 1.1.6.1 ad }
227 1.1.6.1 ad if (uobj && UVM_OBJ_IS_VNODE(uobj) &&
228 1.1.6.1 ad !UVM_OBJ_IS_VTEXT(uobj) && ss->ss_filereact) {
229 1.1.6.1 ad uvmpdpol_pageactivate(pg);
230 1.1.6.1 ad PDPOL_EVCNT_INCR(reactfile);
231 1.1.6.1 ad continue;
232 1.1.6.1 ad }
233 1.1.6.1 ad if ((anon || UVM_OBJ_IS_AOBJ(uobj)) && ss->ss_anonreact) {
234 1.1.6.1 ad uvmpdpol_pageactivate(pg);
235 1.1.6.1 ad PDPOL_EVCNT_INCR(reactanon);
236 1.1.6.1 ad continue;
237 1.1.6.1 ad }
238 1.1.6.1 ad
239 1.1.6.1 ad break;
240 1.1.6.1 ad }
241 1.1.6.1 ad
242 1.1.6.1 ad return pg;
243 1.1.6.1 ad }
244 1.1.6.1 ad
245 1.1.6.1 ad void
246 1.1.6.1 ad uvmpdpol_balancequeue(int swap_shortage)
247 1.1.6.1 ad {
248 1.1.6.1 ad int inactive_shortage;
249 1.1.6.1 ad struct vm_page *p, *nextpg;
250 1.1.6.1 ad
251 1.1.6.1 ad /*
252 1.1.6.1 ad * we have done the scan to get free pages. now we work on meeting
253 1.1.6.1 ad * our inactive target.
254 1.1.6.1 ad */
255 1.1.6.1 ad
256 1.1.6.1 ad inactive_shortage = pdpol_state.s_inactarg - pdpol_state.s_inactive;
257 1.1.6.1 ad for (p = TAILQ_FIRST(&pdpol_state.s_activeq);
258 1.1.6.1 ad p != NULL && (inactive_shortage > 0 || swap_shortage > 0);
259 1.1.6.1 ad p = nextpg) {
260 1.1.6.1 ad nextpg = TAILQ_NEXT(p, pageq);
261 1.1.6.1 ad
262 1.1.6.1 ad /*
263 1.1.6.1 ad * if there's a shortage of swap slots, try to free it.
264 1.1.6.1 ad */
265 1.1.6.1 ad
266 1.1.6.1 ad if (swap_shortage > 0 && (p->pqflags & PQ_SWAPBACKED) != 0) {
267 1.1.6.1 ad if (uvmpd_trydropswap(p)) {
268 1.1.6.1 ad swap_shortage--;
269 1.1.6.1 ad }
270 1.1.6.1 ad }
271 1.1.6.1 ad
272 1.1.6.1 ad /*
273 1.1.6.1 ad * if there's a shortage of inactive pages, deactivate.
274 1.1.6.1 ad */
275 1.1.6.1 ad
276 1.1.6.1 ad if (inactive_shortage > 0) {
277 1.1.6.1 ad /* no need to check wire_count as pg is "active" */
278 1.1.6.1 ad pmap_clear_reference(p);
279 1.1.6.1 ad uvmpdpol_pagedeactivate(p);
280 1.1.6.1 ad uvmexp.pddeact++;
281 1.1.6.1 ad inactive_shortage--;
282 1.1.6.1 ad }
283 1.1.6.1 ad }
284 1.1.6.1 ad }
285 1.1.6.1 ad
286 1.1.6.1 ad void
287 1.1.6.1 ad uvmpdpol_pagedeactivate(struct vm_page *pg)
288 1.1.6.1 ad {
289 1.1.6.1 ad
290 1.1.6.1 ad UVM_LOCK_ASSERT_PAGEQ();
291 1.1.6.1 ad if (pg->pqflags & PQ_ACTIVE) {
292 1.1.6.1 ad TAILQ_REMOVE(&pdpol_state.s_activeq, pg, pageq);
293 1.1.6.1 ad pg->pqflags &= ~PQ_ACTIVE;
294 1.1.6.1 ad KASSERT(pdpol_state.s_active > 0);
295 1.1.6.1 ad pdpol_state.s_active--;
296 1.1.6.1 ad }
297 1.1.6.1 ad if ((pg->pqflags & PQ_INACTIVE) == 0) {
298 1.1.6.1 ad KASSERT(pg->wire_count == 0);
299 1.1.6.1 ad TAILQ_INSERT_TAIL(&pdpol_state.s_inactiveq, pg, pageq);
300 1.1.6.1 ad pg->pqflags |= PQ_INACTIVE;
301 1.1.6.1 ad pdpol_state.s_inactive++;
302 1.1.6.1 ad }
303 1.1.6.1 ad }
304 1.1.6.1 ad
305 1.1.6.1 ad void
306 1.1.6.1 ad uvmpdpol_pageactivate(struct vm_page *pg)
307 1.1.6.1 ad {
308 1.1.6.1 ad
309 1.1.6.1 ad uvmpdpol_pagedequeue(pg);
310 1.1.6.1 ad TAILQ_INSERT_TAIL(&pdpol_state.s_activeq, pg, pageq);
311 1.1.6.1 ad pg->pqflags |= PQ_ACTIVE;
312 1.1.6.1 ad pdpol_state.s_active++;
313 1.1.6.1 ad }
314 1.1.6.1 ad
315 1.1.6.1 ad void
316 1.1.6.1 ad uvmpdpol_pagedequeue(struct vm_page *pg)
317 1.1.6.1 ad {
318 1.1.6.1 ad
319 1.1.6.1 ad if (pg->pqflags & PQ_ACTIVE) {
320 1.1.6.1 ad UVM_LOCK_ASSERT_PAGEQ();
321 1.1.6.1 ad TAILQ_REMOVE(&pdpol_state.s_activeq, pg, pageq);
322 1.1.6.1 ad pg->pqflags &= ~PQ_ACTIVE;
323 1.1.6.1 ad KASSERT(pdpol_state.s_active > 0);
324 1.1.6.1 ad pdpol_state.s_active--;
325 1.1.6.1 ad } else if (pg->pqflags & PQ_INACTIVE) {
326 1.1.6.1 ad UVM_LOCK_ASSERT_PAGEQ();
327 1.1.6.1 ad TAILQ_REMOVE(&pdpol_state.s_inactiveq, pg, pageq);
328 1.1.6.1 ad pg->pqflags &= ~PQ_INACTIVE;
329 1.1.6.1 ad KASSERT(pdpol_state.s_inactive > 0);
330 1.1.6.1 ad pdpol_state.s_inactive--;
331 1.1.6.1 ad }
332 1.1.6.1 ad }
333 1.1.6.1 ad
334 1.1.6.1 ad void
335 1.1.6.1 ad uvmpdpol_pageenqueue(struct vm_page *pg)
336 1.1.6.1 ad {
337 1.1.6.1 ad
338 1.1.6.1 ad uvmpdpol_pageactivate(pg);
339 1.1.6.1 ad }
340 1.1.6.1 ad
341 1.1.6.1 ad void
342 1.1.6.1 ad uvmpdpol_anfree(struct vm_anon *an)
343 1.1.6.1 ad {
344 1.1.6.1 ad }
345 1.1.6.1 ad
346 1.1.6.1 ad boolean_t
347 1.1.6.1 ad uvmpdpol_pageisqueued_p(struct vm_page *pg)
348 1.1.6.1 ad {
349 1.1.6.1 ad
350 1.1.6.1 ad return (pg->pqflags & (PQ_ACTIVE | PQ_INACTIVE)) != 0;
351 1.1.6.1 ad }
352 1.1.6.1 ad
353 1.1.6.1 ad void
354 1.1.6.1 ad uvmpdpol_estimatepageable(int *active, int *inactive)
355 1.1.6.1 ad {
356 1.1.6.1 ad
357 1.1.6.1 ad if (active) {
358 1.1.6.1 ad *active = pdpol_state.s_active;
359 1.1.6.1 ad }
360 1.1.6.1 ad if (inactive) {
361 1.1.6.1 ad *inactive = pdpol_state.s_inactive;
362 1.1.6.1 ad }
363 1.1.6.1 ad }
364 1.1.6.1 ad
365 1.1.6.1 ad #if !defined(PDSIM)
366 1.1.6.1 ad static int
367 1.1.6.1 ad min_check(struct uvm_pctparam *pct, int t)
368 1.1.6.1 ad {
369 1.1.6.1 ad struct uvmpdpol_globalstate *s = &pdpol_state;
370 1.1.6.1 ad int total = t;
371 1.1.6.1 ad
372 1.1.6.1 ad if (pct != &s->s_anonmin) {
373 1.1.6.1 ad total += uvm_pctparam_get(&s->s_anonmin);
374 1.1.6.1 ad }
375 1.1.6.1 ad if (pct != &s->s_filemin) {
376 1.1.6.1 ad total += uvm_pctparam_get(&s->s_filemin);
377 1.1.6.1 ad }
378 1.1.6.1 ad if (pct != &s->s_execmin) {
379 1.1.6.1 ad total += uvm_pctparam_get(&s->s_execmin);
380 1.1.6.1 ad }
381 1.1.6.1 ad if (total > 95) {
382 1.1.6.1 ad return EINVAL;
383 1.1.6.1 ad }
384 1.1.6.1 ad return 0;
385 1.1.6.1 ad }
386 1.1.6.1 ad #endif /* !defined(PDSIM) */
387 1.1.6.1 ad
388 1.1.6.1 ad void
389 1.1.6.1 ad uvmpdpol_init(void)
390 1.1.6.1 ad {
391 1.1.6.1 ad struct uvmpdpol_globalstate *s = &pdpol_state;
392 1.1.6.1 ad
393 1.1.6.1 ad TAILQ_INIT(&s->s_activeq);
394 1.1.6.1 ad TAILQ_INIT(&s->s_inactiveq);
395 1.1.6.1 ad uvm_pctparam_init(&s->s_inactivepct, CLOCK_INACTIVEPCT, NULL);
396 1.1.6.1 ad uvm_pctparam_init(&s->s_anonmin, 10, min_check);
397 1.1.6.1 ad uvm_pctparam_init(&s->s_filemin, 10, min_check);
398 1.1.6.1 ad uvm_pctparam_init(&s->s_execmin, 5, min_check);
399 1.1.6.1 ad uvm_pctparam_init(&s->s_anonmax, 80, NULL);
400 1.1.6.1 ad uvm_pctparam_init(&s->s_filemax, 50, NULL);
401 1.1.6.1 ad uvm_pctparam_init(&s->s_execmax, 30, NULL);
402 1.1.6.1 ad }
403 1.1.6.1 ad
404 1.1.6.1 ad void
405 1.1.6.1 ad uvmpdpol_reinit(void)
406 1.1.6.1 ad {
407 1.1.6.1 ad }
408 1.1.6.1 ad
409 1.1.6.1 ad boolean_t
410 1.1.6.1 ad uvmpdpol_needsscan_p(void)
411 1.1.6.1 ad {
412 1.1.6.1 ad
413 1.1.6.1 ad return pdpol_state.s_inactive < pdpol_state.s_inactarg;
414 1.1.6.1 ad }
415 1.1.6.1 ad
416 1.1.6.1 ad void
417 1.1.6.1 ad uvmpdpol_tune(void)
418 1.1.6.1 ad {
419 1.1.6.1 ad
420 1.1.6.1 ad clock_tune();
421 1.1.6.1 ad }
422 1.1.6.1 ad
423 1.1.6.1 ad #if !defined(PDSIM)
424 1.1.6.1 ad
425 1.1.6.1 ad #include <sys/sysctl.h> /* XXX SYSCTL_DESCR */
426 1.1.6.1 ad
427 1.1.6.1 ad void
428 1.1.6.1 ad uvmpdpol_sysctlsetup(void)
429 1.1.6.1 ad {
430 1.1.6.1 ad struct uvmpdpol_globalstate *s = &pdpol_state;
431 1.1.6.1 ad
432 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_anonmin, "anonmin",
433 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory reserved "
434 1.1.6.1 ad "for anonymous application data"));
435 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_filemin, "filemin",
436 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory reserved "
437 1.1.6.1 ad "for cached executable data"));
438 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_execmin, "execmin",
439 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory reserved "
440 1.1.6.1 ad "for cached file data"));
441 1.1.6.1 ad
442 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_anonmax, "anonmax",
443 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory which will "
444 1.1.6.1 ad "be reclaimed from other usage for "
445 1.1.6.1 ad "anonymous application data"));
446 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_filemax, "filemax",
447 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory which will "
448 1.1.6.1 ad "be reclaimed from other usage for cached "
449 1.1.6.1 ad "file data"));
450 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_execmax, "execmax",
451 1.1.6.1 ad SYSCTL_DESCR("Percentage of physical memory which will "
452 1.1.6.1 ad "be reclaimed from other usage for cached "
453 1.1.6.1 ad "executable data"));
454 1.1.6.1 ad
455 1.1.6.1 ad uvm_pctparam_createsysctlnode(&s->s_inactivepct, "inactivepct",
456 1.1.6.1 ad SYSCTL_DESCR("Percentage of inactive queue of "
457 1.1.6.1 ad "the entire (active + inactive) queue"));
458 1.1.6.1 ad }
459 1.1.6.1 ad
460 1.1.6.1 ad #endif /* !defined(PDSIM) */
461 1.1.6.1 ad
462 1.1.6.1 ad #if defined(PDSIM)
463 1.1.6.1 ad void
464 1.1.6.1 ad pdsim_dump(const char *id)
465 1.1.6.1 ad {
466 1.1.6.1 ad #if defined(DEBUG)
467 1.1.6.1 ad /* XXX */
468 1.1.6.1 ad #endif /* defined(DEBUG) */
469 1.1.6.1 ad }
470 1.1.6.1 ad #endif /* defined(PDSIM) */
471