forked from OSchip/llvm-project
[Sanitizer] Linux refactor shadow huge page mode handling
Disabling Transparent huge page mode refactored in one function. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65771 llvm-svn: 367925
This commit is contained in:
parent
5eb87cf30f
commit
1d92925a5a
|
@ -37,7 +37,7 @@ void ReserveShadowMemoryRange(uptr beg, uptr end, const char *name) {
|
||||||
size);
|
size);
|
||||||
Abort();
|
Abort();
|
||||||
}
|
}
|
||||||
if (common_flags()->no_huge_pages_for_shadow) NoHugePagesInRegion(beg, size);
|
SetShadowRegionHugePageMode(beg, size);
|
||||||
if (common_flags()->use_madv_dontdump) DontDumpShadowMemory(beg, size);
|
if (common_flags()->use_madv_dontdump) DontDumpShadowMemory(beg, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,8 +211,7 @@ void InitThreads() {
|
||||||
|
|
||||||
static void MadviseShadowRegion(uptr beg, uptr end) {
|
static void MadviseShadowRegion(uptr beg, uptr end) {
|
||||||
uptr size = end - beg + 1;
|
uptr size = end - beg + 1;
|
||||||
if (common_flags()->no_huge_pages_for_shadow)
|
SetShadowRegionHugePageMode(beg, size);
|
||||||
NoHugePagesInRegion(beg, size);
|
|
||||||
if (common_flags()->use_madv_dontdump)
|
if (common_flags()->use_madv_dontdump)
|
||||||
DontDumpShadowMemory(beg, size);
|
DontDumpShadowMemory(beg, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end);
|
||||||
void IncreaseTotalMmap(uptr size);
|
void IncreaseTotalMmap(uptr size);
|
||||||
void DecreaseTotalMmap(uptr size);
|
void DecreaseTotalMmap(uptr size);
|
||||||
uptr GetRSS();
|
uptr GetRSS();
|
||||||
bool NoHugePagesInRegion(uptr addr, uptr length);
|
bool SetShadowRegionHugePageMode(uptr addr, uptr length);
|
||||||
bool DontDumpShadowMemory(uptr addr, uptr length);
|
bool DontDumpShadowMemory(uptr addr, uptr length);
|
||||||
// Check if the built VMA size matches the runtime one.
|
// Check if the built VMA size matches the runtime one.
|
||||||
void CheckVMASize();
|
void CheckVMASize();
|
||||||
|
|
|
@ -68,9 +68,11 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end) {
|
||||||
SANITIZER_MADVISE_DONTNEED);
|
SANITIZER_MADVISE_DONTNEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NoHugePagesInRegion(uptr addr, uptr size) {
|
bool SetShadowRegionHugePageMode(uptr addr, uptr size) {
|
||||||
#ifdef MADV_NOHUGEPAGE // May not be defined on old systems.
|
#ifdef MADV_NOHUGEPAGE // May not be defined on old systems.
|
||||||
|
if (common_flags()->no_huge_pages_for_shadow)
|
||||||
return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
|
return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
|
||||||
|
return true;
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif // MADV_NOHUGEPAGE
|
#endif // MADV_NOHUGEPAGE
|
||||||
|
|
|
@ -329,7 +329,7 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end) {
|
||||||
// FIXME: add madvise-analog when we move to 64-bits.
|
// FIXME: add madvise-analog when we move to 64-bits.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NoHugePagesInRegion(uptr addr, uptr size) {
|
bool SetShadowRegionHugePageMode(uptr addr, uptr size) {
|
||||||
// FIXME: probably similar to ReleaseMemoryToOS.
|
// FIXME: probably similar to ReleaseMemoryToOS.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ static const char kShadowMemoryMappingHint[] =
|
||||||
"TSAN_OPTIONS=%s=0\n";
|
"TSAN_OPTIONS=%s=0\n";
|
||||||
|
|
||||||
static void NoHugePagesInShadow(uptr addr, uptr size) {
|
static void NoHugePagesInShadow(uptr addr, uptr size) {
|
||||||
if (common_flags()->no_huge_pages_for_shadow)
|
if (!SetShadowRegionHugePageMode(addr, size)) {
|
||||||
if (!NoHugePagesInRegion(addr, size)) {
|
|
||||||
Printf(kShadowMemoryMappingWarning, SanitizerToolName, addr, addr + size,
|
Printf(kShadowMemoryMappingWarning, SanitizerToolName, addr, addr + size,
|
||||||
"MADV_NOHUGEPAGE", errno);
|
"MADV_NOHUGEPAGE", errno);
|
||||||
Printf(kShadowMemoryMappingHint, "MADV_NOHUGEPAGE",
|
Printf(kShadowMemoryMappingHint, "MADV_NOHUGEPAGE",
|
||||||
|
|
Loading…
Reference in New Issue