[sanitizer_common] Several Solaris procmaps fixes
authorRainer Orth <ro@gcc.gnu.org>
Sat, 16 Jul 2022 04:59:00 +0000 (06:59 +0200)
committerRainer Orth <ro@gcc.gnu.org>
Sat, 16 Jul 2022 04:59:00 +0000 (06:59 +0200)
commit74f6672e59d2cc9fdc95abfd28f527f00c808c07
tree84f35497832c0297b5a03aa675e46d68c6714077
parentfe47cfb324cbc761741527230dc7436ecf62f8c6
[sanitizer_common] Several Solaris procmaps fixes

Since the introduction of GoogleTest sharding in D122251
<https://reviews.llvm.org/D122251>, some of the Solaris sanitizer tests
have been running extremly long (up to an hour) while they took mere
seconds before.  Initial investigation suggests that massive lock
contention in Solaris procfs is involved here.

However, there's an easy way to somewhat reduce the impact: while the
current `ReadProcMaps` uses `ReadFileToBuffer` to read `/proc/self/xmap`,
that function primarily caters to Linux procfs reporting file sizes of 0
while the size on Solaris is accurate.  This patch makes use of that,
reducing the number of syscalls involved and reducing the runtime of
affected tests by a factor of 4.

Besides, it handles shared mappings and doesn't call `readlink` for unnamed
map entries.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D129837
compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp