This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Madvise away unused shadow.
ClosedPublic

Authored by eugenis on Jan 15 2019, 4:12 PM.

Details

Summary

Whenever a large shadow region is tagged to zero, madvise(DONT_NEED)
as much of it as possible.

This reduces shadow RSS on Android by 45% or so, and total memory use
by 2-4%, probably even more on long running multithreaded programs.
CPU time seems to be in the noise.

Event Timeline

eugenis created this revision.Jan 15 2019, 4:12 PM
pcc added inline comments.Jan 15 2019, 5:40 PM
compiler-rt/lib/hwasan/hwasan_poisoning.cc
35–37

This code would work without the ifs, right?

eugenis updated this revision to Diff 182637.Jan 18 2019, 4:29 PM

a test case

eugenis marked an inline comment as done.Jan 18 2019, 4:29 PM
pcc added inline comments.Jan 18 2019, 4:43 PM
compiler-rt/test/hwasan/TestCases/Linux/release-shadow.c
35

Can't this just be open("/proc/self/statm", O_RDONLY);?

eugenis marked an inline comment as done.Jan 18 2019, 5:32 PM
eugenis added inline comments.
compiler-rt/test/hwasan/TestCases/Linux/release-shadow.c
35

I suppose it could.

pcc accepted this revision.Jan 18 2019, 5:43 PM

LGTM

This revision is now accepted and ready to land.Jan 18 2019, 5:43 PM
This revision was automatically updated to reflect the committed changes.