Bug 234091 - Reduce maximum mmap size for Structure regions to help placate ios
Summary: Reduce maximum mmap size for Structure regions to help placate ios
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-09 10:57 PST by Keith Miller
Modified: 2021-12-10 06:29 PST (History)
6 users (show)

See Also:


Attachments
Patch (3.98 KB, patch)
2021-12-09 11:02 PST, Keith Miller
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (4.00 KB, patch)
2021-12-09 11:10 PST, Keith Miller
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (4.02 KB, patch)
2021-12-09 11:16 PST, Keith Miller
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (4.01 KB, patch)
2021-12-09 12:38 PST, Keith Miller
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (4.75 KB, patch)
2021-12-09 12:57 PST, Keith Miller
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (3.54 KB, patch)
2021-12-09 13:55 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (3.57 KB, patch)
2021-12-10 05:36 PST, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2021-12-09 10:57:12 PST
Reduce maximum mmap size for Structure regions to help placate ios
Comment 1 Keith Miller 2021-12-09 11:02:19 PST
Created attachment 446568 [details]
Patch
Comment 2 Keith Miller 2021-12-09 11:10:51 PST
Created attachment 446571 [details]
Patch
Comment 3 Saam Barati 2021-12-09 11:10:54 PST
Comment on attachment 446568 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446568&action=review

r=me

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:93
> +    void* aligned = nullptr;

let's call this "result" or similar, maybe "alignedResult".

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:95
> +    bool copy = false;
> +    int flags = VM_FLAGS_ANYWHERE;

constexpr

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:97
> +    kern_return_t result = mach_vm_map(mach_task_self(), reinterpret_cast<mach_vm_address_t*>(&aligned), bytes, bytes - 1, flags, MEMORY_OBJECT_NULL, 0, copy, protections, protections, childProcessInheritance);

bitwise_cast

Also, this code is wrong if not a power of 2, right?

Should we assert we're dealing with a power of 2?

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:104
> +#if HAVE(MADV_FREE_REUSE)
> +    if (aligned) {
> +        // To support the "reserve then commit" model, we have to initially decommit.
> +        while (madvise(aligned, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
> +    }
> +#endif

Can we abstract this since we have a similar loop elsewhere?

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:106
> +    return reinterpret_cast<void*>(aligned);

bitwise_cast
Comment 4 Saam Barati 2021-12-09 11:12:06 PST
Comment on attachment 446571 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446571&action=review

r=me still with comment from prior patch

> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:83
> +    UNUSED_PARAM(includesGuardPages);

should we assert we're not dealing with this?
Comment 5 Keith Miller 2021-12-09 11:15:53 PST
Comment on attachment 446568 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446568&action=review

>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:93
>> +    void* aligned = nullptr;
> 
> let's call this "result" or similar, maybe "alignedResult".

I'll rename it to address.

>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:95
>> +    int flags = VM_FLAGS_ANYWHERE;
> 
> constexpr

sure.

>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:97
>> +    kern_return_t result = mach_vm_map(mach_task_self(), reinterpret_cast<mach_vm_address_t*>(&aligned), bytes, bytes - 1, flags, MEMORY_OBJECT_NULL, 0, copy, protections, protections, childProcessInheritance);
> 
> bitwise_cast
> 
> Also, this code is wrong if not a power of 2, right?
> 
> Should we assert we're dealing with a power of 2?

Yeah the assert at the top of the function checks that and that the bytes is bigger than page size.

>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:104
>> +#endif
> 
> Can we abstract this since we have a similar loop elsewhere?

That seems like more code than we save.

>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:106
>> +    return reinterpret_cast<void*>(aligned);
> 
> bitwise_cast

I can actually delete this.
Comment 6 Keith Miller 2021-12-09 11:16:29 PST
Created attachment 446574 [details]
Patch for landing
Comment 7 EWS 2021-12-09 11:59:31 PST
Patch 446574 does not build
Comment 8 Keith Miller 2021-12-09 12:38:06 PST
Created attachment 446589 [details]
Patch for landing
Comment 9 Keith Miller 2021-12-09 12:57:19 PST
Created attachment 446594 [details]
Patch for landing
Comment 10 Keith Miller 2021-12-09 13:55:09 PST
Created attachment 446601 [details]
Patch for landing
Comment 11 Saam Barati 2021-12-09 14:35:54 PST
(In reply to Keith Miller from comment #5)
> Comment on attachment 446568 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=446568&action=review
> 
> >> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:93
> >> +    void* aligned = nullptr;
> > 
> > let's call this "result" or similar, maybe "alignedResult".
> 
> I'll rename it to address.
> 
> >> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:95
> >> +    int flags = VM_FLAGS_ANYWHERE;
> > 
> > constexpr
> 
> sure.
> 
> >> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:97
> >> +    kern_return_t result = mach_vm_map(mach_task_self(), reinterpret_cast<mach_vm_address_t*>(&aligned), bytes, bytes - 1, flags, MEMORY_OBJECT_NULL, 0, copy, protections, protections, childProcessInheritance);
> > 
> > bitwise_cast
> > 
> > Also, this code is wrong if not a power of 2, right?
> > 
> > Should we assert we're dealing with a power of 2?
> 
> Yeah the assert at the top of the function checks that and that the bytes is
> bigger than page size.
> 
> >> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:104
> >> +#endif
> > 
> > Can we abstract this since we have a similar loop elsewhere?
> 
> That seems like more code than we save.
> 
> >> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:106
> >> +    return reinterpret_cast<void*>(aligned);
> > 
> > bitwise_cast
> 
> I can actually delete this.

Not all of these changes were made.
Comment 12 Saam Barati 2021-12-09 14:37:29 PST
Comment on attachment 446568 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446568&action=review

>>> Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp:104
>>> +#endif
>> 
>> Can we abstract this since we have a similar loop elsewhere?
> 
> That seems like more code than we save.

that's not always the reason to abstract stuff like this. It's nice to have a shared implementation IMO because of the looping we do.
Comment 13 EWS 2021-12-09 14:57:24 PST
Committed r286804 (245044@main): <https://commits.webkit.org/245044@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446601 [details].
Comment 14 Radar WebKit Bug Importer 2021-12-09 14:58:25 PST
<rdar://problem/86292683>
Comment 15 Ryan Haddad 2021-12-09 16:47:56 PST
Reverted r286804 for reason:

Breaks internal builds.

Committed r286818 (245054@trunk): <https://commits.webkit.org/245054@trunk>
Comment 16 Keith Miller 2021-12-10 05:36:45 PST
Created attachment 446714 [details]
Patch for landing
Comment 17 EWS 2021-12-10 06:29:46 PST
Committed r286849 (245082@main): <https://commits.webkit.org/245082@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446714 [details].