Source-Changes-HG archive

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

[src/trunk]: src/sys Add MAP_INHERIT_ZERO



details:   https://anonhg.NetBSD.org/src/rev/b2291463018b
branches:  trunk
changeset: 330694:b2291463018b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jul 18 12:36:57 2014 +0000

description:
Add MAP_INHERIT_ZERO

diffstat:

 sys/sys/mman.h    |   3 ++-
 sys/uvm/uvm_map.c |  37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)

diffs (89 lines):

diff -r ecda247184da -r b2291463018b sys/sys/mman.h
--- a/sys/sys/mman.h    Fri Jul 18 12:36:18 2014 +0000
+++ b/sys/sys/mman.h    Fri Jul 18 12:36:57 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mman.h,v 1.46 2014/06/30 21:46:33 matt Exp $   */
+/*     $NetBSD: mman.h,v 1.47 2014/07/18 12:36:57 christos Exp $       */
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -161,6 +161,7 @@
 #define        MAP_INHERIT_NONE        2       /* absent from child */
 #define        MAP_INHERIT_DONATE_COPY 3       /* copy and delete -- not
                                           implemented in UVM */
+#define        MAP_INHERIT_ZERO        4       /* zero in child */
 #define        MAP_INHERIT_DEFAULT     MAP_INHERIT_COPY
 #endif
 
diff -r ecda247184da -r b2291463018b sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Fri Jul 18 12:36:18 2014 +0000
+++ b/sys/uvm/uvm_map.c Fri Jul 18 12:36:57 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.329 2014/07/18 12:19:09 christos Exp $   */
+/*     $NetBSD: uvm_map.c,v 1.330 2014/07/18 12:36:57 christos Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.329 2014/07/18 12:19:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.330 2014/07/18 12:36:57 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -3097,6 +3097,7 @@
        case MAP_INHERIT_NONE:
        case MAP_INHERIT_COPY:
        case MAP_INHERIT_SHARE:
+       case MAP_INHERIT_ZERO:
                break;
        default:
                UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
@@ -4346,6 +4347,35 @@
 }
 
 /*
+ * zero the mapping: the new entry will be zero initialized
+ */
+static void
+uvm_mapent_forkzero(struct vm_map *new_map, struct vm_map *old_map,
+    struct vm_map_entry *old_entry)
+{
+       struct vm_map_entry *new_entry;
+
+       new_entry = uvm_mapent_clone(new_map, old_entry, 0);
+
+       new_entry->etype |=
+           (UVM_ET_COPYONWRITE|UVM_ET_NEEDSCOPY);
+
+       if (new_entry->aref.ar_amap) {
+               uvm_map_unreference_amap(new_entry, 0);
+               new_entry->aref.ar_pageoff = 0;
+               new_entry->aref.ar_amap = NULL;
+       }
+
+       if (UVM_ET_ISOBJ(new_entry)) {
+               if (new_entry->object.uvm_obj->pgops->pgo_detach)
+                       new_entry->object.uvm_obj->pgops->pgo_detach(
+                           new_entry->object.uvm_obj);
+               new_entry->object.uvm_obj = NULL;
+               new_entry->etype &= ~UVM_ET_OBJ;
+       }
+}
+
+/*
  *   F O R K   -   m a i n   e n t r y   p o i n t
  */
 /*
@@ -4405,6 +4435,9 @@
                        uvm_mapent_forkcopy(new_map, old_map, old_entry);
                        break;
 
+               case MAP_INHERIT_ZERO:
+                       uvm_mapent_forkzero(new_map, old_map, old_entry);
+                       break;
                default:
                        KASSERT(0);
                        break;



Home | Main Index | Thread Index | Old Index