That is the case with NPT and EPT. Each page has exactly one spte
(except a few vga pages), and each sp has exactly one parent_pte (except
the root pages).
The existing rmap_next() is not O(N), it's O(RMAP_EXT), which is 4. The
data structure was chosen over a simple linked list to avoid extra cache
misses.
kvm_rmap_desc and kvm_pte_chain are indeed ugly, but they do save a lot
of memory and cache misses.
I agree the new code is more readable. Unfortunately it uses more
memory and is likely to be slower. You add a cache miss for every spte,
while kvm_rmap_desc amortizes the cache miss among 4 sptes, and special
cases 1 spte to have no cache misses (or extra memory requirements).
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
--