On Thu, Aug 22, 2024, Peng Zhang wrote: > Currently, xarray is used to manage memory attributes. The memory > attributes management here is an interval problem. However, xarray is > not suitable for handling interval problems. It may cause memory waste > and is not efficient. Switching it to maple tree is more elegant. Using > maple tree here has the following three advantages: > 1. Less memory overhead. > 2. More efficient interval operations. > 3. Simpler code. > > This is the first user of the maple tree interface mas_find_range(), > and it does not have any test cases yet, so its stability is unclear. > > Signed-off-by: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx> > --- > include/linux/kvm_host.h | 5 +++-- > virt/kvm/kvm_main.c | 47 ++++++++++++++-------------------------- > 2 files changed, 19 insertions(+), 33 deletions(-) > > I haven't tested this code yet, and I'm not very familiar with kvm, so I'd > be happy if someone could help test it. This is just an RFC now. Any comments > are welcome. Unfortunatley, you are unlikely to get much feedback (although Matthew already jumped in). We (KVM folks) know the xarray usage for memory attribute is (very) suboptimal, and it's on the todo list to address. We specifically went with a simple-but-slow implementation in order to prioritize correctness above all else for initial merge.