Closed Bug 1980056 Opened 11 months ago Closed 5 months ago

Limit mozjemalloc "logical" page size to 4KB

Categories

(Core :: Memory Allocator, task, P1)

task

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: pbone, Assigned: pbone)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(6 files, 5 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

To ensure that regions can be byte-addressed within runs (Bug 1980047) we need to limit mozjemalloc's page size to 4096 bytes, even on systems where the physical/OS page size is larger. This means separating mozjemalloc's concept of page size into two parts, a "physical" page size and a "logical" page size. OS interfaces like decommitting memory will now have many edge cases that must be handled. This depends on Bug 1921908 which provides a refactoring that will make this change much simpler.

Sub-page size classes will be unsed so remove their logic.

Arenas track dirty chunks in a red-black tree ordered by memory address.
Switching this to a list will make it faster to test if an item is in
the list, which is required by the next patch.

Additionally there's no reason this collection needs to be ordered or
support lookups. The ordering by memory address may have some
fragmentation benefits, the new list is operated as a FIFO. Items are
appended at the tail when they get their first dirty page, and removed
from the head as they're purged.

Currently a dirty chunk (that's a chunk with at least one dirty page)
must:

  • Be in mChunksDirty
  • Be busy pruging by another thread.

The next change will allow it so that chunks with a non-zero mNumDirty
might not be in the dirty chunks list because its impossible to purge
their pages. Therefore in this change we relax the above assumption.

Attachment #9503950 - Attachment description: WIP: Bug 1980056 - Mozjemalloc can now use page sizes smaller than the real size → WIP: Bug 1980056 - pt 5. Mozjemalloc can now use page sizes smaller than the real size
Depends on: 1987055
No longer depends on: 1921908

Comment on attachment 9510759 [details]
WIP: Bug 1980056 - pt 1. Correct a comment

Revision D263334 was moved to bug 1987055. Setting attachment 9510759 [details] to obsolete.

Attachment #9510759 - Attachment is obsolete: true

Comment on attachment 9510760 [details]
WIP: Bug 1980056 - pt 2. Merge purge results, ReachedThreshold and Busy

Revision D263335 was moved to bug 1987055. Setting attachment 9510760 [details] to obsolete.

Attachment #9510760 - Attachment is obsolete: true

Comment on attachment 9510761 [details]
WIP: Bug 1980056 - pt 3. Change the dirty chunks tree to a list

Revision D263336 was moved to bug 1987055. Setting attachment 9510761 [details] to obsolete.

Attachment #9510761 - Attachment is obsolete: true

Comment on attachment 9510762 [details]
WIP: Bug 1980056 - pt 4. mChunksDirty doesn't always track all dirty chunks

Revision D263337 was moved to bug 1987055. Setting attachment 9510762 [details] to obsolete.

Attachment #9510762 - Attachment is obsolete: true

Comment on attachment 9503950 [details]
WIP: Bug 1980056 - pt 5. Mozjemalloc can now use page sizes smaller than the real size

Revision D259219 was moved to bug 1987055. Setting attachment 9503950 [details] to obsolete.

Attachment #9503950 - Attachment is obsolete: true
Attachment #9511908 - Attachment description: WIP: Bug 1980056 - pt 1. Limit logical page size to 4KiB → Bug 1980056 - pt 1. Limit logical page size to 4KiB r=glandium
Attachment #9503951 - Attachment description: WIP: Bug 1980056 - Remove the sub-page size class → Bug 1980056 - pt 2. Remove the sub-page size class r=glandium
Blocks: 2003976
No longer blocks: 2003976
Blocks: 2003976
Regressions: 2010505
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 149 Branch → ---
Flags: needinfo?(pbone)
Flags: needinfo?(pbone)
Attachment #9511908 - Attachment description: Bug 1980056 - pt 1. Limit logical page size to 4KiB r=glandium → Bug 1980056 - pt 5. Limit logical page size to 4KiB r=glandium

Huge allocations will always be rounded to real pages.

The test uses page size to calculate the size of the chunk header for
testing jemalloc_ptr_info. Using real page size is correct for finding
the size of the chunk header.

Realloc of huge allocations used the wrong page size to determine if
they're safe to do in-place. This patch fixes this.

When the allocator touches previously-madvised memory it must clear
madvised bits of trailing pages to keep them aligned with
real pages.

Attachment #9540262 - Attachment description: WIP: Bug 1980056 - pt 2. Use real page size in one of the jemalloc tests → Bug 1980056 - pt 2. Use real page size in one of the jemalloc tests r=glandium
Attachment #9540263 - Attachment description: WIP: Bug 1980056 - pt 3. Use gRealPageSize to qualify huge in-place realloc → Bug 1980056 - pt 3. Use gRealPageSize to qualify huge in-place realloc r=glandium
Attachment #9540264 - Attachment description: WIP: Bug 1980056 - pt 4. Make sure that madvised pages are aligned with real pages → Bug 1980056 - pt 4. Make sure that madvised pages are aligned with real pages r=glandium
Attachment #9503951 - Attachment description: Bug 1980056 - pt 2. Remove the sub-page size class r=glandium → Bug 1980056 - pt 6. Remove the sub-page size class r=glandium
Regressions: 2014781
Regressed by: 2015436
No longer regressed by: 2015436
Regressions: 2015436
QA Whiteboard: [qa-triage-done-c150/b149]
Regressions: 2036120
Regressions: 2039732
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: