This is an archive of the discontinued LLVM Phabricator instance.

tsan: include MBlock/SyncObj stats into mem profile
ClosedPublic

Authored by dvyukov on Sep 21 2021, 4:14 AM.

Details

Summary

Include info about MBlock/SyncObj memory consumption in the memory profile.

Depends on D110148.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Sep 21 2021, 4:14 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 4:15 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Sep 21 2021, 1:38 PM
vitalybuka added inline comments.
compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h
52

we don't need explicit?

90

don't need to lock if pos == nullptr

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
130

how can you overflow here this?

This revision is now accepted and ready to land.Sep 21 2021, 1:38 PM
melver accepted this revision.Sep 22 2021, 12:34 AM
melver added inline comments.
compiler-rt/lib/tsan/rtl/tsan_sync.h
130

Could add a 'struct MetaMap::MemoryStats' to contain the 2 variables and return that, in case you think it'd be cleaner.

dvyukov updated this revision to Diff 374137.Sep 22 2021, 1:08 AM
dvyukov marked 3 inline comments as done.

rebased and addressed comments

dvyukov added inline comments.Sep 22 2021, 1:12 AM
compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
130

"mem_block_mem + sync_obj_mem + stacks->allocated" (and internal allocator memory in the next patch) should come from the mmap region. Thus we subtract it to not double account.
But we obtain these numbers from different sources, so I am not 100% sure it can't underflow. I think it can in some corner cases. One example I can think of is is some of that additional memory is not committed yet, so it won't show up in mem[MemMmap] because it counts real RSS (from /proc/self/maps). In this case mem[MemMmap] can theoretically go negative and I would rather print 0 than 17592186044416MB.

This revision was landed with ongoing or failed builds.Sep 22 2021, 1:14 AM
This revision was automatically updated to reflect the committed changes.