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

Paschalis Mpeis via All-commits all-commits at lists.llvm.org
Thu Nov 21 02:07:53 PST 2024


  Branch: refs/heads/users/paschalis-mpeis/bolt-heatmap-fix
  Home:   https://github.com/llvm/llvm-project
  Commit: 4bdbb4490b38743df19f779e439bc7f763580a50
      https://github.com/llvm/llvm-project/commit/4bdbb4490b38743df19f779e439bc7f763580a50
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-11-20 (Wed, 20 Nov 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: b57442595349b366b886f918ff1ddc6757885d5d
      https://github.com/llvm/llvm-project/commit/b57442595349b366b886f918ff1ddc6757885d5d
  Author: Paschalis Mpeis (aws-mem-aarch64) <paschalis.mpeis at arm.com>
  Date:   2024-11-20 (Wed, 20 Nov 2024)

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

  Log Message:
  -----------
  [BOLT] DataAggregator supports binaries with multiple text segments

When a binary has multiple text segments, the Size is computed as the
difference of the last address of these segments from the BaseAddress.
The base addresses of all text segments must be the same.

Background:
Larger 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, when used in heatmaps the
output excludes all those entries and the section hotness statistics are
wrong.

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

---

This patch introduces the 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)
```


  Commit: fdfc1ab9014cbb3f73b0ffda7d903043e5ed4856
      https://github.com/llvm/llvm-project/commit/fdfc1ab9014cbb3f73b0ffda7d903043e5ed4856
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-11-20 (Wed, 20 Nov 2024)

  Changed paths:
    M bolt/unittests/Core/MemoryMaps.cpp
    M llvm/utils/gn/secondary/bolt/unittests/Core/BUILD.gn

  Log Message:
  -----------
  Attempt to fix build bot failures.

- Added to CoreTests in BUILD.gn
- Hiding DataAggregator std out/err outputs


  Commit: 52460e76f87a36755e8772f1ecd8053fcf2873b8
      https://github.com/llvm/llvm-project/commit/52460e76f87a36755e8772f1ecd8053fcf2873b8
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-11-20 (Wed, 20 Nov 2024)

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

  Log Message:
  -----------
  Addressing reviewers


  Commit: 16cf271e61e7eecd4849e29680a488661f9c677b
      https://github.com/llvm/llvm-project/commit/16cf271e61e7eecd4849e29680a488661f9c677b
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-11-20 (Wed, 20 Nov 2024)

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

  Log Message:
  -----------
  No need to launch perf in the background.

Causes issues on the CI too.


  Commit: 31e98b1637894adead5b98fc0839e13ea0f1fa0d
      https://github.com/llvm/llvm-project/commit/31e98b1637894adead5b98fc0839e13ea0f1fa0d
  Author: Paschalis Mpeis <Paschalis.Mpeis at arm.com>
  Date:   2024-11-21 (Thu, 21 Nov 2024)

  Changed paths:
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/unittests/Core/MemoryMaps.cpp

  Log Message:
  -----------
  Addressing reviewers (2)


Compare: https://github.com/llvm/llvm-project/compare/3fb0ca533b43...31e98b163789

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