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

mpk: limit the number of protection keys #7364

Merged
merged 4 commits into from
Oct 25, 2023
Merged

Commits on Oct 25, 2023

  1. mpk: add max_memory_protection_keys

    If Wasmtime is ever embedded in an application that also uses memory
    protection keys, it could be useful to limit how many Wasmtime
    allocates and uses. This came up while examining `*.wast` tests: if
    there was no way limiting the number of keys used, then those tests
    configured a pool that reserved too much memory. This change takes that
    further to attempt to limit the initial number of keys allocated. The
    unfortunate side effect of using a `OnceLock` is that the `max` setting
    is only applicable on the first invocation, the one that sets the
    `OnceLock`.
    abrown committed Oct 25, 2023
    Configuration menu
    Copy the full SHA
    ddb4b9c View commit details
    Browse the repository at this point in the history
  2. mpk: use two protection keys for WAST tests

    This change stems from how slicing memory slots into MPK-protected
    regions limits the number of memories each store can access: e.g., with
    fifteen keys in use, a store only has access to a fifteenth of the
    available slots. If we simply multiple the number of memory slots needed
    to run the `*.wast` spec tests by fifteen, we run out of available
    memory. This limits the number of protection keys used to two, which
    still allows us to test the functionality without reserving too much
    memory.
    abrown committed Oct 25, 2023
    Configuration menu
    Copy the full SHA
    34f793e View commit details
    Browse the repository at this point in the history
  3. mpk: ensure keys only ever returns max items

    This addresses a review comment to slice the list of keys down to the
    `max` hint regardless of how many are allocated in the first invocation.
    abrown committed Oct 25, 2023
    Configuration menu
    Copy the full SHA
    333ff62 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1d71ea3 View commit details
    Browse the repository at this point in the history