vm.c revision 1.81 1 /* $NetBSD: vm.c,v 1.81 2010/06/09 11:35:36 pooka Exp $ */
2
3 /*
4 * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
5 *
6 * Development of this software was supported by
7 * The Finnish Cultural Foundation and the Research Foundation of
8 * The Helsinki University of Technology.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 /*
33 * Virtual memory emulation routines. Contents:
34 * + anon objects & pager
35 * + misc support routines
36 */
37
38 /*
39 * XXX: we abuse pg->uanon for the virtual address of the storage
40 * for each page. phys_addr would fit the job description better,
41 * except that it will create unnecessary lossage on some platforms
42 * due to not being a pointer type.
43 */
44
45 #include <sys/cdefs.h>
46 __KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.81 2010/06/09 11:35:36 pooka Exp $");
47
48 #include <sys/param.h>
49 #include <sys/atomic.h>
50 #include <sys/buf.h>
51 #include <sys/kernel.h>
52 #include <sys/kmem.h>
53 #include <sys/mman.h>
54 #include <sys/null.h>
55 #include <sys/vnode.h>
56
57 #include <machine/pmap.h>
58
59 #include <rump/rumpuser.h>
60
61 #include <uvm/uvm.h>
62 #include <uvm/uvm_ddb.h>
63 #include <uvm/uvm_prot.h>
64 #include <uvm/uvm_readahead.h>
65
66 #include "rump_private.h"
67
68 static int ao_get(struct uvm_object *, voff_t, struct vm_page **,
69 int *, int, vm_prot_t, int, int);
70 static int ao_put(struct uvm_object *, voff_t, voff_t, int);
71
72 const struct uvm_pagerops aobj_pager = {
73 .pgo_get = ao_get,
74 .pgo_put = ao_put,
75 };
76
77 kmutex_t uvm_pageqlock;
78
79 struct uvmexp uvmexp;
80 struct uvm uvm;
81
82 struct vmspace rump_vmspace;
83 struct vm_map rump_vmmap;
84 static struct vm_map_kernel kmem_map_store;
85 struct vm_map *kmem_map = &kmem_map_store.vmk_map;
86 const struct rb_tree_ops uvm_page_tree_ops;
87
88 static struct vm_map_kernel kernel_map_store;
89 struct vm_map *kernel_map = &kernel_map_store.vmk_map;
90
91 static unsigned int pdaemon_waiters;
92 static kmutex_t pdaemonmtx;
93 static kcondvar_t pdaemoncv, oomwait;
94
95 /*
96 * vm pages
97 */
98
99 /* called with the object locked */
100 struct vm_page *
101 uvm_pagealloc_strat(struct uvm_object *uobj, voff_t off, struct vm_anon *anon,
102 int flags, int strat, int free_list)
103 {
104 struct vm_page *pg;
105
106 pg = kmem_zalloc(sizeof(struct vm_page), KM_SLEEP);
107 pg->offset = off;
108 pg->uobject = uobj;
109
110 pg->uanon = (void *)kmem_alloc(PAGE_SIZE, KM_SLEEP);
111 if (flags & UVM_PGA_ZERO)
112 memset(pg->uanon, 0, PAGE_SIZE);
113 pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE;
114
115 TAILQ_INSERT_TAIL(&uobj->memq, pg, listq.queue);
116 uobj->uo_npages++;
117
118 return pg;
119 }
120
121 /*
122 * Release a page.
123 *
124 * Called with the vm object locked.
125 */
126 void
127 uvm_pagefree(struct vm_page *pg)
128 {
129 struct uvm_object *uobj = pg->uobject;
130
131 if (pg->flags & PG_WANTED)
132 wakeup(pg);
133
134 uobj->uo_npages--;
135 TAILQ_REMOVE(&uobj->memq, pg, listq.queue);
136 kmem_free((void *)pg->uanon, PAGE_SIZE);
137 kmem_free(pg, sizeof(*pg));
138 }
139
140 void
141 uvm_pagezero(struct vm_page *pg)
142 {
143
144 pg->flags &= ~PG_CLEAN;
145 memset((void *)pg->uanon, 0, PAGE_SIZE);
146 }
147
148 /*
149 * Anon object stuff
150 */
151
152 static int
153 ao_get(struct uvm_object *uobj, voff_t off, struct vm_page **pgs,
154 int *npages, int centeridx, vm_prot_t access_type,
155 int advice, int flags)
156 {
157 struct vm_page *pg;
158 int i;
159
160 if (centeridx)
161 panic("%s: centeridx != 0 not supported", __func__);
162
163 /* loop over pages */
164 off = trunc_page(off);
165 for (i = 0; i < *npages; i++) {
166 retrylookup:
167 pg = uvm_pagelookup(uobj, off + (i << PAGE_SHIFT));
168 if (pg) {
169 if (pg->flags & PG_BUSY) {
170 pg->flags |= PG_WANTED;
171 UVM_UNLOCK_AND_WAIT(pg, &uobj->vmobjlock, 0,
172 "aogetpg", 0);
173 goto retrylookup;
174 }
175 pg->flags |= PG_BUSY;
176 pgs[i] = pg;
177 } else {
178 pg = uvm_pagealloc(uobj,
179 off + (i << PAGE_SHIFT), NULL, UVM_PGA_ZERO);
180 pgs[i] = pg;
181 }
182 }
183 mutex_exit(&uobj->vmobjlock);
184
185 return 0;
186
187 }
188
189 static int
190 ao_put(struct uvm_object *uobj, voff_t start, voff_t stop, int flags)
191 {
192 struct vm_page *pg;
193
194 /* we only free all pages for now */
195 if ((flags & PGO_FREE) == 0 || (flags & PGO_ALLPAGES) == 0) {
196 mutex_exit(&uobj->vmobjlock);
197 return 0;
198 }
199
200 while ((pg = TAILQ_FIRST(&uobj->memq)) != NULL)
201 uvm_pagefree(pg);
202 mutex_exit(&uobj->vmobjlock);
203
204 return 0;
205 }
206
207 struct uvm_object *
208 uao_create(vsize_t size, int flags)
209 {
210 struct uvm_object *uobj;
211
212 uobj = kmem_zalloc(sizeof(struct uvm_object), KM_SLEEP);
213 uobj->pgops = &aobj_pager;
214 TAILQ_INIT(&uobj->memq);
215 mutex_init(&uobj->vmobjlock, MUTEX_DEFAULT, IPL_NONE);
216
217 return uobj;
218 }
219
220 void
221 uao_detach(struct uvm_object *uobj)
222 {
223
224 mutex_enter(&uobj->vmobjlock);
225 ao_put(uobj, 0, 0, PGO_ALLPAGES | PGO_FREE);
226 mutex_destroy(&uobj->vmobjlock);
227 kmem_free(uobj, sizeof(*uobj));
228 }
229
230 /*
231 * Misc routines
232 */
233
234 static kmutex_t pagermtx;
235
236 void
237 uvm_init(void)
238 {
239
240 uvmexp.free = 1024*1024; /* XXX */
241 rump_vmspace.vm_map.pmap = pmap_kernel();
242
243 mutex_init(&pagermtx, MUTEX_DEFAULT, 0);
244 mutex_init(&uvm_pageqlock, MUTEX_DEFAULT, 0);
245
246 mutex_init(&pdaemonmtx, MUTEX_DEFAULT, 0);
247 cv_init(&pdaemoncv, "pdaemon");
248 cv_init(&oomwait, "oomwait");
249
250 kernel_map->pmap = pmap_kernel();
251 callback_head_init(&kernel_map_store.vmk_reclaim_callback, IPL_VM);
252 kmem_map->pmap = pmap_kernel();
253 callback_head_init(&kmem_map_store.vmk_reclaim_callback, IPL_VM);
254 }
255
256
257 void
258 uvm_pagewire(struct vm_page *pg)
259 {
260
261 /* nada */
262 }
263
264 void
265 uvm_pageunwire(struct vm_page *pg)
266 {
267
268 /* nada */
269 }
270
271 /*
272 * This satisfies the "disgusting mmap hack" used by proplib.
273 * We probably should grow some more assertables to make sure we're
274 * not satisfying anything we shouldn't be satisfying. At least we
275 * should make sure it's the local machine we're mmapping ...
276 */
277 int
278 uvm_mmap(struct vm_map *map, vaddr_t *addr, vsize_t size, vm_prot_t prot,
279 vm_prot_t maxprot, int flags, void *handle, voff_t off, vsize_t locklim)
280 {
281 void *uaddr;
282 int error;
283
284 if (prot != (VM_PROT_READ | VM_PROT_WRITE))
285 panic("uvm_mmap() variant unsupported");
286 if (flags != (MAP_PRIVATE | MAP_ANON))
287 panic("uvm_mmap() variant unsupported");
288 /* no reason in particular, but cf. uvm_default_mapaddr() */
289 if (*addr != 0)
290 panic("uvm_mmap() variant unsupported");
291
292 uaddr = rumpuser_anonmmap(NULL, size, 0, 0, &error);
293 if (uaddr == NULL)
294 return error;
295
296 *addr = (vaddr_t)uaddr;
297 return 0;
298 }
299
300 struct pagerinfo {
301 vaddr_t pgr_kva;
302 int pgr_npages;
303 struct vm_page **pgr_pgs;
304 bool pgr_read;
305
306 LIST_ENTRY(pagerinfo) pgr_entries;
307 };
308 static LIST_HEAD(, pagerinfo) pagerlist = LIST_HEAD_INITIALIZER(pagerlist);
309
310 /*
311 * Pager "map" in routine. Instead of mapping, we allocate memory
312 * and copy page contents there. Not optimal or even strictly
313 * correct (the caller might modify the page contents after mapping
314 * them in), but what the heck. Assumes UVMPAGER_MAPIN_WAITOK.
315 */
316 vaddr_t
317 uvm_pagermapin(struct vm_page **pgs, int npages, int flags)
318 {
319 struct pagerinfo *pgri;
320 vaddr_t curkva;
321 int i;
322
323 /* allocate structures */
324 pgri = kmem_alloc(sizeof(*pgri), KM_SLEEP);
325 pgri->pgr_kva = (vaddr_t)kmem_alloc(npages * PAGE_SIZE, KM_SLEEP);
326 pgri->pgr_npages = npages;
327 pgri->pgr_pgs = kmem_alloc(sizeof(struct vm_page *) * npages, KM_SLEEP);
328 pgri->pgr_read = (flags & UVMPAGER_MAPIN_READ) != 0;
329
330 /* copy contents to "mapped" memory */
331 for (i = 0, curkva = pgri->pgr_kva;
332 i < npages;
333 i++, curkva += PAGE_SIZE) {
334 /*
335 * We need to copy the previous contents of the pages to
336 * the window even if we are reading from the
337 * device, since the device might not fill the contents of
338 * the full mapped range and we will end up corrupting
339 * data when we unmap the window.
340 */
341 memcpy((void*)curkva, pgs[i]->uanon, PAGE_SIZE);
342 pgri->pgr_pgs[i] = pgs[i];
343 }
344
345 mutex_enter(&pagermtx);
346 LIST_INSERT_HEAD(&pagerlist, pgri, pgr_entries);
347 mutex_exit(&pagermtx);
348
349 return pgri->pgr_kva;
350 }
351
352 /*
353 * map out the pager window. return contents from VA to page storage
354 * and free structures.
355 *
356 * Note: does not currently support partial frees
357 */
358 void
359 uvm_pagermapout(vaddr_t kva, int npages)
360 {
361 struct pagerinfo *pgri;
362 vaddr_t curkva;
363 int i;
364
365 mutex_enter(&pagermtx);
366 LIST_FOREACH(pgri, &pagerlist, pgr_entries) {
367 if (pgri->pgr_kva == kva)
368 break;
369 }
370 KASSERT(pgri);
371 if (pgri->pgr_npages != npages)
372 panic("uvm_pagermapout: partial unmapping not supported");
373 LIST_REMOVE(pgri, pgr_entries);
374 mutex_exit(&pagermtx);
375
376 if (pgri->pgr_read) {
377 for (i = 0, curkva = pgri->pgr_kva;
378 i < pgri->pgr_npages;
379 i++, curkva += PAGE_SIZE) {
380 memcpy(pgri->pgr_pgs[i]->uanon,(void*)curkva,PAGE_SIZE);
381 }
382 }
383
384 kmem_free(pgri->pgr_pgs, npages * sizeof(struct vm_page *));
385 kmem_free((void*)pgri->pgr_kva, npages * PAGE_SIZE);
386 kmem_free(pgri, sizeof(*pgri));
387 }
388
389 /*
390 * convert va in pager window to page structure.
391 * XXX: how expensive is this (global lock, list traversal)?
392 */
393 struct vm_page *
394 uvm_pageratop(vaddr_t va)
395 {
396 struct pagerinfo *pgri;
397 struct vm_page *pg = NULL;
398 int i;
399
400 mutex_enter(&pagermtx);
401 LIST_FOREACH(pgri, &pagerlist, pgr_entries) {
402 if (pgri->pgr_kva <= va
403 && va < pgri->pgr_kva + pgri->pgr_npages*PAGE_SIZE)
404 break;
405 }
406 if (pgri) {
407 i = (va - pgri->pgr_kva) >> PAGE_SHIFT;
408 pg = pgri->pgr_pgs[i];
409 }
410 mutex_exit(&pagermtx);
411
412 return pg;
413 }
414
415 /* Called with the vm object locked */
416 struct vm_page *
417 uvm_pagelookup(struct uvm_object *uobj, voff_t off)
418 {
419 struct vm_page *pg;
420
421 TAILQ_FOREACH(pg, &uobj->memq, listq.queue) {
422 if (pg->offset == off) {
423 return pg;
424 }
425 }
426
427 return NULL;
428 }
429
430 void
431 uvm_page_unbusy(struct vm_page **pgs, int npgs)
432 {
433 struct vm_page *pg;
434 int i;
435
436 for (i = 0; i < npgs; i++) {
437 pg = pgs[i];
438 if (pg == NULL)
439 continue;
440
441 KASSERT(pg->flags & PG_BUSY);
442 if (pg->flags & PG_WANTED)
443 wakeup(pg);
444 if (pg->flags & PG_RELEASED)
445 uvm_pagefree(pg);
446 else
447 pg->flags &= ~(PG_WANTED|PG_BUSY);
448 }
449 }
450
451 void
452 uvm_estimatepageable(int *active, int *inactive)
453 {
454
455 /* XXX: guessing game */
456 *active = 1024;
457 *inactive = 1024;
458 }
459
460 struct vm_map_kernel *
461 vm_map_to_kernel(struct vm_map *map)
462 {
463
464 return (struct vm_map_kernel *)map;
465 }
466
467 bool
468 vm_map_starved_p(struct vm_map *map)
469 {
470
471 if (map->flags & VM_MAP_WANTVA)
472 return true;
473
474 return false;
475 }
476
477 int
478 uvm_loan(struct vm_map *map, vaddr_t start, vsize_t len, void *v, int flags)
479 {
480
481 panic("%s: unimplemented", __func__);
482 }
483
484 void
485 uvm_unloan(void *v, int npages, int flags)
486 {
487
488 panic("%s: unimplemented", __func__);
489 }
490
491 int
492 uvm_loanuobjpages(struct uvm_object *uobj, voff_t pgoff, int orignpages,
493 struct vm_page **opp)
494 {
495
496 return EBUSY;
497 }
498
499 #ifdef DEBUGPRINT
500 void
501 uvm_object_printit(struct uvm_object *uobj, bool full,
502 void (*pr)(const char *, ...))
503 {
504
505 pr("VM OBJECT at %p, refs %d", uobj, uobj->uo_refs);
506 }
507 #endif
508
509 vaddr_t
510 uvm_default_mapaddr(struct proc *p, vaddr_t base, vsize_t sz)
511 {
512
513 return 0;
514 }
515
516 int
517 uvm_map_protect(struct vm_map *map, vaddr_t start, vaddr_t end,
518 vm_prot_t prot, bool set_max)
519 {
520
521 return EOPNOTSUPP;
522 }
523
524 /*
525 * UVM km
526 */
527
528 vaddr_t
529 uvm_km_alloc(struct vm_map *map, vsize_t size, vsize_t align, uvm_flag_t flags)
530 {
531 void *rv;
532 int alignbit, error;
533
534 alignbit = 0;
535 if (align) {
536 alignbit = ffs(align)-1;
537 }
538
539 rv = rumpuser_anonmmap(NULL, size, alignbit, flags & UVM_KMF_EXEC,
540 &error);
541 if (rv == NULL) {
542 if (flags & (UVM_KMF_CANFAIL | UVM_KMF_NOWAIT))
543 return 0;
544 else
545 panic("uvm_km_alloc failed");
546 }
547
548 if (flags & UVM_KMF_ZERO)
549 memset(rv, 0, size);
550
551 return (vaddr_t)rv;
552 }
553
554 void
555 uvm_km_free(struct vm_map *map, vaddr_t vaddr, vsize_t size, uvm_flag_t flags)
556 {
557
558 rumpuser_unmap((void *)vaddr, size);
559 }
560
561 struct vm_map *
562 uvm_km_suballoc(struct vm_map *map, vaddr_t *minaddr, vaddr_t *maxaddr,
563 vsize_t size, int pageable, bool fixed, struct vm_map_kernel *submap)
564 {
565
566 return (struct vm_map *)417416;
567 }
568
569 vaddr_t
570 uvm_km_alloc_poolpage(struct vm_map *map, bool waitok)
571 {
572
573 return (vaddr_t)rump_hypermalloc(PAGE_SIZE, PAGE_SIZE,
574 waitok, "kmalloc");
575 }
576
577 void
578 uvm_km_free_poolpage(struct vm_map *map, vaddr_t addr)
579 {
580
581 rumpuser_free((void *)addr);
582 }
583
584 vaddr_t
585 uvm_km_alloc_poolpage_cache(struct vm_map *map, bool waitok)
586 {
587
588 return uvm_km_alloc_poolpage(map, waitok);
589 }
590
591 void
592 uvm_km_free_poolpage_cache(struct vm_map *map, vaddr_t vaddr)
593 {
594
595 uvm_km_free_poolpage(map, vaddr);
596 }
597
598 void
599 uvm_km_va_drain(struct vm_map *map, uvm_flag_t flags)
600 {
601
602 /* we eventually maybe want some model for available memory */
603 }
604
605 /*
606 * Mapping and vm space locking routines.
607 * XXX: these don't work for non-local vmspaces
608 */
609 int
610 uvm_vslock(struct vmspace *vs, void *addr, size_t len, vm_prot_t access)
611 {
612
613 KASSERT(vs == &rump_vmspace);
614 return 0;
615 }
616
617 void
618 uvm_vsunlock(struct vmspace *vs, void *addr, size_t len)
619 {
620
621 KASSERT(vs == &rump_vmspace);
622 }
623
624 void
625 vmapbuf(struct buf *bp, vsize_t len)
626 {
627
628 bp->b_saveaddr = bp->b_data;
629 }
630
631 void
632 vunmapbuf(struct buf *bp, vsize_t len)
633 {
634
635 bp->b_data = bp->b_saveaddr;
636 bp->b_saveaddr = 0;
637 }
638
639 void
640 uvmspace_free(struct vmspace *vm)
641 {
642
643 /* nothing for now */
644 }
645
646 int
647 uvm_io(struct vm_map *map, struct uio *uio)
648 {
649
650 /*
651 * just do direct uio for now. but this needs some vmspace
652 * olympics for rump_sysproxy.
653 */
654 return uiomove((void *)(vaddr_t)uio->uio_offset, uio->uio_resid, uio);
655 }
656
657 /*
658 * page life cycle stuff. it really doesn't exist, so just stubs.
659 */
660
661 void
662 uvm_pageactivate(struct vm_page *pg)
663 {
664
665 /* nada */
666 }
667
668 void
669 uvm_pagedeactivate(struct vm_page *pg)
670 {
671
672 /* nada */
673 }
674
675 void
676 uvm_pagedequeue(struct vm_page *pg)
677 {
678
679 /* nada*/
680 }
681
682 void
683 uvm_pageenqueue(struct vm_page *pg)
684 {
685
686 /* nada */
687 }
688
689 /*
690 * Routines related to the Page Baroness.
691 */
692
693 void
694 uvm_wait(const char *msg)
695 {
696
697 if (__predict_false(curlwp == uvm.pagedaemon_lwp))
698 panic("pagedaemon out of memory");
699 if (__predict_false(rump_threads == 0))
700 panic("pagedaemon missing (RUMP_THREADS = 0)");
701
702 mutex_enter(&pdaemonmtx);
703 pdaemon_waiters++;
704 cv_signal(&pdaemoncv);
705 cv_wait(&oomwait, &pdaemonmtx);
706 mutex_exit(&pdaemonmtx);
707 }
708
709 void
710 uvm_pageout_start(int npages)
711 {
712
713 /* we don't have the heuristics */
714 }
715
716 void
717 uvm_pageout_done(int npages)
718 {
719
720 /* could wakeup waiters, but just let the pagedaemon do it */
721 }
722
723 /*
724 * Under-construction page mistress. This is lacking vfs support, namely:
725 *
726 * 1) draining vfs buffers
727 * 2) paging out pages in vm vnode objects
728 * (we will not page out anon memory on the basis that
729 * that's the task of the host)
730 */
731
732 void
733 uvm_pageout(void *arg)
734 {
735 struct pool *pp, *pp_first;
736 uint64_t where;
737 int timo = 0;
738 bool succ;
739
740 mutex_enter(&pdaemonmtx);
741 for (;;) {
742 cv_timedwait(&pdaemoncv, &pdaemonmtx, timo);
743 uvmexp.pdwoke++;
744 kernel_map->flags |= VM_MAP_WANTVA;
745 mutex_exit(&pdaemonmtx);
746
747 succ = false;
748 pool_drain_start(&pp_first, &where);
749 pp = pp_first;
750 for (;;) {
751 succ = pool_drain_end(pp, where);
752 if (succ)
753 break;
754 pool_drain_start(&pp, &where);
755 if (pp == pp_first) {
756 succ = pool_drain_end(pp, where);
757 break;
758 }
759 }
760 mutex_enter(&pdaemonmtx);
761
762 if (!succ) {
763 rumpuser_dprintf("pagedaemoness: failed to reclaim "
764 "memory ... sleeping (deadlock?)\n");
765 timo = hz;
766 continue;
767 }
768 kernel_map->flags &= ~VM_MAP_WANTVA;
769 timo = 0;
770
771 if (pdaemon_waiters) {
772 pdaemon_waiters = 0;
773 cv_broadcast(&oomwait);
774 }
775 }
776
777 panic("you can swap out any time you like, but you can never leave");
778 }
779
780 /*
781 * In a regular kernel the pagedaemon is activated when memory becomes
782 * low. In a virtual rump kernel we do not know exactly how much memory
783 * we have available -- it depends on the conditions on the host.
784 * Therefore, we cannot preemptively kick the pagedaemon. Rather, we
785 * wait until things we desperate and we're forced to uvm_wait().
786 *
787 * The alternative would be to allocate a huge chunk of memory at
788 * startup, but that solution has a number of problems including
789 * being a resource hog, failing anyway due to host memory overcommit
790 * and core dump size.
791 */
792
793 void
794 uvm_kick_pdaemon()
795 {
796
797 /* nada */
798 }
799
800 void *
801 rump_hypermalloc(size_t howmuch, int alignment, bool waitok, const char *wmsg)
802 {
803 void *rv;
804
805 again:
806 rv = rumpuser_malloc(howmuch, alignment);
807 if (__predict_false(rv == NULL && waitok)) {
808 uvm_wait(wmsg);
809 goto again;
810 }
811
812 return rv;
813 }
814