This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common] Use zx_system_get_page_size() on Fuchsia
ClosedPublic

Authored by mcgrathr on Feb 2 2021, 9:00 PM.

Details

Summary

Fuchsia is migrating to a variable page size.

Diff Detail

Event Timeline

mcgrathr requested review of this revision.Feb 2 2021, 9:00 PM
mcgrathr created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2021, 9:00 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
phosek accepted this revision.Feb 2 2021, 10:00 PM

LGTM

This revision is now accepted and ready to land.Feb 2 2021, 10:00 PM

The CL seems fine, but should we use sanitizer_common's GetPageSizeCached()[0] where we call GetPageSize() ? Fuchsia documentation indicates that it's OK for user apps to cache that value.

[0]: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_common.h#L72-L78
[1]: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0016_boot_time_page_sizes

The CL seems fine, but should we use sanitizer_common's GetPageSizeCached()[0] where we call GetPageSize() ? Fuchsia documentation indicates that it's OK for user apps to cache that value.

It's fine to cache the value, but the question is whether it's worthwhile. The zx_system_get_page_size() call is literally a shared library function call that returns the value of a global variable. So it's already just as cheap as a local cache would be except for the PLT overhead of calling a shared library function rather than a local function (that might be LTO'd away to direct access to the global). I don't have data, but my intuition is that all in all the PLT overhead in those calls does less harm than the extra code and data space for a local cache.

charco accepted this revision.Feb 3 2021, 10:32 AM

Ah! It is already in the VDSO! I thought it was a regular system call, my bad. Fuchsia should probably document that.

Ah! It is already in the VDSO! I thought it was a regular system call, my bad. Fuchsia should probably document that.

It is not really part of the semantics how the vDSO is implemented. But it is the case that all the zx_system_get_* calls are quite cheap and we could at least document that expectation.