Skip to content

asahi: Improve VM bind performance for large BOs#495

Open
TrungNguyen1909 wants to merge 1 commit intoAsahiLinux:asahifrom
TrungNguyen1909:asahi-large-bo-binding-perf
Open

asahi: Improve VM bind performance for large BOs#495
TrungNguyen1909 wants to merge 1 commit intoAsahiLinux:asahifrom
TrungNguyen1909:asahi-large-bo-binding-perf

Conversation

@TrungNguyen1909
Copy link
Copy Markdown

Large BOs can take quite long time to randomly-map/bind to AGX address space since the current implementation iterates through every page entries that come before the requested BO offset.

This pull request provides an improvement by caching up all the SGT entries (linked list) into an KVVec and binary_search() on it. The additional memory-usage is 3*8*NENTS bytes per VmBo allocation (i.e Asahi VM x mapped). SGTable's Rust implementation currently do not export sg_nents so the allocation here is like O(NlogN) (can be reduced in the next version).

The cost for the first bind remains about the same but if we are doing bind/unbind from a large BO repeatedly then the cost for the sequential binds are greatly reduced, amortizing the initial cost.

A few questions that need to be addressed:

  • Is the additional memory justified? Should we only do this only on large (defined by larger than whatever constants), or all BOs?
  • If we are doing this on all BOs, should we drop the SGTable in the VmBo structure? Cannot be done since SGTable is owning the pages.
  • There is a possibility to merge SGT entries before they are being added to the sg_vec if the entries are physically contiguous.

Signed-off-by: Hoang Trung Nguyen <trung@kryptoslogic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant