Hi, All I have a question about the memory management in Xen. Suppose I start 2 DomU instances and both of them use the same kernel image. In this case, 1) will Xen make two copy of the kernel image in the memory, i.e., occupy 2*sizeof(kernel image) space in the physical memory or, 2) will Xen only have one copy of the read-only pages of the kernel image (for instance, text section, rodata section) in the physical memory? Because I read somewhere about that, Unix will only have one copy of read-only pages in the memory and share them among processes. How about Xen? Any thoughts? Thank you Haifeng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Mark Williamson
2007-Oct-25 17:42 UTC
Re: [Xen-devel] Question about memory management in Xen
> I have a question about the memory management in Xen. Suppose I start > 2 DomU instances and both of them use the same kernel image. In this case, > > 1) will Xen make two copy of the kernel image in the memory, i.e., occupy > 2*sizeof(kernel image) space in the physical memory or,This is the case under Xen. Each domain gets built in entirely separate memory and the kernel is copied into there.> 2) will Xen only have one copy of the read-only pages of the kernel > image (for instance, text section, rodata section) in the physical > memory? Because I read > somewhere about that, Unix will only have one copy of read-only pages in > the memory and share them among processes. How about Xen? Any thoughts?Xen doesn''t share memory in this case. This costs some space but kernel images are typically not that large compared to the total memory used by a VM. The Xen model basically gives each guest a separate, independent memory like a real machine would. Most VMMs at least try to present this appearance to the guest. I know that VMware ESX is able to unify identical pages between virtual machines once they''re are running in order to save memory. This applies to both kernel and userspace pages, both code and data. I don''t definitely know of any other x86-based VMM which does sharing like this. IBM''s zSeries boxes can share memory for things like kernel text, but they use a special kind of memory segment for this. The memory management architecture of the zSeries is pretty strange, coming from an x86 background. In principle, Xen could unify identical pages in a similar way to VMware ESX by using shadow pagetables. Another option would be getting guests to co-operate explicitly (I''ve been hacking on something similar to this) with the sharing. The "Potemkin virtual honey farm" uses shadow pagetables to allow guests that have been "forked" from a common parent to share memory in a copy-on-write fashion. Hope that helps. Cheers, Mark -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel! _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hi, I was wondering if it is possible to share machine memory pages between Domains. I found there is a function "share_xen_page_with_guest" in arch/x86/mm.c. What''s used for? Is it possible to use the function for that purpose? Thanks a lot Haifeng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hi,>I was wondering if it is possible to share machine memory pages >between Domains. I found there is a function >"share_xen_page_with_guest" in arch/x86/mm.c. What''s used for? Is it >possible to use the function for that purpose?The function is used for sharing between hypervisor and guest. Hypervisor need to map shared memory to guest for console page and shared info page before staring guest. If you can share between domains, you should use grant table. Best Regards, Akio Takebe _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Mark Williamson
2007-Dec-03 04:28 UTC
Re: [Xen-devel] Question about memory management in Xen
> >I was wondering if it is possible to share machine memory pages > >between Domains. I found there is a function > >"share_xen_page_with_guest" in arch/x86/mm.c. What''s used for? Is it > >possible to use the function for that purpose? > > The function is used for sharing between hypervisor and guest. > Hypervisor need to map shared memory to guest for console page > and shared info page before staring guest. > > If you can share between domains, you should use grant table.For examples of grant table usage, see the current block and network front/back drivers, amongst other things. These show you how to share memory by using grant tables from kernel space. Basically, the domU which wishes to share memory adds a sharing grant into its grant table and then communicates a "grant reference" (just an integer) identifying it to dom0. This reference can be communicated via Xenstore (which is how the block / net drivers set up the communications ring), via existing shared memory (the block and net drivers pass further grant refs through the communications rind), or via any other method. Dom0 then maps the granted memory using a hypercall, specifying the domain ID and the grant reference it was given, plus a virtual address to map it at. I''ve used dom0 and domU as examples partly to simplify things but also because until recently only dom0 was allowed to map grant references. I''m told that domUs can also map grant references in the current -unstable tree. Cheers, Mark -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel! _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel