Skip to content

Mmapper granularity: chunk or page? #1344

@wks

Description

@wks

Implementations of Mmapper keep a map from chunks to MapState values. Obviously it works at the granularity of chunks internally.

But some methods of Mmapper take the number of pages as arguments. Concretely:

  • quarantine_address_range(start, pages, strategy, anno)
  • ensure_mapped(start, pages, strategy, anno)
  • protect(start, pages)

I don't think Mmapper can maintain MapState at the granularity of pages because that would be too fine-grained. To handle large address ranges up to 48 bits, we would need to switch to a different data structure, such as segment tree which is slower to query than chunk-grained arrays.

If we want Mmapper to keep working at chunk granularity, we should change the public interface in order not to give its user a false impression that it may work at page granularity. We should remove all mentions of "page" and use one of the following strategies:

  1. quarantine_address_ranges(start: Address, bytes: usize, ...) while requiring both start and bytes to be chunk-aligned.
  2. quarantine_address_ranges(start_chunk_index: usize, num_chunks: usize, ...) where both start_chunk_index and num_chunks are chunk indices counted from address 0. That is, chunk_index = address >> LOG_BYTES_IN_CHUNK.
  3. quarantine_address_ranges(chunk_range: ChunkRange, ...) where chunk_range is a dedicated data structure that refers to whole chunks.

I personally prefer method 3. Regardless of the internal representation of ChunkRange (whether it uses aligned addresses or chunk indices), there is no way the user can supply an unaligned range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions