Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/uvm Pull up revision 1.11 (requested by chs):



details:   https://anonhg.NetBSD.org/src/rev/7d8af21d3ec1
branches:  netbsd-1-5
changeset: 492772:7d8af21d3ec1
user:      he <he%NetBSD.org@localhost>
date:      Thu Feb 14 19:53:00 2002 +0000

description:
Pull up revision 1.11 (requested by chs):
  Make memory allocation failures during ``swapctl -a'' return an error
  instead of causing a panic.

diffstat:

 sys/uvm/uvm_anon.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (51 lines):

diff -r b545fd1ed85a -r 7d8af21d3ec1 sys/uvm/uvm_anon.c
--- a/sys/uvm/uvm_anon.c        Thu Feb 14 19:52:47 2002 +0000
+++ b/sys/uvm/uvm_anon.c        Thu Feb 14 19:53:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_anon.c,v 1.5.4.2 2000/08/06 17:09:58 thorpej Exp $ */
+/*     $NetBSD: uvm_anon.c,v 1.5.4.3 2002/02/14 19:53:00 he Exp $      */
 
 /*
  *
@@ -92,7 +92,7 @@
  *
  * => swap_syscall_lock should be held (protects anonblock_list).
  */
-void
+int
 uvm_anon_add(count)
        int     count;
 {
@@ -106,17 +106,16 @@
        simple_unlock(&uvm.afreelock);
 
        if (needed <= 0) {
-               return;
+               return 0;
        }
- 
-       MALLOC(anonblock, void *, sizeof(*anonblock), M_UVMAMAP, M_WAITOK);
        anon = (void *)uvm_km_alloc(kernel_map, sizeof(*anon) * needed);
-
-       /* XXX Should wait for VM to free up. */
-       if (anonblock == NULL || anon == NULL) {
-               printf("uvm_anon_add: can not allocate %d anons\n", needed);
-               panic("uvm_anon_add");
+       if (anon == NULL) {
+               simple_lock(&uvm.afreelock);
+               uvmexp.nanonneeded -= count;
+               simple_unlock(&uvm.afreelock);
+               return ENOMEM;
        }
+       MALLOC(anonblock, void *, sizeof(*anonblock), M_UVMAMAP, M_WAITOK);
 
        anonblock->count = needed;
        anonblock->anons = anon;
@@ -133,6 +132,7 @@
                simple_lock_init(&uvm.afree->an_lock);
        }
        simple_unlock(&uvm.afreelock);
+       return 0;
 }
 
 /*



Home | Main Index | Thread Index | Old Index