Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Allow flexible memory management using Uffd#515

Closed
tyler wants to merge 28 commits intotyler/uffd-integrationfrom
tyler/uffd-strategy
Closed

Allow flexible memory management using Uffd#515
tyler wants to merge 28 commits intotyler/uffd-integrationfrom
tyler/uffd-strategy

Conversation

@tyler
Copy link
Member

@tyler tyler commented May 8, 2020

This adds a UffdStrategy trait to allow users of UffdRegion to configure the way faults are handled.

This will be important especially to Lucet users who have highly concurrent applications and potentially large linear memories. Uffd in its most naive form is likely to be slower than the Mmap region because of the additional work done to shunt faults back into userspace, and the reaction to those faults over to the kernel.

This can be dealt with by being smarter about how those faults are handled. For instance, work can be batched up. Instead of copying one host page per fault, one could copy a batch of them. This doesn't implement that, but does provide the facilities to make it possible.

tyler and others added 23 commits May 1, 2020 14:34
- Instantiates the suite in `lucet_runtime_internals::alloc::tests` for `UffdRegion

- Fixes early return issues in `UffdRegion` similar to #455

- Adds a test to show that the per-instance heap limit applies to runtime expansions, not just
initial instantiation

- Refactors `validate_runtime_spec` to take the per-instance heap limit as an additional
argument. This centralizes the logic for rejecting initially-oversized heap limits, and makes it
clearer what's happening in each region's instantiation logic.

- Removes the `UffdRegion`'s assertion that signal stack size is a multiple of page size. Since the
user can now control this as a parameter, we reject it gracefully when validating `Limits` rather
than panicking.
Leaving the question of errors in the handler alone for this commit, since that'll be a more major
change.
Notably, this should get us building and running uffd in Linux CI.

It turns out to be a tremendous pain to enable a feature flag for just one crate within a
workspace. The situation is [being addressed][1], but in the meantime I believe the best route
forward is to just have uffd on by default for Linux.

[1]: rust-lang/cargo#5364
@tyler tyler changed the base branch from master to tyler/uffd-integration May 8, 2020 19:05
@tyler tyler force-pushed the tyler/uffd-strategy branch from 027290c to 388186e Compare May 9, 2020 00:03
Copy link
Contributor

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little style note, otherwise I think this looks fantastic. I'm really pleased how easily you were able to extract those bits! I guess when you're dealing with raw pointers, you don't have to worry at all about cloning or borrowing snags 🙂

tyler and others added 2 commits May 13, 2020 16:50
@tyler tyler force-pushed the tyler/uffd-integration branch from fc3049a to a96cb55 Compare May 19, 2020 20:39
@tyler
Copy link
Member Author

tyler commented May 19, 2020

Cherry picked the relevant bits over to #492

@tyler tyler closed this May 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants