Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Replace "malloc" in comments, remove unnecessary hea...



details:   https://anonhg.NetBSD.org/src/rev/c9d67d5a1eaa
branches:  trunk
changeset: 764447:c9d67d5a1eaa
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sat Apr 23 18:14:12 2011 +0000

description:
Replace "malloc" in comments, remove unnecessary header inclusions.

diffstat:

 sys/uvm/uvm_amap.c    |  34 +++++++++++++++++++---------------
 sys/uvm/uvm_amap.h    |   4 ++--
 sys/uvm/uvm_anon.c    |   6 ++----
 sys/uvm/uvm_aobj.c    |   8 ++++----
 sys/uvm/uvm_device.c  |   6 +++---
 sys/uvm/uvm_extern.h  |   4 ++--
 sys/uvm/uvm_fault.c   |   6 ++----
 sys/uvm/uvm_init.c    |   6 ++----
 sys/uvm/uvm_io.c      |   6 ++----
 sys/uvm/uvm_kmguard.c |   6 ++----
 sys/uvm/uvm_loan.c    |   6 ++----
 sys/uvm/uvm_mmap.c    |   6 ++----
 sys/uvm/uvm_pager.c   |   6 ++----
 sys/uvm/uvm_pglist.c  |   6 ++----
 sys/uvm/uvm_stat.h    |  10 ++++------
 sys/uvm/uvm_swap.c    |  10 +++++-----
 sys/uvm/uvm_vnode.c   |   6 ++----
 17 files changed, 59 insertions(+), 77 deletions(-)

diffs (truncated from 530 to 300 lines):

diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c        Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_amap.c        Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_amap.c,v 1.89 2011/02/02 15:13:33 chuck Exp $      */
+/*     $NetBSD: uvm_amap.c,v 1.90 2011/04/23 18:14:12 rmind Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,13 +35,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.89 2011/02/02 15:13:33 chuck Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.90 2011/04/23 18:14:12 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/proc.h>
 #include <sys/kernel.h>
 #include <sys/kmem.h>
 #include <sys/pool.h>
@@ -98,8 +97,8 @@
  * when enabled, an array of ints is allocated for the pprefs.  this
  * array is allocated only when a partial reference is added to the
  * map (either by unmapping part of the amap, or gaining a reference
- * to only a part of an amap).  if the malloc of the array fails
- * (M_NOWAIT), then we set the array pointer to PPREF_NONE to indicate
+ * to only a part of an amap).  if the allocation of the array fails
+ * (KM_NOSLEEP), then we set the array pointer to PPREF_NONE to indicate
  * that we tried to do ppref's but couldn't alloc the array so just
  * give up (after all, this is an optional feature!).
  *
@@ -190,6 +189,10 @@
        amap->am_nslot = slots;
        amap->am_nused = 0;
 
+       /*
+        * Note: since allocations are likely big, we expect to reduce the
+        * memory fragmentation by allocating them in separate blocks.
+        */
        amap->am_slots = kmem_alloc(totalslots * sizeof(int), kmflags);
        if (amap->am_slots == NULL)
                goto fail1;
@@ -475,15 +478,15 @@
        }
 
        /*
-        * case 3: we need to malloc a new amap and copy all the amap
-        * data over from old amap to the new one.
+        * Case 3: we need to allocate a new amap and copy all the amap
+        * data over from old amap to the new one.  Drop the lock before
+        * performing allocation.
         *
-        * note that the use of a kernel realloc() probably would not
-        * help here, since we wish to abort cleanly if one of the
-        * three (or four) mallocs fails.
+        * Note: since allocations are likely big, we expect to reduce the
+        * memory fragmentation by allocating them in separate blocks.
         */
 
-       amap_unlock(amap);      /* unlock in case we sleep in malloc */
+       amap_unlock(amap);
 
        if (slotneed >= UVM_AMAP_LARGE) {
                return E2BIG;
@@ -492,8 +495,10 @@
        slotalloc = amap_roundup_slots(slotneed);
 #ifdef UVM_AMAP_PPREF
        newppref = NULL;
-       if (amap->am_ppref && amap->am_ppref != PPREF_NONE)
+       if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
+               /* Will be handled later if fails. */
                newppref = kmem_alloc(slotalloc * sizeof(*newppref), kmflags);
+       }
 #endif
        newsl = kmem_alloc(slotalloc * sizeof(*newsl), kmflags);
        newbck = kmem_alloc(slotalloc * sizeof(*newbck), kmflags);
@@ -519,7 +524,7 @@
        KASSERT(amap->am_maxslot < slotneed);
 
        /*
-        * now copy everything over to new malloc'd areas...
+        * Copy everything over to new allocated areas.
         */
 
        slotadded = slotalloc - amap->am_nslot;
@@ -829,7 +834,7 @@
        /*
         * need to double check reference count now that we've got the
         * src amap locked down.  the reference count could have
-        * changed while we were in malloc.  if the reference count
+        * changed while we were allocating.  if the reference count
         * dropped down to one we take over the old map rather than
         * copying the amap.
         */
@@ -1587,4 +1592,3 @@
 
        UVMHIST_LOG(maphist,"<- done!", 0, 0, 0, 0);
 }
-
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_amap.h
--- a/sys/uvm/uvm_amap.h        Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_amap.h        Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_amap.h,v 1.35 2011/02/02 15:13:33 chuck Exp $      */
+/*     $NetBSD: uvm_amap.h,v 1.36 2011/04/23 18:14:12 rmind Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -208,7 +208,7 @@
  * of this VM is actually used.  since the stack is anonymous memory
  * it makes sense for it to live in an amap, but if we allocated an
  * amap for the entire stack range we could end up wasting a large
- * amount of malloc'd KVM.
+ * amount of allocated KVM.
  *
  * for example, on the i386 at boot time we allocate two amaps for the stack
  * of /sbin/init:
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_anon.c
--- a/sys/uvm/uvm_anon.c        Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_anon.c        Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_anon.c,v 1.52 2011/02/02 15:13:34 chuck Exp $      */
+/*     $NetBSD: uvm_anon.c,v 1.53 2011/04/23 18:14:12 rmind Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -30,14 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.52 2011/02/02 15:13:34 chuck Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.53 2011/04/23 18:14:12 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
 #include <sys/pool.h>
 #include <sys/kernel.h>
 
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_aobj.c
--- a/sys/uvm/uvm_aobj.c        Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_aobj.c        Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_aobj.c,v 1.113 2011/02/11 00:21:18 rmind Exp $     */
+/*     $NetBSD: uvm_aobj.c,v 1.114 2011/04/23 18:14:12 rmind Exp $     */
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.113 2011/02/11 00:21:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.114 2011/04/23 18:14:12 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -442,7 +442,7 @@
        int refs;
 
        /*
-        * malloc a new aobj unless we are asked for the kernel object
+        * Allocate a new aobj, unless kernel object is requested.
         */
 
        if (flags & UAO_FLAG_KERNOBJ) {
@@ -486,7 +486,7 @@
                        aobj->u_swslots = kmem_zalloc(pages * sizeof(int),
                            kernswap ? KM_NOSLEEP : KM_SLEEP);
                        if (aobj->u_swslots == NULL)
-                               panic("uao_create: malloc swslots failed");
+                               panic("uao_create: swslots allocation failed");
                }
 #endif /* defined(VMSWAP) */
 
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_device.c
--- a/sys/uvm/uvm_device.c      Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_device.c      Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_device.c,v 1.60 2011/02/12 14:45:31 jmcneill Exp $ */
+/*     $NetBSD: uvm_device.c,v 1.61 2011/04/23 18:14:12 rmind Exp $    */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.60 2011/02/12 14:45:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.61 2011/04/23 18:14:12 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -210,7 +210,7 @@
                }
 
                /*
-                * did not find it on main list.   need to malloc a new one.
+                * Did not find it on main list.  Need to allocate a new one.
                 */
 
                mutex_exit(&udv_lock);
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h      Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_extern.h      Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_extern.h,v 1.171 2011/02/17 19:27:13 matt Exp $    */
+/*     $NetBSD: uvm_extern.h,v 1.172 2011/04/23 18:14:12 rmind Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -135,7 +135,7 @@
 #define UVM_FLAG_OVERLAY 0x020000 /* establish overlay */
 #define UVM_FLAG_NOMERGE 0x040000 /* don't merge map entries */
 #define UVM_FLAG_COPYONW 0x080000 /* set copy_on_write flag */
-#define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce malloc() */
+#define UVM_FLAG_AMAPPAD 0x100000 /* for bss: pad amap to reduce allocations */
 #define UVM_FLAG_TRYLOCK 0x200000 /* fail if we can not lock map */
 #define UVM_FLAG_NOWAIT  0x400000 /* not allowed to sleep */
 #define UVM_FLAG_QUANTUM 0x800000 /* entry can never be split later */
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c       Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_fault.c       Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_fault.c,v 1.183 2011/04/08 10:42:51 yamt Exp $     */
+/*     $NetBSD: uvm_fault.c,v 1.184 2011/04/23 18:14:12 rmind Exp $    */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,15 +32,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.183 2011/04/08 10:42:51 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.184 2011/04/23 18:14:12 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
 #include <sys/mman.h>
 
 #include <uvm/uvm.h>
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_init.c
--- a/sys/uvm/uvm_init.c        Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_init.c        Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_init.c,v 1.39 2011/02/02 15:13:34 chuck Exp $      */
+/*     $NetBSD: uvm_init.c,v 1.40 2011/04/23 18:14:12 rmind Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.39 2011/02/02 15:13:34 chuck Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.40 2011/04/23 18:14:12 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,8 +42,6 @@
 #include <sys/resourcevar.h>
 #include <sys/kmem.h>
 #include <sys/mman.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
 #include <sys/vnode.h>
 
 #include <uvm/uvm.h>
diff -r ea0725eb6378 -r c9d67d5a1eaa sys/uvm/uvm_io.c
--- a/sys/uvm/uvm_io.c  Sat Apr 23 16:46:51 2011 +0000
+++ b/sys/uvm/uvm_io.c  Sat Apr 23 18:14:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_io.c,v 1.25 2011/02/02 15:13:34 chuck Exp $        */
+/*     $NetBSD: uvm_io.c,v 1.26 2011/04/23 18:14:12 rmind Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,13 +32,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.25 2011/02/02 15:13:34 chuck Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_io.c,v 1.26 2011/04/23 18:14:12 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mman.h>
-#include <sys/proc.h>



Home | Main Index | Thread Index | Old Index