This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Refactor Memory Release Functions.
AcceptedPublic

Authored by charco on Sep 25 2020, 5:35 PM.

Details

Summary

This commit refactors calls to ReleaseMemoryPagesToOS into calls to
ReleaseTSANPages, and unmap/map to zero fill memory into ZeroPages.

This is in preparation for porting TSAN for Fuchsia: fuchsia doesn't
implement ReleaseMemoryPagesToOS, so we cannot call it directly.
Instead we will call an internal function that is able to only return
memory used for the tsan data structures (shadow, meta-shadow and
traces).

Diff Detail

Event Timeline

charco created this revision.Sep 25 2020, 5:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 25 2020, 5:35 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
charco requested review of this revision.Sep 25 2020, 5:35 PM
charco updated this revision to Diff 295877.Oct 2 2020, 11:06 AM

Fix ptrdiff error.

charco updated this revision to Diff 295878.Oct 2 2020, 11:14 AM

wrong argument order.

mcgrathr accepted this revision.Oct 23 2020, 10:28 AM

I'm not sure this is the optimal refactor ultimately, but it seems like a safe and clean pure refactor that's at least an incremental cleanup in expressing what the APIs are being used for.

compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp
125

This is the conservative change as a pure refactor. But on any POSIX system the munmap is superfluous before overmapping with MAP_FIXED so this call could be dropped.

compiler-rt/lib/tsan/rtl/tsan_platform_windows.cpp
36

Perhaps a comment that this is only used by TSan and TSan doesn't support Windows.

This revision is now accepted and ready to land.Oct 23 2020, 10:28 AM