[llvm] [llvm-profgen] Handle perf mmaps with page sizes larger than 4 KiB (PR #217887)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 10:31:51 PDT 2026
================
@@ -362,10 +362,11 @@ template <class ELFT>
void ProfiledBinary::setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
StringRef FileName) {
const auto &PhdrRange = unwrapOrError(Obj.program_headers(), FileName);
- // FIXME: This should be the page size of the system running profiling.
- // However such info isn't available at post-processing time, assuming
- // 4K page now. Note that we don't use EXEC_PAGESIZE from <linux/param.h>
- // because we may build the tools on non-linux.
+ // The page size of the profiling system cannot be determined from the ELF
+ // binary alone, and using the page size of the post-processing system would
+ // be incorrect. Use 4 KiB as the binary-side baseline. PerfScriptReader
+ // reconciles executable mmap events whose mappings cover the segment start
+ // due to a larger runtime page size.
uint64_t PageSize = 0x1000;
----------------
HighW4y2H3ll wrote:
Thanks for the fix! Do you think it makes sense to adjust PageSize by `max(0x1000, Phdr.p_align)`?
https://github.com/llvm/llvm-project/pull/217887
More information about the llvm-commits
mailing list