From: Will Deacon Subject: Re: [RFC PATCH 13/16] kvm tools: keep track of registered memory banks in struct kvm Date: Tue, 13 Nov 2012 12:16:05 +0000 Message-ID: <20121113121605.GC5493@mudshark.cambridge.arm.com> References: <1352721450-11340-1-git-send-email-will.deacon@arm.com> <1352721450-11340-14-git-send-email-will.deacon@arm.com> <50A1CE92.6060803@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Cc: "kvm@vger.kernel.org" , "penberg@kernel.org" , Marc Zyngier , "c.dall@virtualopensystems.com" , Matt Evans , "peter.maydell@linaro.org" To: Sasha Levin Return-path: Received: from service87.mimecast.com ([91.220.42.44]:54941 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212Ab2KMMQL convert rfc822-to-8bit (ORCPT ); Tue, 13 Nov 2012 07:16:11 -0500 In-Reply-To: <50A1CE92.6060803@gmail.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Nov 13, 2012 at 04:37:38AM +0000, Sasha Levin wrote: > On 11/12/2012 06:57 AM, Will Deacon wrote: > > +struct kvm_mem_bank { > > + struct list_head list; > > + unsigned long guest_phys_addr; > > + void *host_addr; > > + unsigned long size; > > +}; > > Can we just reuse struct kvm_userspace_memory_region here? We're also using different > data types for guest_phys_addr and size than whats in kvm_userspace_memory_region - that > can't be good. I looked briefly at doing that when I wrote the multi-bank stuff, but I hit a couple of issues: - kvmtool itself tends to use void * for host addresses, rather than the __u64 userspace_addr in kvm_userspace_memory_region - kvm_userspace_memory_region is a superset of what we need (not the end of the world I guess) so you end up casting address types a fair amount. Still, I'll revisit it and see if I can come up with something cleaner. > > struct kvm { > > struct kvm_arch arch; > > struct kvm_config cfg; > > @@ -49,6 +56,7 @@ struct kvm { > > u64 ram_size; > > void *ram_start; > > u64 ram_pagesize; > > + struct list_head mem_banks; > > These memory banks actually look like a perfect example to use our augmented interval rb-tree, > can we switch them to use it, or is it a list on purpose? Well, the usual case is one memory bank but that doesn't swing the argument either way. I'll update to use the fancy new tree. Thanks for the comments, Will