Page MenuHomeFreeBSD

D20753.id59035.diff
No OneTemporary

D20753.id59035.diff

Index: vm_map.c
===================================================================
--- vm_map.c
+++ vm_map.c
@@ -2463,6 +2463,7 @@
vm_object_t obj;
struct ucred *cred;
vm_prot_t old_prot;
+ int rv;
if (start == end)
return (KERN_SUCCESS);
@@ -2516,10 +2517,13 @@
}
/*
- * Do an accounting pass for private read-only mappings that
- * now will do cow due to allowed write (e.g. debugger sets
- * breakpoint on text segment)
+ * Do an accounting pass for private read-only mappings that now will
+ * do cow due to allowed write (e.g. debugger sets breakpoint on text
+ * segment). If swap space can't be reserved to back the copy-on-write
+ * pages that may now be written, break the loop early and let the next
+ * loop simplify entries, since some may be mergeable.
*/
+ rv = KERN_SUCCESS;
vm_map_clip_start(map, entry, start);
for (current = entry; current->start < end; current = current->next) {
@@ -2537,8 +2541,8 @@
if (obj == NULL || (current->eflags & MAP_ENTRY_NEEDS_COPY)) {
if (!swap_reserve(current->end - current->start)) {
- vm_map_unlock(map);
- return (KERN_RESOURCE_SHORTAGE);
+ rv = KERN_RESOURCE_SHORTAGE;
+ break;
}
crhold(cred);
current->cred = cred;
@@ -2561,8 +2565,8 @@
obj, current));
if (!swap_reserve(ptoa(obj->size))) {
VM_OBJECT_WUNLOCK(obj);
- vm_map_unlock(map);
- return (KERN_RESOURCE_SHORTAGE);
+ rv = KERN_RESOURCE_SHORTAGE;
+ break;
}
crhold(cred);
@@ -2572,11 +2576,14 @@
}
/*
- * Go back and fix up protections. [Note that clipping is not
- * necessary the second time.]
+ * If enough swap space was available, go back and fix up
+ * protections. [Note that clipping is not necessary the second time.]
+ * Otherwise, just simplify entries, since some may have been modified.
*/
- for (current = entry; current->start < end; current = current->next) {
- if ((current->eflags & MAP_ENTRY_GUARD) != 0)
+ for (current = entry; current->start < end;
+ vm_map_simplify_entry(map, current), current = current->next) {
+ if (rv != KERN_SUCCESS ||
+ (current->eflags & MAP_ENTRY_GUARD) != 0)
continue;
old_prot = current->protection;
@@ -2611,10 +2618,9 @@
current->protection & MASK(current));
#undef MASK
}
- vm_map_simplify_entry(map, current);
}
vm_map_unlock(map);
- return (KERN_SUCCESS);
+ return (rv);
}
/*

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 12, 6:06 AM (12 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29568566
Default Alt Text
D20753.id59035.diff (2 KB)

Event Timeline