From: Wei Liu Subject: Re: [PATCH 1/2] x86/mem-sharing: Bulk mem-sharing entire domains Date: Tue, 6 Oct 2015 10:19:13 +0100 Message-ID: <20151006091913.GQ29124@zion.uk.xensource.com> References: <1443990339-19590-1-git-send-email-tamas@tklengyel.com> <1443990339-19590-2-git-send-email-tamas@tklengyel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZjOP1-0006be-8D for xen-devel@lists.xenproject.org; Tue, 06 Oct 2015 09:19:19 +0000 Content-Disposition: inline In-Reply-To: <1443990339-19590-2-git-send-email-tamas@tklengyel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tamas K Lengyel Cc: Wei Liu , Ian Campbell , Stefano Stabellini , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Tamas K Lengyel , xen-devel@lists.xenproject.org, Keir Fraser List-Id: xen-devel@lists.xenproject.org On Sun, Oct 04, 2015 at 02:25:38PM -0600, Tamas K Lengyel wrote: > Currently mem-sharing can be performed on a page-by-page base from the control > domain. However, when completely deduplicating (cloning) a VM, this requires > at least 3 hypercalls per page. As the user has to loop through all pages up > to max_gpfn, this process is very slow and wasteful. > > This patch introduces a new mem_sharing memop for bulk deduplication where > the user doesn't have to separately nominate each page in both the source and > destination domain, and the looping over all pages happen in the hypervisor. > This significantly reduces the overhead of completely deduplicating entire > domains. > > Signed-off-by: Tamas K Lengyel > Cc: Ian Jackson > Cc: Stefano Stabellini > Cc: Ian Campbell > Cc: Wei Liu > Cc: George Dunlap > Cc: Keir Fraser > Cc: Jan Beulich > Cc: Andrew Cooper > --- > tools/libxc/include/xenctrl.h | 11 +++++ > tools/libxc/xc_memshr.c | 14 ++++++ > xen/arch/x86/mm/mem_sharing.c | 90 ++++++++++++++++++++++++++++++++++++++- > xen/arch/x86/x86_64/compat/mm.c | 6 ++- > xen/arch/x86/x86_64/mm.c | 6 ++- > xen/include/asm-x86/mem_sharing.h | 3 +- > xen/include/public/memory.h | 1 + > 7 files changed, 124 insertions(+), 7 deletions(-) > > diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h > index 3bfa00b..dd82549 100644 > --- a/tools/libxc/include/xenctrl.h > +++ b/tools/libxc/include/xenctrl.h > @@ -2594,6 +2594,17 @@ int xc_memshr_add_to_physmap(xc_interface *xch, > domid_t client_domain, > unsigned long client_gfn); > > +/* Allows to deduplicate the entire memory of a client domain in bulk. Using > + * this function is equivalent of calling xc_memshr_nominate_gfn for each gfn > + * in the two domains followed by xc_memshr_share_gfns. > + * > + * May fail with EINVAL if the source and client domain have different > + * memory size or if memory sharing is not enabled on either of the domains. > + */ > +int xc_memshr_bulk_dedup(xc_interface *xch, > + domid_t source_domain, > + domid_t client_domain); > + > /* Debug calls: return the number of pages referencing the shared frame backing > * the input argument. Should be one or greater. > * > diff --git a/tools/libxc/xc_memshr.c b/tools/libxc/xc_memshr.c > index deb0aa4..ecb0f5c 100644 > --- a/tools/libxc/xc_memshr.c > +++ b/tools/libxc/xc_memshr.c > @@ -181,6 +181,20 @@ int xc_memshr_add_to_physmap(xc_interface *xch, > return xc_memshr_memop(xch, source_domain, &mso); > } > > +int xc_memshr_bulk_dedup(xc_interface *xch, > + domid_t source_domain, > + domid_t client_domain) > +{ > + xen_mem_sharing_op_t mso; > + > + memset(&mso, 0, sizeof(mso)); > + > + mso.op = XENMEM_sharing_op_bulk_dedup; > + mso.u.share.client_domain = client_domain; > + > + return xc_memshr_memop(xch, source_domain, &mso); > +} > + Tools bits: Acked-by: Wei Liu