mirror of
https://github.com/golang/go
synced 2024-11-23 05:20:11 -07:00
runtime: improve efence
Mark free memory blocks as unused. On amd64 it allows the process to eat all 128 GB of heap without killing the machine. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/74070043
This commit is contained in:
parent
cdc93d2416
commit
c115cda22c
@ -44,7 +44,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -95,7 +95,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -56,7 +56,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -49,7 +49,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
runtime·mmap(v, n, PROT_NONE, 0, -1, 0);
|
||||
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
|
||||
}
|
||||
|
||||
void*
|
||||
|
@ -66,11 +66,8 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
void
|
||||
runtime·SysFault(void *v, uintptr n)
|
||||
{
|
||||
uintptr r, old;
|
||||
|
||||
r = (uintptr)runtime·stdcall(runtime·VirtualProtect, 4, v, n, (uintptr)PAGE_NOACCESS, &old);
|
||||
if(r == 0)
|
||||
runtime·throw("runtime: failed to protect pages");
|
||||
// SysUnused makes the memory inaccessible and prevents its reuse
|
||||
runtime·SysUnused(v, n);
|
||||
}
|
||||
|
||||
void*
|
||||
|
Loading…
Reference in New Issue
Block a user