> Date: Wed, 1 Feb 2012 13:05:55 -0500
> From: Peter Deng <agent.peter123@gmail.com>
> To: xen-devel@lists.xensource.com
> Subject: [Xen-devel] Xen Mem Page Sharing
> Message-ID:
> <CAJy3yGDJAWJmPtgwr1esf+F+Y4kopV1FGvo8QOdDodKoYdTR-Q@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> I''m am looking into and doing some research on Memory Page Sharing
on Xen,
> and I would like to know the current activity status regarding
Xen''s
> memory
> management. Also, while looking through the source code, I am having some
> trouble translating some of the functions, notably in mem_sharing.c, and
> one function I would like to have explained is mem_sharing_audit(). One
> that note, is there recent documentation on Xen code or do I need to trace
> the logs to determine development changes?
Quite recently we effectively overhauled all the sharing support in the
hypervisor. So it''s best you check out the latest xen-unstable tree.
The interface is relatively simple. You identify a page that is a
candidate for sharing and you call nominate(domain, gfn). You get back a
64 bit handle. This is a unique identifier for this *version* of this
guest page. Should the page change (writes) the handle won''t be valid
anymore.
Once you have two candidates you can coalesce them by calling
share(source_domain, source_gfn, source_handle, client_domain, client_gfn,
client_handle). Voila! you''ve shared and saved memory. You can reshare
(to
coalesce > 2 guest pages into a single backing shared page), but keep in
mind that the client gfn and handle won''t be valid anymore for further
sharing.
All the user-space visible code is in tools/libxc/xc_memshr.c, with
prototypes in tools/libxc/xenctrl.h. As you found out, the hypervisor code
is in arch/x86/mm/mem_sharing.c
It is crucial to understand that the hypervisor won''t check the
contents
of the pages. If you select the wrong candidates for sharing, you will
crash your guest(s). However, the hypervisor will ensure that pages are
properly unshared when writes happen.
Hope this helps, agent Peter!
Andres>
> Thanks,
>
> Peter