Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm provide proper defaults for topdown and bottomup all...



details:   https://anonhg.NetBSD.org/src/rev/ae1e3d42507f
branches:  trunk
changeset: 793042:ae1e3d42507f
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 25 05:14:03 2014 +0000

description:
provide proper defaults for topdown and bottomup allocation.
XXX: Ports that provide their own VM_DEFAULT_ADDRESS() need to provide the
two new flavors, otherwise they get the default ones now.

diffstat:

 sys/uvm/uvm_mmap.c  |   9 ++++++---
 sys/uvm/uvm_param.h |  16 ++++++++++++----
 2 files changed, 18 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r 76082657feb2 -r ae1e3d42507f sys/uvm/uvm_mmap.c
--- a/sys/uvm/uvm_mmap.c        Sat Jan 25 05:09:59 2014 +0000
+++ b/sys/uvm/uvm_mmap.c        Sat Jan 25 05:14:03 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_mmap.c,v 1.145 2013/09/11 18:26:14 martin Exp $    */
+/*     $NetBSD: uvm_mmap.c,v 1.146 2014/01/25 05:14:03 christos Exp $  */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.145 2013/09/11 18:26:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.146 2014/01/25 05:14:03 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_pax.h"
@@ -1253,5 +1253,8 @@
 uvm_default_mapaddr(struct proc *p, vaddr_t base, vsize_t sz)
 {
 
-       return VM_DEFAULT_ADDRESS(base, sz);
+       if (p->p_vmspace->vm_map.flags & VM_MAP_TOPDOWN)
+               return VM_DEFAULT_ADDRESS_TOPDOWN(base, sz);
+       else
+               return VM_DEFAULT_ADDRESS_BOTTOMUP(base, sz);
 }
diff -r 76082657feb2 -r ae1e3d42507f sys/uvm/uvm_param.h
--- a/sys/uvm/uvm_param.h       Sat Jan 25 05:09:59 2014 +0000
+++ b/sys/uvm/uvm_param.h       Sat Jan 25 05:14:03 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_param.h,v 1.31 2012/03/19 00:17:08 uebayasi Exp $  */
+/*     $NetBSD: uvm_param.h,v 1.32 2014/01/25 05:14:03 christos Exp $  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -225,6 +225,15 @@
  * NOT defined, then the port can offer topdown as an option, but it
  * MUST define the VM_DEFAULT_ADDRESS macro itself.
  */
+#ifndef VM_DEFAULT_ADDRESS_BOTTOMUP
+#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
+    round_page((vaddr_t)(da) + (vsize_t)maxdmap)
+#endif
+#ifndef VM_DEFAULT_ADDRESS_TOPDOWN
+#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
+    trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz))
+#endif
+
 #if defined(USE_TOPDOWN_VM) || defined(__USE_TOPDOWN_VM)
 # if !defined(__HAVE_TOPDOWN_VM) && !defined(__USE_TOPDOWN_VM)
 #  error "Top down memory allocation not enabled for this system"
@@ -234,8 +243,7 @@
 #   if !defined(__USE_TOPDOWN_VM)
 #    error "Top down memory allocation not configured for this system"
 #   else /* !__USE_TOPDOWN_VM */
-#    define VM_DEFAULT_ADDRESS(da, sz) \
-       trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz))
+#    define VM_DEFAULT_ADDRESS(da, sz) VM_DEFAULT_ADDRESS_TOPDOWN(da, sz)
 #   endif /* !__USE_TOPDOWN_VM */
 #  endif /* !VM_DEFAULT_ADDRESS */
 # endif /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
@@ -245,7 +253,7 @@
 # if defined(VM_DEFAULT_ADDRESS)
 #  error "Default vm address should not be defined here"
 # else /* VM_DEFAULT_ADDRESS */
-#  define VM_DEFAULT_ADDRESS(da, sz) round_page((vaddr_t)(da) + (vsize_t)maxdmap)
+#  define VM_DEFAULT_ADDRESS(da, sz) VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz)
 # endif /* VM_DEFAULT_ADDRESS */
 #endif /* !__USING_TOPDOWN_VM */
 



Home | Main Index | Thread Index | Old Index