This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Make argument name passed to `FindAvailableMemoryRange()` consistent with parameter name.
Needs ReviewPublic

Authored by delcypher on Aug 5 2020, 6:16 PM.

Details

Summary

The parameter name in FindAvailableMemoryRange() is left_padding.
There is a variable with this name in this function that has the same
value so just use it to avoid any confusion.

Diff Detail

Event Timeline

delcypher created this revision.Aug 5 2020, 6:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2020, 6:16 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
delcypher requested review of this revision.Aug 5 2020, 6:16 PM
yln added a subscriber: tejohnson.

I am okay with this change, but I don't understand this code or why this change is NFC. Can we get @tejohnson to take a look? (D83247)

granularity is not necessarily equal to left_padding. Also left_padding already goes into space_size, which is also passed to FindAvailableMemoryRange().

const uptr granularity = GetMmapGranularity();
...
const uptr left_padding =
    Max<uptr>(granularity, 1ULL << min_shadow_base_alignment);

uptr space_size = shadow_size_bytes + left_padding;

...
uptr shadow_start =
    FindAvailableMemoryRange(space_size, alignment, granularity, ...);
In D85387#2200178, @yln wrote:

I am okay with this change, but I don't understand this code or why this change is NFC. Can we get @tejohnson to take a look? (D83247)

granularity is not necessarily equal to left_padding.

It's NFC because min_shadow_base_alignment is always 0 for mac. We made this change to make the interface to, and the code within, the newly refactored MapDynamicShadow versions consistent. BTW the same issue exists in the win version, can you make the same change there? The linux version doesn't call FindAvailableMemoryRange(), so no issue there.

Also left_padding already goes into space_size, which is also passed to FindAvailableMemoryRange().

const uptr granularity = GetMmapGranularity();
...
const uptr left_padding =
    Max<uptr>(granularity, 1ULL << min_shadow_base_alignment);

uptr space_size = shadow_size_bytes + left_padding;

...
uptr shadow_start =
    FindAvailableMemoryRange(space_size, alignment, granularity, ...);

@tejohnson Side comment about the refactor. The comments on MapDynamicShadow(...) say that is function is actually supposed to mmap the found memory as NO_ACCESS. The current implementation doesn't do this. It just finds a space but doesn't mmap it. Is this a problem?

@tejohnson Side comment about the refactor. The comments on MapDynamicShadow(...) say that is function is actually supposed to mmap the found memory as NO_ACCESS. The current implementation doesn't do this. It just finds a space but doesn't mmap it. Is this a problem?

Thanks for pointing that out. That comment came from the linux version, where it is true, but it isn't true on mac or win. I will adjust the comment to say "on linux mapped no access".

@tejohnson Side comment about the refactor. The comments on MapDynamicShadow(...) say that is function is actually supposed to mmap the found memory as NO_ACCESS. The current implementation doesn't do this. It just finds a space but doesn't mmap it. Is this a problem?

Thanks for pointing that out. That comment came from the linux version, where it is true, but it isn't true on mac or win. I will adjust the comment to say "on linux mapped no access".

Fixed comment in bb1456decf5e09947dfe8eee47b9736de7cd7f47