Make anon clustering more compatible.
Make the clustering enabling knob more fine-grained by providing a setting where the allocation with hint is not clustered. This is aimed to be somewhat more compatible with e.g. go 1.4 which expects that hinted mmap without MAP_FIXED does not change the allocation address. Now the vm.cluster_anon can be set to 1 to only cluster when no hints, and to 2 to always cluster. Default value is 1. Requested by: peter Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D19194
This commit is contained in:
parent
59621b207c
commit
484e9d0322
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344128
@ -1487,7 +1487,22 @@ static const int aslr_pages_rnd_32[2] = {0x100, 0x4};
|
||||
static int cluster_anon = 1;
|
||||
SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW,
|
||||
&cluster_anon, 0,
|
||||
"Cluster anonymous mappings");
|
||||
"Cluster anonymous mappings: 0 = no, 1 = yes if no hint, 2 = always");
|
||||
|
||||
static bool
|
||||
clustering_anon_allowed(vm_offset_t addr)
|
||||
{
|
||||
|
||||
switch (cluster_anon) {
|
||||
case 0:
|
||||
return (false);
|
||||
case 1:
|
||||
return (addr == 0);
|
||||
case 2:
|
||||
default:
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
static long aslr_restarts;
|
||||
SYSCTL_LONG(_vm, OID_AUTO, aslr_restarts, CTLFLAG_RD,
|
||||
@ -1593,7 +1608,7 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
} else
|
||||
alignment = 0;
|
||||
en_aslr = (map->flags & MAP_ASLR) != 0;
|
||||
update_anon = cluster = cluster_anon != 0 &&
|
||||
update_anon = cluster = clustering_anon_allowed(*addr) &&
|
||||
(map->flags & MAP_IS_SUB_MAP) == 0 && max_addr == 0 &&
|
||||
find_space != VMFS_NO_SPACE && object == NULL &&
|
||||
(cow & (MAP_INHERIT_SHARE | MAP_STACK_GROWS_UP |
|
||||
|
Loading…
Reference in New Issue
Block a user