svn commit: r355612 - head/sys/vm
Doug Moore
dougm at FreeBSD.org
Wed Dec 11 16:09:58 UTC 2019
Author: dougm
Date: Wed Dec 11 16:09:57 2019
New Revision: 355612
URL: https://svnweb.freebsd.org/changeset/base/355612
Log:
Extract code common to _vm_map_clip_start and _vm_map_clip_end into a
function, vm_map_entry_clone, that can be invoked by each.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22760
Modified:
head/sys/vm/vm_map.c
Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c Wed Dec 11 15:52:29 2019 (r355611)
+++ head/sys/vm/vm_map.c Wed Dec 11 16:09:57 2019 (r355612)
@@ -2291,6 +2291,42 @@ vm_map_entry_charge_object(vm_map_t map, vm_map_entry_
}
/*
+ * vm_map_entry_clone
+ *
+ * Create a duplicate map entry for clipping.
+ */
+static vm_map_entry_t
+vm_map_entry_clone(vm_map_t map, vm_map_entry_t entry)
+{
+ vm_map_entry_t new_entry;
+
+ VM_MAP_ASSERT_LOCKED(map);
+
+ /*
+ * Create a backing object now, if none exists, so that more individual
+ * objects won't be created after the map entry is split.
+ */
+ vm_map_entry_charge_object(map, entry);
+
+ /* Clone the entry. */
+ new_entry = vm_map_entry_create(map);
+ *new_entry = *entry;
+ if (new_entry->cred != NULL)
+ crhold(entry->cred);
+ if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
+ vm_object_reference(new_entry->object.vm_object);
+ vm_map_entry_set_vnode_text(new_entry, true);
+ /*
+ * The object->un_pager.vnp.writemappings for the object of
+ * MAP_ENTRY_WRITECNT type entry shall be kept as is here. The
+ * virtual pages are re-distributed among the clipped entries,
+ * so the sum is left the same.
+ */
+ }
+ return (new_entry);
+}
+
+/*
* vm_map_clip_start: [ internal use only ]
*
* Asserts that the given entry begins at or after
@@ -2316,16 +2352,8 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry,
KASSERT(entry->end > start && entry->start < start,
("_vm_map_clip_start: invalid clip of entry %p", entry));
- /*
- * Create a backing object now, if none exists, so that more individual
- * objects won't be created after the map entry is split.
- */
- vm_map_entry_charge_object(map, entry);
+ new_entry = vm_map_entry_clone(map, entry);
- /* Clone the entry. */
- new_entry = vm_map_entry_create(map);
- *new_entry = *entry;
-
/*
* Split off the front portion. Insert the new entry BEFORE this one,
* so that this entry has the specified starting address.
@@ -2333,22 +2361,7 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry,
new_entry->end = start;
entry->offset += (start - entry->start);
entry->start = start;
- if (new_entry->cred != NULL)
- crhold(entry->cred);
-
vm_map_entry_link(map, new_entry);
-
- if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
- vm_object_reference(new_entry->object.vm_object);
- vm_map_entry_set_vnode_text(new_entry, true);
- /*
- * The object->un_pager.vnp.writemappings for the
- * object of MAP_ENTRY_WRITECNT type entry shall be
- * kept as is here. The virtual pages are
- * re-distributed among the clipped entries, so the sum is
- * left the same.
- */
- }
}
/*
@@ -2377,31 +2390,15 @@ _vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, v
KASSERT(entry->start < end && entry->end > end,
("_vm_map_clip_end: invalid clip of entry %p", entry));
- /*
- * Create a backing object now, if none exists, so that more individual
- * objects won't be created after the map entry is split.
- */
- vm_map_entry_charge_object(map, entry);
+ new_entry = vm_map_entry_clone(map, entry);
- /* Clone the entry. */
- new_entry = vm_map_entry_create(map);
- *new_entry = *entry;
-
/*
* Split off the back portion. Insert the new entry AFTER this one,
* so that this entry has the specified ending address.
*/
new_entry->start = entry->end = end;
new_entry->offset += (end - entry->start);
- if (new_entry->cred != NULL)
- crhold(entry->cred);
-
vm_map_entry_link(map, new_entry);
-
- if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) {
- vm_object_reference(new_entry->object.vm_object);
- vm_map_entry_set_vnode_text(new_entry, true);
- }
}
/*
More information about the svn-src-all
mailing list