# HG changeset patch # User Juergen Gross # Date 1342171239 -7200 # Node ID 80c3e053c1726eeeddf11204ce7f25aefc2fd021 # Parent 83fd911db89ee2d57db1c22537188d6b5691f807 tools: Save superpages in the same batch, to make detection easier On the first time through (when pfns are mostly allocated on the receiving side), try to keep superpages together in the same batch by ending a batch early if we see the first page of a potential superpage and there isn't enough room in the batch for a full superpage. Signed-off-by: George Dunlap diff -r 83fd911db89e -r 80c3e053c172 tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Fri Jul 13 11:20:37 2012 +0200 +++ b/tools/libxc/xc_domain_save.c Fri Jul 13 11:20:39 2012 +0200 @@ -81,6 +81,11 @@ struct outbuf { (((_mfn) < (ctx->max_mfn)) && \ ((mfn_to_pfn(_mfn) < (dinfo->p2m_size)) && \ (pfn_to_mfn(mfn_to_pfn(_mfn)) == (_mfn)))) + +#define SUPERPAGE_PFN_SHIFT 9 +#define SUPERPAGE_NR_PFNS (1UL << SUPERPAGE_PFN_SHIFT) + +#define SUPER_PAGE_START(pfn) (((pfn) & (SUPERPAGE_NR_PFNS-1)) == 0 ) /* ** During (live) save/migrate, we maintain a number of bitmaps to track @@ -906,6 +911,7 @@ int xc_domain_save(xc_interface *xch, in int rc = 1, frc, i, j, last_iter = 0, iter = 0; int live = (flags & XCFLAGS_LIVE); int debug = (flags & XCFLAGS_DEBUG); + int superpages = !!hvm; int race = 0, sent_last_iter, skip_this_iter = 0; unsigned int sent_this_iter = 0; int tmem_saved = 0; @@ -1261,6 +1267,12 @@ int xc_domain_save(xc_interface *xch, in (test_bit(n, to_send) && last_iter) || (test_bit(n, to_fix) && last_iter)) ) continue; + + /* First time through, try to keep superpages in the same batch */ + if ( superpages && iter == 1 + && SUPER_PAGE_START(n) + && batch + SUPERPAGE_NR_PFNS > MAX_BATCH_SIZE ) + break; /* ** we get here if: