Browse Source
* mpk: optimize layout of protected stripes While experimenting with the limits of MPK-protected memory pools, @alexcrichton and I discovered that the current slab layout calculations were too conservative. This meant that the memory pool could not pack in as many memories as it should have been able: we were expecting, but not seeing, ~15x more memory slots over non-MPK memory pools. The fix ends up being simpler than the original: we must maintain the codegen constraints that expect a static memory to be inaccessible for OOB access within a `static_memory_maximum_size + static_memory_guard_size` region (called `expected_slot_bytes + guard_bytes` in `memory_pool.rs`). By dividing up that region between the stripes, we still guarantee that the region is inaccessible by packing in other MPK-protected stripes. And we still need to make sure that the `post_slab_guard_bytes` add up to that region. These changes fix the memory inefficiency issues we were seeing. Co-authored-by: Alex Crichton <alex@alexcrichton.com> * mpk: eliminate extra stripe @alexcrichton pointed out that we know that `slot_bytes / max_memory_bytes` will at least be 1 due to a `max` comparison above. Knowing this, we can remove a `+ 1` intended for the case when `needed_num_stripes == 0`, which should be impossible. * review: replace `checked_*` with `saturating_*` This style change is a readability improvement; no calculations should change. Co-authored-by: Alex Crichton <alex@alexcrichton.com> --------- Co-authored-by: Alex Crichton <alex@alexcrichton.com>pull/7610/head
Andrew Brown
11 months ago
committed by
GitHub
2 changed files with 22 additions and 19 deletions
Loading…
Reference in new issue