uvm_pgflcache.c revision 1.4.6.2 1 1.4.6.2 martin /* $NetBSD: uvm_pgflcache.c,v 1.4.6.2 2020/04/08 14:09:04 martin Exp $ */
2 1.4.6.2 martin
3 1.4.6.2 martin /*-
4 1.4.6.2 martin * Copyright (c) 2019 The NetBSD Foundation, Inc.
5 1.4.6.2 martin * All rights reserved.
6 1.4.6.2 martin *
7 1.4.6.2 martin * This code is derived from software contributed to The NetBSD Foundation
8 1.4.6.2 martin * by Andrew Doran.
9 1.4.6.2 martin *
10 1.4.6.2 martin * Redistribution and use in source and binary forms, with or without
11 1.4.6.2 martin * modification, are permitted provided that the following conditions
12 1.4.6.2 martin * are met:
13 1.4.6.2 martin * 1. Redistributions of source code must retain the above copyright
14 1.4.6.2 martin * notice, this list of conditions and the following disclaimer.
15 1.4.6.2 martin * 2. Redistributions in binary form must reproduce the above copyright
16 1.4.6.2 martin * notice, this list of conditions and the following disclaimer in the
17 1.4.6.2 martin * documentation and/or other materials provided with the distribution.
18 1.4.6.2 martin *
19 1.4.6.2 martin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.4.6.2 martin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.4.6.2 martin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.4.6.2 martin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.4.6.2 martin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.4.6.2 martin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.4.6.2 martin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.4.6.2 martin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.4.6.2 martin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.4.6.2 martin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.4.6.2 martin * POSSIBILITY OF SUCH DAMAGE.
30 1.4.6.2 martin */
31 1.4.6.2 martin
32 1.4.6.2 martin /*
33 1.4.6.2 martin * uvm_pgflcache.c: page freelist cache.
34 1.4.6.2 martin *
35 1.4.6.2 martin * This implements a tiny per-CPU cache of pages that sits between the main
36 1.4.6.2 martin * page allocator and the freelists. By allocating and freeing pages in
37 1.4.6.2 martin * batch, it reduces freelist contention by an order of magnitude.
38 1.4.6.2 martin *
39 1.4.6.2 martin * The cache can be paused & resumed at runtime so that UVM_HOTPLUG,
40 1.4.6.2 martin * uvm_pglistalloc() and uvm_page_redim() can have a consistent view of the
41 1.4.6.2 martin * world. On system with one CPU per physical package (e.g. a uniprocessor)
42 1.4.6.2 martin * the cache is not enabled.
43 1.4.6.2 martin */
44 1.4.6.2 martin
45 1.4.6.2 martin #include <sys/cdefs.h>
46 1.4.6.2 martin __KERNEL_RCSID(0, "$NetBSD: uvm_pgflcache.c,v 1.4.6.2 2020/04/08 14:09:04 martin Exp $");
47 1.4.6.2 martin
48 1.4.6.2 martin #include "opt_uvm.h"
49 1.4.6.2 martin #include "opt_multiprocessor.h"
50 1.4.6.2 martin
51 1.4.6.2 martin #include <sys/param.h>
52 1.4.6.2 martin #include <sys/systm.h>
53 1.4.6.2 martin #include <sys/sched.h>
54 1.4.6.2 martin #include <sys/kernel.h>
55 1.4.6.2 martin #include <sys/vnode.h>
56 1.4.6.2 martin #include <sys/proc.h>
57 1.4.6.2 martin #include <sys/atomic.h>
58 1.4.6.2 martin #include <sys/cpu.h>
59 1.4.6.2 martin #include <sys/xcall.h>
60 1.4.6.2 martin
61 1.4.6.2 martin #include <uvm/uvm.h>
62 1.4.6.2 martin #include <uvm/uvm_pglist.h>
63 1.4.6.2 martin #include <uvm/uvm_pgflcache.h>
64 1.4.6.2 martin
65 1.4.6.2 martin /* There is no point doing any of this on a uniprocessor. */
66 1.4.6.2 martin #ifdef MULTIPROCESSOR
67 1.4.6.2 martin
68 1.4.6.2 martin /*
69 1.4.6.2 martin * MAXPGS - maximum pages per color, per bucket.
70 1.4.6.2 martin * FILLPGS - number of pages to allocate at once, per color, per bucket.
71 1.4.6.2 martin *
72 1.4.6.2 martin * Why the chosen values:
73 1.4.6.2 martin *
74 1.4.6.2 martin * (1) In 2019, an average Intel system has 4kB pages and 8x L2 cache
75 1.4.6.2 martin * colors. We make the assumption that most of the time allocation activity
76 1.4.6.2 martin * will be centered around one UVM freelist, so most of the time there will
77 1.4.6.2 martin * be no more than 224kB worth of cached pages per-CPU. That's tiny, but
78 1.4.6.2 martin * enough to hugely reduce contention on the freelist locks, and give us a
79 1.4.6.2 martin * small pool of pages which if we're very lucky may have some L1/L2 cache
80 1.4.6.2 martin * locality, and do so without subtracting too much from the L2/L3 cache
81 1.4.6.2 martin * benefits of having per-package free lists in the page allocator.
82 1.4.6.2 martin *
83 1.4.6.2 martin * (2) With the chosen values on _LP64, the data structure for each color
84 1.4.6.2 martin * takes up a single cache line (64 bytes) giving this very low overhead
85 1.4.6.2 martin * even in the "miss" case.
86 1.4.6.2 martin *
87 1.4.6.2 martin * (3) We don't want to cause too much pressure by hiding away memory that
88 1.4.6.2 martin * could otherwise be put to good use.
89 1.4.6.2 martin */
90 1.4.6.2 martin #define MAXPGS 7
91 1.4.6.2 martin #define FILLPGS 6
92 1.4.6.2 martin
93 1.4.6.2 martin /* Variable size, according to # colors. */
94 1.4.6.2 martin struct pgflcache {
95 1.4.6.2 martin struct pccolor {
96 1.4.6.2 martin intptr_t count;
97 1.4.6.2 martin struct vm_page *pages[MAXPGS];
98 1.4.6.2 martin } color[1];
99 1.4.6.2 martin };
100 1.4.6.2 martin
101 1.4.6.2 martin static kmutex_t uvm_pgflcache_lock;
102 1.4.6.2 martin static int uvm_pgflcache_sem;
103 1.4.6.2 martin
104 1.4.6.2 martin /*
105 1.4.6.2 martin * uvm_pgflcache_fill: fill specified freelist/color from global list
106 1.4.6.2 martin *
107 1.4.6.2 martin * => must be called at IPL_VM
108 1.4.6.2 martin * => must be called with given bucket lock held
109 1.4.6.2 martin * => must only fill from the correct bucket for this CPU
110 1.4.6.2 martin */
111 1.4.6.2 martin
112 1.4.6.2 martin void
113 1.4.6.2 martin uvm_pgflcache_fill(struct uvm_cpu *ucpu, int fl, int b, int c)
114 1.4.6.2 martin {
115 1.4.6.2 martin struct pgflbucket *pgb;
116 1.4.6.2 martin struct pgflcache *pc;
117 1.4.6.2 martin struct pccolor *pcc;
118 1.4.6.2 martin struct pgflist *head;
119 1.4.6.2 martin struct vm_page *pg;
120 1.4.6.2 martin int count;
121 1.4.6.2 martin
122 1.4.6.2 martin KASSERT(mutex_owned(&uvm_freelist_locks[b].lock));
123 1.4.6.2 martin KASSERT(ucpu->pgflbucket == b);
124 1.4.6.2 martin
125 1.4.6.2 martin /* If caching is off, then bail out. */
126 1.4.6.2 martin if (__predict_false((pc = ucpu->pgflcache[fl]) == NULL)) {
127 1.4.6.2 martin return;
128 1.4.6.2 martin }
129 1.4.6.2 martin
130 1.4.6.2 martin /* Fill only to the limit. */
131 1.4.6.2 martin pcc = &pc->color[c];
132 1.4.6.2 martin pgb = uvm.page_free[fl].pgfl_buckets[b];
133 1.4.6.2 martin head = &pgb->pgb_colors[c];
134 1.4.6.2 martin if (pcc->count >= FILLPGS) {
135 1.4.6.2 martin return;
136 1.4.6.2 martin }
137 1.4.6.2 martin
138 1.4.6.2 martin /* Pull pages from the bucket until it's empty, or we are full. */
139 1.4.6.2 martin count = pcc->count;
140 1.4.6.2 martin pg = LIST_FIRST(head);
141 1.4.6.2 martin while (__predict_true(pg != NULL && count < FILLPGS)) {
142 1.4.6.2 martin KASSERT(pg->flags & PG_FREE);
143 1.4.6.2 martin KASSERT(uvm_page_get_bucket(pg) == b);
144 1.4.6.2 martin pcc->pages[count++] = pg;
145 1.4.6.2 martin pg = LIST_NEXT(pg, pageq.list);
146 1.4.6.2 martin }
147 1.4.6.2 martin
148 1.4.6.2 martin /* Violate LIST abstraction to remove all pages at once. */
149 1.4.6.2 martin head->lh_first = pg;
150 1.4.6.2 martin if (__predict_true(pg != NULL)) {
151 1.4.6.2 martin pg->pageq.list.le_prev = &head->lh_first;
152 1.4.6.2 martin }
153 1.4.6.2 martin pgb->pgb_nfree -= (count - pcc->count);
154 1.4.6.2 martin pcc->count = count;
155 1.4.6.2 martin }
156 1.4.6.2 martin
157 1.4.6.2 martin /*
158 1.4.6.2 martin * uvm_pgflcache_spill: spill specified freelist/color to global list
159 1.4.6.2 martin *
160 1.4.6.2 martin * => must be called at IPL_VM
161 1.4.6.2 martin * => mark __noinline so we don't pull it into uvm_pgflcache_free()
162 1.4.6.2 martin */
163 1.4.6.2 martin
164 1.4.6.2 martin static void __noinline
165 1.4.6.2 martin uvm_pgflcache_spill(struct uvm_cpu *ucpu, int fl, int c)
166 1.4.6.2 martin {
167 1.4.6.2 martin struct pgflbucket *pgb;
168 1.4.6.2 martin struct pgfreelist *pgfl;
169 1.4.6.2 martin struct pgflcache *pc;
170 1.4.6.2 martin struct pccolor *pcc;
171 1.4.6.2 martin struct pgflist *head;
172 1.4.6.2 martin kmutex_t *lock;
173 1.4.6.2 martin int b, adj;
174 1.4.6.2 martin
175 1.4.6.2 martin pc = ucpu->pgflcache[fl];
176 1.4.6.2 martin pcc = &pc->color[c];
177 1.4.6.2 martin pgfl = &uvm.page_free[fl];
178 1.4.6.2 martin b = ucpu->pgflbucket;
179 1.4.6.2 martin pgb = pgfl->pgfl_buckets[b];
180 1.4.6.2 martin head = &pgb->pgb_colors[c];
181 1.4.6.2 martin lock = &uvm_freelist_locks[b].lock;
182 1.4.6.2 martin
183 1.4.6.2 martin mutex_spin_enter(lock);
184 1.4.6.2 martin for (adj = pcc->count; pcc->count != 0;) {
185 1.4.6.2 martin pcc->count--;
186 1.4.6.2 martin KASSERT(pcc->pages[pcc->count] != NULL);
187 1.4.6.2 martin KASSERT(pcc->pages[pcc->count]->flags & PG_FREE);
188 1.4.6.2 martin LIST_INSERT_HEAD(head, pcc->pages[pcc->count], pageq.list);
189 1.4.6.2 martin }
190 1.4.6.2 martin pgb->pgb_nfree += adj;
191 1.4.6.2 martin mutex_spin_exit(lock);
192 1.4.6.2 martin }
193 1.4.6.2 martin
194 1.4.6.2 martin /*
195 1.4.6.2 martin * uvm_pgflcache_alloc: try to allocate a cached page.
196 1.4.6.2 martin *
197 1.4.6.2 martin * => must be called at IPL_VM
198 1.4.6.2 martin * => allocate only from the given freelist and given page color
199 1.4.6.2 martin */
200 1.4.6.2 martin
201 1.4.6.2 martin struct vm_page *
202 1.4.6.2 martin uvm_pgflcache_alloc(struct uvm_cpu *ucpu, int fl, int c)
203 1.4.6.2 martin {
204 1.4.6.2 martin struct pgflcache *pc;
205 1.4.6.2 martin struct pccolor *pcc;
206 1.4.6.2 martin struct vm_page *pg;
207 1.4.6.2 martin
208 1.4.6.2 martin /* If caching is off, then bail out. */
209 1.4.6.2 martin if (__predict_false((pc = ucpu->pgflcache[fl]) == NULL)) {
210 1.4.6.2 martin return NULL;
211 1.4.6.2 martin }
212 1.4.6.2 martin
213 1.4.6.2 martin /* Very simple: if we have a page then return it. */
214 1.4.6.2 martin pcc = &pc->color[c];
215 1.4.6.2 martin if (__predict_false(pcc->count == 0)) {
216 1.4.6.2 martin return NULL;
217 1.4.6.2 martin }
218 1.4.6.2 martin pg = pcc->pages[--(pcc->count)];
219 1.4.6.2 martin KASSERT(pg != NULL);
220 1.4.6.2 martin KASSERT(pg->flags & PG_FREE);
221 1.4.6.2 martin KASSERT(uvm_page_get_freelist(pg) == fl);
222 1.4.6.2 martin KASSERT(uvm_page_get_bucket(pg) == ucpu->pgflbucket);
223 1.4.6.2 martin pg->flags &= PG_ZERO;
224 1.4.6.2 martin return pg;
225 1.4.6.2 martin }
226 1.4.6.2 martin
227 1.4.6.2 martin /*
228 1.4.6.2 martin * uvm_pgflcache_free: cache a page, if possible.
229 1.4.6.2 martin *
230 1.4.6.2 martin * => must be called at IPL_VM
231 1.4.6.2 martin * => must only send pages for the correct bucket for this CPU
232 1.4.6.2 martin */
233 1.4.6.2 martin
234 1.4.6.2 martin bool
235 1.4.6.2 martin uvm_pgflcache_free(struct uvm_cpu *ucpu, struct vm_page *pg)
236 1.4.6.2 martin {
237 1.4.6.2 martin struct pgflcache *pc;
238 1.4.6.2 martin struct pccolor *pcc;
239 1.4.6.2 martin int fl, c;
240 1.4.6.2 martin
241 1.4.6.2 martin KASSERT(uvm_page_get_bucket(pg) == ucpu->pgflbucket);
242 1.4.6.2 martin
243 1.4.6.2 martin /* If caching is off, then bail out. */
244 1.4.6.2 martin fl = uvm_page_get_freelist(pg);
245 1.4.6.2 martin if (__predict_false((pc = ucpu->pgflcache[fl]) == NULL)) {
246 1.4.6.2 martin return false;
247 1.4.6.2 martin }
248 1.4.6.2 martin
249 1.4.6.2 martin /* If the array is full spill it first, then add page to array. */
250 1.4.6.2 martin c = VM_PGCOLOR(pg);
251 1.4.6.2 martin pcc = &pc->color[c];
252 1.4.6.2 martin KASSERT((pg->flags & PG_FREE) == 0);
253 1.4.6.2 martin if (__predict_false(pcc->count == MAXPGS)) {
254 1.4.6.2 martin uvm_pgflcache_spill(ucpu, fl, c);
255 1.4.6.2 martin }
256 1.4.6.2 martin pg->flags = (pg->flags & PG_ZERO) | PG_FREE;
257 1.4.6.2 martin pcc->pages[pcc->count] = pg;
258 1.4.6.2 martin pcc->count++;
259 1.4.6.2 martin return true;
260 1.4.6.2 martin }
261 1.4.6.2 martin
262 1.4.6.2 martin /*
263 1.4.6.2 martin * uvm_pgflcache_init: allocate and initialize per-CPU data structures for
264 1.4.6.2 martin * the free page cache. Don't set anything in motion - that's taken care
265 1.4.6.2 martin * of by uvm_pgflcache_resume().
266 1.4.6.2 martin */
267 1.4.6.2 martin
268 1.4.6.2 martin static void
269 1.4.6.2 martin uvm_pgflcache_init_cpu(struct cpu_info *ci)
270 1.4.6.2 martin {
271 1.4.6.2 martin struct uvm_cpu *ucpu;
272 1.4.6.2 martin size_t sz;
273 1.4.6.2 martin
274 1.4.6.2 martin ucpu = ci->ci_data.cpu_uvm;
275 1.4.6.2 martin KASSERT(ucpu->pgflcachemem == NULL);
276 1.4.6.2 martin KASSERT(ucpu->pgflcache[0] == NULL);
277 1.4.6.2 martin
278 1.4.6.2 martin sz = offsetof(struct pgflcache, color[uvmexp.ncolors]);
279 1.4.6.2 martin ucpu->pgflcachememsz =
280 1.4.6.2 martin (roundup2(sz * VM_NFREELIST, coherency_unit) + coherency_unit - 1);
281 1.4.6.2 martin ucpu->pgflcachemem = kmem_zalloc(ucpu->pgflcachememsz, KM_SLEEP);
282 1.4.6.2 martin }
283 1.4.6.2 martin
284 1.4.6.2 martin /*
285 1.4.6.2 martin * uvm_pgflcache_fini_cpu: dump all cached pages back to global free list
286 1.4.6.2 martin * and shut down caching on the CPU. Called on each CPU in the system via
287 1.4.6.2 martin * xcall.
288 1.4.6.2 martin */
289 1.4.6.2 martin
290 1.4.6.2 martin static void
291 1.4.6.2 martin uvm_pgflcache_fini_cpu(void *arg1 __unused, void *arg2 __unused)
292 1.4.6.2 martin {
293 1.4.6.2 martin struct uvm_cpu *ucpu;
294 1.4.6.2 martin int fl, color, s;
295 1.4.6.2 martin
296 1.4.6.2 martin ucpu = curcpu()->ci_data.cpu_uvm;
297 1.4.6.2 martin for (fl = 0; fl < VM_NFREELIST; fl++) {
298 1.4.6.2 martin s = splvm();
299 1.4.6.2 martin for (color = 0; color < uvmexp.ncolors; color++) {
300 1.4.6.2 martin uvm_pgflcache_spill(ucpu, fl, color);
301 1.4.6.2 martin }
302 1.4.6.2 martin ucpu->pgflcache[fl] = NULL;
303 1.4.6.2 martin splx(s);
304 1.4.6.2 martin }
305 1.4.6.2 martin }
306 1.4.6.2 martin
307 1.4.6.2 martin /*
308 1.4.6.2 martin * uvm_pgflcache_pause: pause operation of the caches
309 1.4.6.2 martin */
310 1.4.6.2 martin
311 1.4.6.2 martin void
312 1.4.6.2 martin uvm_pgflcache_pause(void)
313 1.4.6.2 martin {
314 1.4.6.2 martin uint64_t where;
315 1.4.6.2 martin
316 1.4.6.2 martin /* First one in starts draining. Everyone else waits. */
317 1.4.6.2 martin mutex_enter(&uvm_pgflcache_lock);
318 1.4.6.2 martin if (uvm_pgflcache_sem++ == 0) {
319 1.4.6.2 martin where = xc_broadcast(XC_HIGHPRI, uvm_pgflcache_fini_cpu,
320 1.4.6.2 martin (void *)1, NULL);
321 1.4.6.2 martin xc_wait(where);
322 1.4.6.2 martin }
323 1.4.6.2 martin mutex_exit(&uvm_pgflcache_lock);
324 1.4.6.2 martin }
325 1.4.6.2 martin
326 1.4.6.2 martin /*
327 1.4.6.2 martin * uvm_pgflcache_resume: resume operation of the caches
328 1.4.6.2 martin */
329 1.4.6.2 martin
330 1.4.6.2 martin void
331 1.4.6.2 martin uvm_pgflcache_resume(void)
332 1.4.6.2 martin {
333 1.4.6.2 martin CPU_INFO_ITERATOR cii;
334 1.4.6.2 martin struct cpu_info *ci;
335 1.4.6.2 martin struct uvm_cpu *ucpu;
336 1.4.6.2 martin uintptr_t addr;
337 1.4.6.2 martin size_t sz;
338 1.4.6.2 martin int fl;
339 1.4.6.2 martin
340 1.4.6.2 martin /* Last guy out takes care of business. */
341 1.4.6.2 martin mutex_enter(&uvm_pgflcache_lock);
342 1.4.6.2 martin KASSERT(uvm_pgflcache_sem > 0);
343 1.4.6.2 martin if (uvm_pgflcache_sem-- > 1) {
344 1.4.6.2 martin mutex_exit(&uvm_pgflcache_lock);
345 1.4.6.2 martin return;
346 1.4.6.2 martin }
347 1.4.6.2 martin
348 1.4.6.2 martin /*
349 1.4.6.2 martin * Make sure dependant data structure updates are remotely visible.
350 1.4.6.2 martin * Essentially this functions as a global memory barrier.
351 1.4.6.2 martin */
352 1.4.6.2 martin xc_barrier(XC_HIGHPRI);
353 1.4.6.2 martin
354 1.4.6.2 martin /*
355 1.4.6.2 martin * Then set all of the pointers in place on each CPU. As soon as
356 1.4.6.2 martin * each pointer is set, caching is operational in that dimension.
357 1.4.6.2 martin */
358 1.4.6.2 martin sz = offsetof(struct pgflcache, color[uvmexp.ncolors]);
359 1.4.6.2 martin for (CPU_INFO_FOREACH(cii, ci)) {
360 1.4.6.2 martin ucpu = ci->ci_data.cpu_uvm;
361 1.4.6.2 martin addr = roundup2((uintptr_t)ucpu->pgflcachemem, coherency_unit);
362 1.4.6.2 martin for (fl = 0; fl < VM_NFREELIST; fl++) {
363 1.4.6.2 martin ucpu->pgflcache[fl] = (struct pgflcache *)addr;
364 1.4.6.2 martin addr += sz;
365 1.4.6.2 martin }
366 1.4.6.2 martin }
367 1.4.6.2 martin mutex_exit(&uvm_pgflcache_lock);
368 1.4.6.2 martin }
369 1.4.6.2 martin
370 1.4.6.2 martin /*
371 1.4.6.2 martin * uvm_pgflcache_start: start operation of the cache.
372 1.4.6.2 martin *
373 1.4.6.2 martin * => called once only, when init(8) is about to be started
374 1.4.6.2 martin */
375 1.4.6.2 martin
376 1.4.6.2 martin void
377 1.4.6.2 martin uvm_pgflcache_start(void)
378 1.4.6.2 martin {
379 1.4.6.2 martin CPU_INFO_ITERATOR cii;
380 1.4.6.2 martin struct cpu_info *ci;
381 1.4.6.2 martin
382 1.4.6.2 martin KASSERT(uvm_pgflcache_sem > 0);
383 1.4.6.2 martin
384 1.4.6.2 martin /*
385 1.4.6.2 martin * There's not much point doing this if every CPU has its own
386 1.4.6.2 martin * bucket (and that includes the uniprocessor case).
387 1.4.6.2 martin */
388 1.4.6.2 martin if (ncpu == uvm.bucketcount) {
389 1.4.6.2 martin return;
390 1.4.6.2 martin }
391 1.4.6.2 martin
392 1.4.6.2 martin /* Create data structures for each CPU. */
393 1.4.6.2 martin for (CPU_INFO_FOREACH(cii, ci)) {
394 1.4.6.2 martin uvm_pgflcache_init_cpu(ci);
395 1.4.6.2 martin }
396 1.4.6.2 martin
397 1.4.6.2 martin /* Kick it into action. */
398 1.4.6.2 martin uvm_pgflcache_resume();
399 1.4.6.2 martin }
400 1.4.6.2 martin
401 1.4.6.2 martin /*
402 1.4.6.2 martin * uvm_pgflcache_init: set up data structures for the free page cache.
403 1.4.6.2 martin */
404 1.4.6.2 martin
405 1.4.6.2 martin void
406 1.4.6.2 martin uvm_pgflcache_init(void)
407 1.4.6.2 martin {
408 1.4.6.2 martin
409 1.4.6.2 martin uvm_pgflcache_sem = 1;
410 1.4.6.2 martin mutex_init(&uvm_pgflcache_lock, MUTEX_DEFAULT, IPL_NONE);
411 1.4.6.2 martin }
412 1.4.6.2 martin
413 1.4.6.2 martin #else /* MULTIPROCESSOR */
414 1.4.6.2 martin
415 1.4.6.2 martin struct vm_page *
416 1.4.6.2 martin uvm_pgflcache_alloc(struct uvm_cpu *ucpu, int fl, int c)
417 1.4.6.2 martin {
418 1.4.6.2 martin
419 1.4.6.2 martin return NULL;
420 1.4.6.2 martin }
421 1.4.6.2 martin
422 1.4.6.2 martin bool
423 1.4.6.2 martin uvm_pgflcache_free(struct uvm_cpu *ucpu, struct vm_page *pg)
424 1.4.6.2 martin {
425 1.4.6.2 martin
426 1.4.6.2 martin return false;
427 1.4.6.2 martin }
428 1.4.6.2 martin
429 1.4.6.2 martin void
430 1.4.6.2 martin uvm_pgflcache_fill(struct uvm_cpu *ucpu, int fl, int b, int c)
431 1.4.6.2 martin {
432 1.4.6.2 martin
433 1.4.6.2 martin }
434 1.4.6.2 martin
435 1.4.6.2 martin void
436 1.4.6.2 martin uvm_pgflcache_pause(void)
437 1.4.6.2 martin {
438 1.4.6.2 martin
439 1.4.6.2 martin }
440 1.4.6.2 martin
441 1.4.6.2 martin void
442 1.4.6.2 martin uvm_pgflcache_resume(void)
443 1.4.6.2 martin {
444 1.4.6.2 martin
445 1.4.6.2 martin }
446 1.4.6.2 martin
447 1.4.6.2 martin void
448 1.4.6.2 martin uvm_pgflcache_start(void)
449 1.4.6.2 martin {
450 1.4.6.2 martin
451 1.4.6.2 martin }
452 1.4.6.2 martin
453 1.4.6.2 martin void
454 1.4.6.2 martin uvm_pgflcache_init(void)
455 1.4.6.2 martin {
456 1.4.6.2 martin
457 1.4.6.2 martin }
458 1.4.6.2 martin
459 1.4.6.2 martin #endif /* MULTIPROCESSOR */
460