Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133050156
D20370.id58568.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D20370.id58568.diff
View Options
Index: vm_map.c
===================================================================
--- vm_map.c
+++ vm_map.c
@@ -2109,6 +2109,60 @@
}
/*
+ * vm_map_entry_back:
+ *
+ * Allocate an object to back a map entry.
+ */
+static inline void
+vm_map_entry_back(vm_map_entry_t entry)
+{
+ vm_object_t object;
+
+ KASSERT(entry->object.vm_object == NULL,
+ ("map entry %p has backing object", entry));
+ KASSERT((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0,
+ ("map entry %p is a submap", entry));
+ object = vm_object_allocate(OBJT_DEFAULT,
+ atop(entry->end - entry->start));
+ entry->object.vm_object = object;
+ entry->offset = 0;
+ if (entry->cred != NULL) {
+ object->cred = entry->cred;
+ object->charge = entry->end - entry->start;
+ entry->cred = NULL;
+ }
+}
+
+/*
+ * vm_map_entry_charge_object
+ *
+ * If there is no object backing this entry, create one. Otherwise, if
+ * the entry has cred, give it to the backing object.
+ */
+static inline void
+vm_map_entry_charge_object(vm_map_t map, vm_map_entry_t entry)
+{
+
+ VM_MAP_ASSERT_LOCKED(map);
+ KASSERT((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0,
+ ("map entry %p is a submap", entry));
+ if (entry->object.vm_object == NULL && !map->system_map &&
+ (entry->eflags & MAP_ENTRY_GUARD) == 0)
+ vm_map_entry_back(entry);
+ else if (entry->object.vm_object != NULL &&
+ ((entry->eflags & MAP_ENTRY_NEEDS_COPY) == 0) &&
+ entry->cred != NULL) {
+ VM_OBJECT_WLOCK(entry->object.vm_object);
+ KASSERT(entry->object.vm_object->cred == NULL,
+ ("OVERCOMMIT: %s: both cred e %p", __func__, entry));
+ entry->object.vm_object->cred = entry->cred;
+ entry->object.vm_object->charge = entry->end - entry->start;
+ VM_OBJECT_WUNLOCK(entry->object.vm_object);
+ entry->cred = NULL;
+ }
+}
+
+/*
* vm_map_clip_start: [ internal use only ]
*
* Asserts that the given entry begins at or after
@@ -2140,38 +2194,7 @@
* starting address.
*/
vm_map_simplify_entry(map, entry);
-
- /*
- * If there is no object backing this entry, we might as well create
- * one now. If we defer it, an object can get created after the map
- * is clipped, and individual objects will be created for the split-up
- * map. This is a bit of a hack, but is also about the best place to
- * put this improvement.
- */
- if (entry->object.vm_object == NULL && !map->system_map &&
- (entry->eflags & MAP_ENTRY_GUARD) == 0) {
- vm_object_t object;
- object = vm_object_allocate(OBJT_DEFAULT,
- atop(entry->end - entry->start));
- entry->object.vm_object = object;
- entry->offset = 0;
- if (entry->cred != NULL) {
- object->cred = entry->cred;
- object->charge = entry->end - entry->start;
- entry->cred = NULL;
- }
- } else if (entry->object.vm_object != NULL &&
- ((entry->eflags & MAP_ENTRY_NEEDS_COPY) == 0) &&
- entry->cred != NULL) {
- VM_OBJECT_WLOCK(entry->object.vm_object);
- KASSERT(entry->object.vm_object->cred == NULL,
- ("OVERCOMMIT: vm_entry_clip_start: both cred e %p", entry));
- entry->object.vm_object->cred = entry->cred;
- entry->object.vm_object->charge = entry->end - entry->start;
- VM_OBJECT_WUNLOCK(entry->object.vm_object);
- entry->cred = NULL;
- }
-
+ vm_map_entry_charge_object(map, entry);
new_entry = vm_map_entry_create(map);
*new_entry = *entry;
@@ -2222,40 +2245,11 @@
KASSERT(entry->start < end && entry->end > end,
("_vm_map_clip_end: invalid clip of entry %p", entry));
- /*
- * If there is no object backing this entry, we might as well create
- * one now. If we defer it, an object can get created after the map
- * is clipped, and individual objects will be created for the split-up
- * map. This is a bit of a hack, but is also about the best place to
- * put this improvement.
- */
- if (entry->object.vm_object == NULL && !map->system_map &&
- (entry->eflags & MAP_ENTRY_GUARD) == 0) {
- vm_object_t object;
- object = vm_object_allocate(OBJT_DEFAULT,
- atop(entry->end - entry->start));
- entry->object.vm_object = object;
- entry->offset = 0;
- if (entry->cred != NULL) {
- object->cred = entry->cred;
- object->charge = entry->end - entry->start;
- entry->cred = NULL;
- }
- } else if (entry->object.vm_object != NULL &&
- ((entry->eflags & MAP_ENTRY_NEEDS_COPY) == 0) &&
- entry->cred != NULL) {
- VM_OBJECT_WLOCK(entry->object.vm_object);
- KASSERT(entry->object.vm_object->cred == NULL,
- ("OVERCOMMIT: vm_entry_clip_end: both cred e %p", entry));
- entry->object.vm_object->cred = entry->cred;
- entry->object.vm_object->charge = entry->end - entry->start;
- VM_OBJECT_WUNLOCK(entry->object.vm_object);
- entry->cred = NULL;
- }
/*
* Create a new entry and insert it AFTER the specified entry
*/
+ vm_map_entry_charge_object(map, entry);
new_entry = vm_map_entry_create(map);
*new_entry = *entry;
@@ -3935,16 +3929,8 @@
*/
object = old_entry->object.vm_object;
if (object == NULL) {
- object = vm_object_allocate(OBJT_DEFAULT,
- atop(old_entry->end - old_entry->start));
- old_entry->object.vm_object = object;
- old_entry->offset = 0;
- if (old_entry->cred != NULL) {
- object->cred = old_entry->cred;
- object->charge = old_entry->end -
- old_entry->start;
- old_entry->cred = NULL;
- }
+ vm_map_entry_back(old_entry);
+ object = old_entry->object.vm_object;
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 23, 11:29 AM (4 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24090262
Default Alt Text
D20370.id58568.diff (5 KB)
Attached To
Mode
D20370: Eliminate code duplication around clip_start
Attached
Detach File
Event Timeline
Log In to Comment