ia64/xen-unstable

changeset 17417:e64d17985df5

save/restore: Batch contiguous page-sized writes together during domain save.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 09 15:19:09 2008 +0100 (2008-04-09)
parents 0553004fa328
children aee133a8e5e7
files tools/libxc/xc_domain_save.c
line diff
     1.1 --- a/tools/libxc/xc_domain_save.c	Wed Apr 09 14:34:49 2008 +0100
     1.2 +++ b/tools/libxc/xc_domain_save.c	Wed Apr 09 15:19:09 2008 +0100
     1.3 @@ -1048,7 +1048,7 @@ int xc_domain_save(int xc_handle, int io
     1.4      /* Now write out each data page, canonicalising page tables as we go... */
     1.5      for ( ; ; )
     1.6      {
     1.7 -        unsigned int prev_pc, sent_this_iter, N, batch;
     1.8 +        unsigned int prev_pc, sent_this_iter, N, batch, run;
     1.9  
    1.10          iter++;
    1.11          sent_this_iter = 0;
    1.12 @@ -1225,6 +1225,7 @@ int xc_domain_save(int xc_handle, int io
    1.13              }
    1.14  
    1.15              /* entering this loop, pfn_type is now in pfns (Not mfns) */
    1.16 +            run = 0;
    1.17              for ( j = 0; j < batch; j++ )
    1.18              {
    1.19                  unsigned long pfn, pagetype;
    1.20 @@ -1233,7 +1234,25 @@ int xc_domain_save(int xc_handle, int io
    1.21                  pfn      = pfn_type[j] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
    1.22                  pagetype = pfn_type[j] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
    1.23  
    1.24 -                /* write out pages in batch */
    1.25 +                if ( pagetype != 0 )
    1.26 +                {
    1.27 +                    /* If the page is not a normal data page, write out any
    1.28 +                       run of pages we may have previously acumulated */
    1.29 +                    if ( run )
    1.30 +                    {
    1.31 +                        if ( ratewrite(io_fd, live, 
    1.32 +                                       (char*)region_base+(PAGE_SIZE*(j-run)), 
    1.33 +                                       PAGE_SIZE*run) != PAGE_SIZE*run )
    1.34 +                        {
    1.35 +                            ERROR("Error when writing to state file (4a)"
    1.36 +                                  " (errno %d)", errno);
    1.37 +                            goto out;
    1.38 +                        }                        
    1.39 +                        run = 0;
    1.40 +                    }
    1.41 +                }
    1.42 +
    1.43 +                /* skip pages that aren't present */
    1.44                  if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
    1.45                      continue;
    1.46  
    1.47 @@ -1255,24 +1274,31 @@ int xc_domain_save(int xc_handle, int io
    1.48  
    1.49                      if ( ratewrite(io_fd, live, page, PAGE_SIZE) != PAGE_SIZE )
    1.50                      {
    1.51 -                        ERROR("Error when writing to state file (4)"
    1.52 +                        ERROR("Error when writing to state file (4b)"
    1.53                                " (errno %d)", errno);
    1.54                          goto out;
    1.55                      }
    1.56                  }
    1.57                  else
    1.58                  {
    1.59 -                    /* We have a normal page: just write it directly. */
    1.60 -                    if ( ratewrite(io_fd, live, spage, PAGE_SIZE) !=
    1.61 -                         PAGE_SIZE )
    1.62 -                    {
    1.63 -                        ERROR("Error when writing to state file (5)"
    1.64 -                              " (errno %d)", errno);
    1.65 -                        goto out;
    1.66 -                    }
    1.67 +                    /* We have a normal page: accumulate it for writing. */
    1.68 +                    run++;
    1.69                  }
    1.70              } /* end of the write out for this batch */
    1.71  
    1.72 +            if ( run )
    1.73 +            {
    1.74 +                /* write out the last accumulated run of pages */
    1.75 +                if ( ratewrite(io_fd, live, 
    1.76 +                               (char*)region_base+(PAGE_SIZE*(j-run)), 
    1.77 +                               PAGE_SIZE*run) != PAGE_SIZE*run )
    1.78 +                {
    1.79 +                    ERROR("Error when writing to state file (4c)"
    1.80 +                          " (errno %d)", errno);
    1.81 +                    goto out;
    1.82 +                }                        
    1.83 +            }
    1.84 +
    1.85              sent_this_iter += batch;
    1.86  
    1.87              munmap(region_base, batch*PAGE_SIZE);