svn commit: r351640 - stable/11/sys/vm
Konstantin Belousov
kib at FreeBSD.org
Sat Aug 31 08:52:58 UTC 2019
Author: kib
Date: Sat Aug 31 08:52:57 2019
New Revision: 351640
URL: https://svnweb.freebsd.org/changeset/base/351640
Log:
MFC r351453:
Make stack grow use the same gap as stack create.
Modified:
stable/11/sys/vm/vm_map.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/vm/vm_map.c
==============================================================================
--- stable/11/sys/vm/vm_map.c Sat Aug 31 08:40:41 2019 (r351639)
+++ stable/11/sys/vm/vm_map.c Sat Aug 31 08:52:57 2019 (r351640)
@@ -3686,8 +3686,20 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos,
rv = vm_map_insert(map, NULL, 0, gap_bot, gap_top, VM_PROT_NONE,
VM_PROT_NONE, MAP_CREATE_GUARD | (orient == MAP_STACK_GROWS_DOWN ?
MAP_CREATE_STACK_GAP_DN : MAP_CREATE_STACK_GAP_UP));
- if (rv != KERN_SUCCESS)
+ if (rv == KERN_SUCCESS) {
+ /*
+ * Gap can never successfully handle a fault, so
+ * read-ahead logic is never used for it. Re-use
+ * next_read of the gap entry to store
+ * stack_guard_page for vm_map_growstack().
+ */
+ if (orient == MAP_STACK_GROWS_DOWN)
+ new_entry->prev->next_read = sgp;
+ else
+ new_entry->next->next_read = sgp;
+ } else {
(void)vm_map_delete(map, bot, top);
+ }
return (rv);
}
@@ -3728,7 +3740,6 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_ma
MPASS(!map->system_map);
- guard = stack_guard_page * PAGE_SIZE;
lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK);
stacklim = lim_cur(curthread, RLIMIT_STACK);
vmemlim = lim_cur(curthread, RLIMIT_VMEM);
@@ -3755,6 +3766,7 @@ retry:
} else {
return (KERN_FAILURE);
}
+ guard = gap_entry->next_read;
max_grow = gap_entry->end - gap_entry->start;
if (guard > max_grow)
return (KERN_NO_SPACE);
More information about the svn-src-stable
mailing list