Source-Changes-HG archive

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

[src/trunk]: src extending vmem(9) to be able to allocated resources for it's...



details:   https://anonhg.NetBSD.org/src/rev/f3ff6a1bd7a5
branches:  trunk
changeset: 773085:f3ff6a1bd7a5
user:      para <para%NetBSD.org@localhost>
date:      Fri Jan 27 19:48:38 2012 +0000

description:
extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/arc.c |   39 +-
 sys/arch/alpha/alpha/pmap.c                      |   11 +-
 sys/arch/amd64/amd64/machdep.c                   |   12 +-
 sys/arch/arm/arm32/pmap.c                        |   12 +-
 sys/arch/m68k/m68k/pmap_motorola.c               |    6 +-
 sys/arch/mips/mips/pmap.c                        |   11 +-
 sys/arch/powerpc/booke/booke_pmap.c              |   11 +-
 sys/arch/powerpc/ibm4xx/pmap.c                   |   10 +-
 sys/arch/x86/x86/pmap.c                          |   40 +-
 sys/arch/xen/xen/xbd_xenbus.c                    |   15 +-
 sys/dev/iscsi/iscsi_ioctl.c                      |    4 +-
 sys/dev/pci/twa.c                                |   26 +-
 sys/dev/pci/twe.c                                |   19 +-
 sys/external/bsd/drm/dist/bsd-core/drm_bufs.c    |   16 +
 sys/fs/efs/efs_ihash.c                           |    5 +-
 sys/fs/ntfs/ntfs_ihash.c                         |    5 +-
 sys/fs/smbfs/smbfs_kq.c                          |    5 +-
 sys/fs/smbfs/smbfs_vnops.c                       |    5 +-
 sys/kern/core_elf32.c                            |   13 +-
 sys/kern/kern_malloc.c                           |  706 +---------------------
 sys/kern/subr_extent.c                           |   11 +-
 sys/kern/subr_kmem.c                             |  435 ++++++-------
 sys/kern/subr_percpu.c                           |    8 +-
 sys/kern/subr_pool.c                             |  262 ++-----
 sys/kern/subr_vmem.c                             |  518 +++++++++++++---
 sys/kern/uipc_mbuf.c                             |    6 +-
 sys/kern/uipc_socket.c                           |   22 +-
 sys/kern/vfs_bio.c                               |   23 +-
 sys/kern/vfs_wapbl.c                             |   12 +-
 sys/rump/librump/rumpkern/vm.c                   |  104 +--
 sys/sys/kmem.h                                   |    3 +-
 sys/sys/pool.h                                   |    8 +-
 sys/sys/sysctl.h                                 |    3 +-
 sys/sys/vmem.h                                   |   31 +-
 sys/uvm/uvm_amap.c                               |    8 +-
 sys/uvm/uvm_device.c                             |   12 +-
 sys/uvm/uvm_extern.h                             |   42 +-
 sys/uvm/uvm_fault.c                              |   24 +-
 sys/uvm/uvm_glue.c                               |   39 +-
 sys/uvm/uvm_init.c                               |   44 +-
 sys/uvm/uvm_io.c                                 |    6 +-
 sys/uvm/uvm_km.c                                 |  414 +++++--------
 sys/uvm/uvm_km.h                                 |    6 +-
 sys/uvm/uvm_kmguard.c                            |    8 +-
 sys/uvm/uvm_map.c                                |  665 +-------------------
 sys/uvm/uvm_map.h                                |   61 +-
 sys/uvm/uvm_meter.c                              |   10 +-
 sys/uvm/uvm_mmap.c                               |    6 +-
 sys/uvm/uvm_page.c                               |   35 +-
 sys/uvm/uvm_pager.c                              |    6 +-
 sys/uvm/uvm_pdaemon.c                            |   57 +-
 sys/uvm/uvm_pdpolicy_clock.c                     |   21 +-
 sys/uvm/uvm_swap.c                               |   40 +-
 usr.bin/pmap/pmap.c                              |    9 +-
 54 files changed, 1335 insertions(+), 2595 deletions(-)

diffs (truncated from 6901 to 300 lines):

diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 external/cddl/osnet/dist/uts/common/fs/zfs/arc.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c  Fri Jan 27 19:22:48 2012 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c  Fri Jan 27 19:48:38 2012 +0000
@@ -152,33 +152,12 @@
 #define        curproc         curlwp
 #define        proc_pageout    uvm.pagedaemon_lwp
 
-#define        heap_arena      kernel_map
-#define        VMEM_ALLOC      1
-#define        VMEM_FREE       2
-static inline size_t
-vmem_size(struct vm_map *map, int flag)
-{
-       switch (flag) {
-       case VMEM_ALLOC:
-               return map->size;
-       case VMEM_FREE:
-               return vm_map_max(map) - vm_map_min(map) - map->size;
-       case VMEM_FREE|VMEM_ALLOC:
-               return vm_map_max(map) - vm_map_min(map);
-       default:
-               panic("vmem_size");
-       }
-}
 static void    *zio_arena;
 
 #include <sys/callback.h>
 /* Structures used for memory and kva space reclaim. */
 static struct callback_entry arc_kva_reclaim_entry;
 
-#ifdef _KERNEL
-static struct uvm_reclaim_hook arc_hook;
-#endif
-
 #endif /* __NetBSD__ */
 
 static kmutex_t                arc_reclaim_thr_lock;
@@ -2028,7 +2007,7 @@
        /*
         * If we're on an i386 platform, it's possible that we'll exhaust the
         * kernel heap space before we ever run out of available physical
-        * memory.  Most checks of the size of the heap_area compare against
+        * memory.  Most checks of the size of the kmem_area compare against
         * tune.t_minarmem, which is the minimum available real memory that we
         * can have in the system.  However, this is generally fixed at 25 pages
         * which is so low that it's useless.  In this comparison, we seek to
@@ -2036,8 +2015,8 @@
         * heap is allocated.  (Or, in the calculation, if less than 1/4th is
         * free)
         */
-       if (btop(vmem_size(heap_arena, VMEM_FREE)) <
-           (btop(vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC)) >> 2))
+       if (btop(vmem_size(kmem_arena, VMEM_FREE)) <
+           (btop(vmem_size(kmem_arena, VMEM_FREE | VMEM_ALLOC)) >> 2))
                return (1);
 #endif
 
@@ -3359,7 +3338,7 @@
        static uint64_t last_txg = 0;
 
        available_memory =
-           MIN(available_memory, vmem_size(heap_arena, VMEM_FREE));
+           MIN(available_memory, vmem_size(kmem_arena, VMEM_FREE));
        if (available_memory >= zfs_write_limit_max)
                return (0);
 
@@ -3511,7 +3490,7 @@
         * than the addressable space (intel in 32-bit mode), we may
         * need to limit the cache to 1/8 of VM size.
         */
-       arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8);
+       arc_c = MIN(arc_c, vmem_size(kmem_arena, VMEM_ALLOC | VMEM_FREE) / 8);
 #endif
 
        /* set min cache to 1/32 of all memory, or 64MB, whichever is more */
@@ -3615,11 +3594,11 @@
            TS_RUN, maxclsyspri);
 
 #if defined(__NetBSD__) && defined(_KERNEL)
-       arc_hook.uvm_reclaim_hook = &arc_uvm_reclaim_hook;
+/*     arc_hook.uvm_reclaim_hook = &arc_uvm_reclaim_hook;
 
        uvm_reclaim_hook_add(&arc_hook);
        callback_register(&vm_map_to_kernel(kernel_map)->vmk_reclaim_callback,
-           &arc_kva_reclaim_entry, NULL, arc_kva_reclaim_callback);
+           &arc_kva_reclaim_entry, NULL, arc_kva_reclaim_callback); */
 
 #endif
 
@@ -3674,9 +3653,9 @@
        mutex_destroy(&zfs_write_limit_lock);
 
 #if defined(__NetBSD__) && defined(_KERNEL)
-       uvm_reclaim_hook_del(&arc_hook);
+/*     uvm_reclaim_hook_del(&arc_hook);
        callback_unregister(&vm_map_to_kernel(kernel_map)->vmk_reclaim_callback,
-           &arc_kva_reclaim_entry);
+           &arc_kva_reclaim_entry); */
 #endif         
        
        buf_fini();
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Fri Jan 27 19:48:38 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.255 2010/11/12 07:59:25 uebayasi Exp $ */
+/* $NetBSD: pmap.c,v 1.256 2012/01/27 19:48:38 para Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008 The NetBSD Foundation, Inc.
@@ -140,7 +140,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.255 2010/11/12 07:59:25 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.256 2012/01/27 19:48:38 para Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -757,11 +757,6 @@
 #endif
 
        /*
-        * Compute the number of pages kmem_map will have.
-        */
-       kmeminit_nkmempages();
-
-       /*
         * Figure out how many initial PTE's are necessary to map the
         * kernel.  We also reserve space for kmem_alloc_pageable()
         * for vm_fork().
@@ -774,7 +769,7 @@
        lev3mapsize =
                (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
                 bufsz + 16 * NCARGS + pager_map_size) / PAGE_SIZE +
-               (maxproc * UPAGES) + nkmempages;
+               (maxproc * UPAGES) + (256 * 1024 * 1024) / PAGE_SIZE;
 
 #ifdef SYSVSHM
        lev3mapsize += shminfo.shmall;
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Fri Jan 27 19:48:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.174 2012/01/12 19:49:37 cherry Exp $     */
+/*     $NetBSD: machdep.c,v 1.175 2012/01/27 19:48:38 para Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.174 2012/01/12 19:49:37 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175 2012/01/27 19:48:38 para Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -278,7 +278,7 @@
 paddr_t lo32_paddr;
 
 vaddr_t module_start, module_end;
-static struct vm_map_kernel module_map_store;
+static struct vm_map module_map_store;
 extern struct vm_map *module_map;
 vaddr_t kern_end;
 
@@ -386,9 +386,9 @@
        phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
                                   VM_PHYS_SIZE, 0, false, NULL);
 
-       uvm_map_setup_kernel(&module_map_store, module_start, module_end, 0);
-       module_map_store.vmk_map.pmap = pmap_kernel();
-       module_map = &module_map_store.vmk_map;
+       uvm_map_setup(&module_map_store, module_start, module_end, 0);
+       module_map_store.pmap = pmap_kernel();
+       module_map = &module_map_store;
 
        /* Say hello. */
        banner();
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/arm/arm32/pmap.c Fri Jan 27 19:48:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.224 2011/07/01 20:57:45 dyoung Exp $        */
+/*     $NetBSD: pmap.c,v 1.225 2012/01/27 19:48:38 para Exp $  */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -197,12 +197,12 @@
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
-#include <sys/malloc.h>
 #include <sys/pool.h>
+#include <sys/kmem.h>
 #include <sys/cdefs.h>
 #include <sys/cpu.h>
 #include <sys/sysctl.h>
- 
+
 #include <uvm/uvm.h>
 
 #include <sys/bus.h>
@@ -211,7 +211,7 @@
 #include <machine/param.h>
 #include <arm/arm32/katelib.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.224 2011/07/01 20:57:45 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.225 2012/01/27 19:48:38 para Exp $");
 
 #ifdef PMAP_DEBUG
 
@@ -5497,7 +5497,7 @@
        needed = (maxproc / PMAP_DOMAINS) + ((maxproc % PMAP_DOMAINS) ? 1 : 0);
        needed -= 1;
 
-       l1 = malloc(sizeof(*l1) * needed, M_VMPMAP, M_WAITOK);
+       l1 = kmem_alloc(sizeof(*l1) * needed, KM_SLEEP);
 
        for (loop = 0; loop < needed; loop++, l1++) {
                /* Allocate a L1 page table */
@@ -5506,7 +5506,7 @@
                        panic("Cannot allocate L1 KVM");
 
                error = uvm_pglistalloc(L1_TABLE_SIZE, physical_start,
-                   physical_end, L1_TABLE_SIZE, 0, &plist, 1, M_WAITOK);
+                   physical_end, L1_TABLE_SIZE, 0, &plist, 1, 1);
                if (error)
                        panic("Cannot allocate L1 physical pages");
 
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/m68k/m68k/pmap_motorola.c
--- a/sys/arch/m68k/m68k/pmap_motorola.c        Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/m68k/m68k/pmap_motorola.c        Fri Jan 27 19:48:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_motorola.c,v 1.64 2011/11/03 14:39:05 tsutsui Exp $        */
+/*     $NetBSD: pmap_motorola.c,v 1.65 2012/01/27 19:48:38 para Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.64 2011/11/03 14:39:05 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.65 2012/01/27 19:48:38 para Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -243,7 +243,7 @@
 static struct pmap kernel_pmap_store;
 struct pmap    *const kernel_pmap_ptr = &kernel_pmap_store;
 struct vm_map  *st_map, *pt_map;
-struct vm_map_kernel st_map_store, pt_map_store;
+struct vm_map st_map_store, pt_map_store;
 
 vaddr_t                lwp0uarea;      /* lwp0 u-area VA, initialized in bootstrap */
 
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/mips/mips/pmap.c
--- a/sys/arch/mips/mips/pmap.c Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/mips/mips/pmap.c Fri Jan 27 19:48:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.205 2011/09/23 23:02:23 macallan Exp $      */
+/*     $NetBSD: pmap.c,v 1.206 2012/01/27 19:48:39 para Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.205 2011/09/23 23:02:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.206 2012/01/27 19:48:39 para Exp $");
 
 /*
  *     Manages physical address maps.
@@ -496,11 +496,6 @@
        pmap_tlb_info_init(&pmap_tlb0_info);            /* init the lock */
 
        /*
-        * Compute the number of pages kmem_map will have.
-        */
-       kmeminit_nkmempages();
-
-       /*
         * Figure out how many PTE's are necessary to map the kernel.
         * We also reserve space for kmem_alloc_pageable() for vm_fork().
         */
@@ -512,7 +507,7 @@
 
        Sysmapsize = (VM_PHYS_SIZE + (ubc_nwins << ubc_winshift) +
            bufsz + 16 * NCARGS + pager_map_size + iospace_size) / NBPG +
-           (maxproc * UPAGES) + nkmempages;
+           (maxproc * UPAGES) + 1024 * 1024;
 #ifdef DEBUG
        {
                extern int kmem_guard_depth;
diff -r 3e1ff9f2895b -r f3ff6a1bd7a5 sys/arch/powerpc/booke/booke_pmap.c
--- a/sys/arch/powerpc/booke/booke_pmap.c       Fri Jan 27 19:22:48 2012 +0000
+++ b/sys/arch/powerpc/booke/booke_pmap.c       Fri Jan 27 19:48:38 2012 +0000



Home | Main Index | Thread Index | Old Index