[all-commits] [llvm/llvm-project] 505e18: BOLT fails to read correctly the size of multi-seg...

Paschalis Mpeis via All-commits all-commits at lists.llvm.org
Wed Aug 28 02:52:30 PDT 2024


  Branch: refs/heads/users/paschalis-mpeis/bolt-heatmap-fix
  Home:   https://github.com/llvm/llvm-project
  Commit: 505e186842c02e718a127134b64c11ebc493c87a
      https://github.com/llvm/llvm-project/commit/505e186842c02e718a127134b64c11ebc493c87a
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    M bolt/include/bolt/Profile/DataAggregator.h
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/unittests/Core/CMakeLists.txt
    A bolt/unittests/Core/MemoryMaps.cpp

  Log Message:
  -----------
  BOLT fails to read correctly the size of multi-segment mmaps.


  Commit: d5a5aaa7601fe0cfd42642745d0a45f482613443
      https://github.com/llvm/llvm-project/commit/d5a5aaa7601fe0cfd42642745d0a45f482613443
  Author: Paschalis Mpeis (aws-mem-aarch64) <paschalis.mpeis at arm.com>
  Date:   2024-08-28 (Wed, 28 Aug 2024)

  Changed paths:
    M bolt/lib/Profile/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] Fix heatmaps on large BOLTE'd binaries.

Large binaries get two text segments mapped when loaded in memory.
BOLT processes only the first, which is not having a correct BaseAddress,
causing a wrong computation of a BinaryMMapInfo's size.

Consequently, BOLT wrongly thinks that many of the samples fall outside
the binary and ignores them. As a result, the computed heatmap is
incomplete, and the section hotness statistics are wrong.

This bug is present in both the AArch64 and x86 backends.

---

This patch introduces flag 'perf-script-events' that allows passing
perf events without BOLT having to parse them using 'perf script'.
The flag is used to pass a mock perf profile that has two memory
mappings for a mock binary that has two text segments. The size of the
mapping is updated as `parseMMapEvents` now processes all text segments.

---

Example used in unit tests:
>From `/proc/<BINARY PID>/maps`, we have 2 text mappings, say A and B.

```
abc0000000-abc1000000 r-xp 011c0000 103:01 1573523 BINARY
abc2000000-abca000000 r-xp 031d0000 103:01 1573523 BINARY
```

Size of text mappings:

| Mapping |  Size  |
| ------- | ------ |
| A       | ~15MB  |
| B       | ~135MB |

---

Example on a real program:
```
2f7200000-2fabca000 r--p 00000000        bolted-binary
2fabd9000-2fe47c000 r-xp 039c9000        bolted-binary <- 1st txt segment
2fe48b000-2fe61d000 r--p 0727b000        bolted-binary
2fe62c000-2fe660000 rw-p 0740c000        bolted-binary
2fe660000-2fea4c000 rw-p 00000000
2fec00000-303dad000 r-xp 07a00000        bolted-binary <- 2nd (appears only on the bolted binary)
```


Compare: https://github.com/llvm/llvm-project/compare/ff020d9ae49d...d5a5aaa7601f

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list