mirror of
https://github.com/golang/go
synced 2024-11-23 08:10:03 -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
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -95,7 +95,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -56,7 +56,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -48,7 +48,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -49,7 +49,7 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
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*
|
void*
|
||||||
|
@ -66,11 +66,8 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
|||||||
void
|
void
|
||||||
runtime·SysFault(void *v, uintptr n)
|
runtime·SysFault(void *v, uintptr n)
|
||||||
{
|
{
|
||||||
uintptr r, old;
|
// SysUnused makes the memory inaccessible and prevents its reuse
|
||||||
|
runtime·SysUnused(v, n);
|
||||||
r = (uintptr)runtime·stdcall(runtime·VirtualProtect, 4, v, n, (uintptr)PAGE_NOACCESS, &old);
|
|
||||||
if(r == 0)
|
|
||||||
runtime·throw("runtime: failed to protect pages");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
Loading…
Reference in New Issue
Block a user