On Thu, 2021-04-22 at 14:31 +0200, Jan Beulich wrote: > On 30.04.2020 22:44, Hongyan Xia wrote: > > From: Hongyan Xia <hongy...@amazon.com> > > > > When there is not an always-mapped direct map, xenheap allocations > > need > > to be mapped and unmapped on-demand. > > > > Signed-off-by: Hongyan Xia <hongy...@amazon.com> > > This series has been left uncommented for far too long - I'm sorry. > While earlier patches here are probably reasonable (but would likely > need re-basing, so I'm not sure whether to try to get to look though > them before that makes much sense),
No worries. This series depends on the domheap Xen page table conversion series anyway (which was just fully merged. Thanks.). I will re-base now since the dependency is resolved. > As I don't think we have many cases where code actually depends on > being able to apply __va() (or equivalent) to the address returned > from alloc_xenheap_pages(), I think this should instead involve > vmap(), with the vmap area drastically increased (perhaps taking all > of the space the direct map presently consumes). For any remaining > users of __va() or alike these should perhaps be converted into an > alias / derivation of vmap_to_{mfn,page}() then. That's true, and this was my first implementation (and also Wei's original proposal) which worked okay. But, several problems got in the way. 1. Partial unmap. Biggest offender is xmalloc which allocates and could then free part of it, which means we need to be able to partially unmap the region. vmap() does not support this. 2. Fast PA->VA. There is currently no way to go from PA to VA in vmapped pages, unless we somehow repurpose or add new fields in page_info. Also, VA->PA is possible but very slow now. There is not much PA->VA in the critical path but see 3. 3. EPT. Mapping and unmapping EPT in HVM hypercalls and MMIO are so many and so slow that it is probably not possible to keep them as domheap pages due to the big performance drop after removing the direct map. If we move them to xenheap pages on vmap, then this depends on 2 for page table walking. In the end, I could not find a way that met all 3 above without massive and intrusive changes. If there is a way, it certainly needs a design document. The "on-demand" direct map solves all the problems without breaking any APIs and is very easy to understand. We have been using Xen without the direct map for a while now with this approach with decent performance (in fact, you cannot tell that this is a Xen without the direct map by just real-world benchmarks alone). I too agree that this approach is a litte hacky and wastes a big chunk of virtual address space. Definitely wants some discussion if a better way can be found that solves the problems. Thanks, Hongyan