This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Divide RegularPageSize for X86 and AArch64 cases
ClosedPublic

Authored by Elvina on Feb 8 2022, 11:17 AM.

Details

Summary

For AArch64 in some cases/some distributions ld uses 64K alignment of LOAD segments by default.

Diff Detail

Event Timeline

Elvina created this revision.Feb 8 2022, 11:17 AM
Elvina requested review of this revision.Feb 8 2022, 11:17 AM
yota9 accepted this revision.Feb 8 2022, 11:37 AM

Some of the aarch64 distros are using 64kb page size, so setting up the page size for 64kb seems to be more universal solution for arm. LGTM, but let's wait for other reviewers.

This revision is now accepted and ready to land.Feb 8 2022, 11:37 AM
maksfb added a comment.Feb 8 2022, 1:06 PM

I think the proper way to add different page sizes is to add an API to MCSubtargetInfo. There's already API for cache (getCacheSize(), getCacheLineSize(), getCacheAssociativity()), we can introduce the one for pages. What do you think?

bolt/include/bolt/Core/BinaryContext.h
497

Curious - what's the motivation for this change?

yota9 added a comment.Feb 8 2022, 1:29 PM

@maksfb As I see this is target (CPU) specific API. But we are talking about software-related choice of page size, this is not like the hardware feature, some of the linux distros might use standard 4kb page, some of them are using 64kb pages. So I'm not sure if the MCSubtargetInfo is the right place to add it to. Besides there are pros and cons for each choice of course, but using 64kb alignment will work on every distro, and 4kb won't :)

There are typically several page sizes supported by a CPU, e.g. 4KiB, 2MiB, 1GiB for x86-64, and I believe this data could be added to MCSubtargetInfo. But you are right, in theory a system could be configured to use virtually any of the available HW options and even use a mixture for the same binary, such as one for "text", another for "data", etc. Ideally, such info could be part of ELF, but alas it is not.

yota9 added a comment.EditedFeb 10 2022, 1:13 AM

@maksfb Yes, that is exactly what I've meant, thank you! Although the page size might be configured to be any (from the supported by hardware list), currently there are 2 types of them are used for aarch64 by linux in common: it is 4kb and 64kb. Increasing the size to 64kb will cover all of our cases, so I really think it makes sense for us to make it by default for arm.

bolt/include/bolt/Core/BinaryContext.h
497

This is just in order to make it the same type (except const, of course) like RegularPageSize variable, but it is not necessary of course :)

Elvina added inline comments.Feb 10 2022, 8:04 AM
bolt/include/bolt/Core/BinaryContext.h
497

yep :)

Could you please add "[BOLT]" to the title?

ld uses 64K alignment of LOAD segments by default.

I wonder if in that case the alignment of the segment will be 0x10000 as well?

bolt/include/bolt/Core/BinaryContext.h
497

The type is still unsigned, but semantics has changed. Let's keep it as a static member.

Elvina updated this revision to Diff 414186.Mar 9 2022, 12:44 PM

Reverted changes for HugePageSize

Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 12:44 PM
Elvina marked an inline comment as done.Mar 9 2022, 12:45 PM
Elvina retitled this revision from Divide RegularPageSize for X86 and AArch64 cases to [BOLT] Divide RegularPageSize for X86 and AArch64 cases.

Could you please add "[BOLT]" to the title?

ld uses 64K alignment of LOAD segments by default.

I wonder if in that case the alignment of the segment will be 0x10000 as well?

Sorry for the long silence. Yes, I double-checked, in that case alignment is 0x10000

maksfb accepted this revision.Mar 9 2022, 11:06 PM

LGTM

This revision was automatically updated to reflect the committed changes.