Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmpfs: limit regularFile.Translate() fill range #11343

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

copybara-service[bot]
Copy link

tmpfs: limit regularFile.Translate() fill range

When e.g. an application thread takes a page fault on an mmapped file, MM calls
memmap.Mappable.Translate() to obtain the corresponding host FD range that
should be mapped into the application's address space. It passes both the range
that must be mapped (e.g. the faulting page) as required, and the maximum
range that may be mapped (the previously-unfaulted part of the corresponding
VMA) as optional, such that file implementations can map more than required
to avoid future page faults.

Prior to this CL, tmpfs.regularFile.Translate() always returned translations
up to optional, under the assumption that allocating larger ranges from
pgalloc.MemoryFile has negligible incremental cost. This behavior dates to
the introduction of memmap.Mappable.Translate() (cl/182882705) and thus
predates the implementation of tmpfs size limits (cl/442686814). Now that the
latter exists, unconditionally translating - and therefore allocating pages -
up to optional can result in hitting tmpfs size limits prematurely.

Thus: Constrain optional translations returned by
tmpfs.regularFile.Translate(), applying the same logic as
gofer.maxFillRange().

@copybara-service copybara-service bot added the exported Issue was exported automatically label Jan 7, 2025
@copybara-service copybara-service bot force-pushed the test/cl712742057 branch 6 times, most recently from bc3ea6c to 31fd1ac Compare January 8, 2025 04:10
When e.g. an application thread takes a page fault on an mmapped file, MM calls
`memmap.Mappable.Translate()` to obtain the corresponding host FD range that
should be mapped into the application's address space. It passes both the range
that *must* be mapped (e.g. the faulting page) as `required`, and the maximum
range that *may* be mapped (the previously-unfaulted part of the corresponding
VMA) as `optional`, such that file implementations can map more than `required`
to avoid future page faults.

Prior to this CL, `tmpfs.regularFile.Translate()` always returned translations
up to `optional`, under the assumption that allocating larger ranges from
`pgalloc.MemoryFile` has negligible incremental cost. This behavior dates to
the introduction of `memmap.Mappable.Translate()` (cl/182882705) and thus
predates the implementation of tmpfs size limits (cl/442686814). Now that the
latter exists, unconditionally translating - and therefore allocating pages -
up to `optional` can result in hitting tmpfs size limits prematurely.

Thus: Constrain optional translations returned by
`tmpfs.regularFile.Translate()`, applying the same logic as
`gofer.maxFillRange()`.
PiperOrigin-RevId: 713134287
@copybara-service copybara-service bot merged commit 8b7b69c into master Jan 8, 2025
0 of 2 checks passed
@copybara-service copybara-service bot deleted the test/cl712742057 branch January 8, 2025 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant