debuggers.hg

changeset 22745:f84ae053b7da

xenpaging: remove domain_id and mfn from struct xenpaging_victim

Remove unused member 'mfn' from struct xenpaging_victim.

xenpaging operates on a single guest, so it needs only a single
domain_id. Remove domain_id from struct xenpaging_victim and use the
one from paging->mem_event where needed. Its not used in the policy.

This saves 4MB runtime data with a 1GB pagefile.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
author Keir Fraser <keir@xen.org>
date Tue Jan 11 10:31:33 2011 +0000 (2011-01-11)
parents a2dcebb88bc4
children f87b1c194eb8
files tools/xenpaging/policy.h tools/xenpaging/policy_default.c tools/xenpaging/xenpaging.c tools/xenpaging/xenpaging.h
line diff
     1.1 --- a/tools/xenpaging/policy.h	Tue Jan 11 10:30:46 2011 +0000
     1.2 +++ b/tools/xenpaging/policy.h	Tue Jan 11 10:31:33 2011 +0000
     1.3 @@ -29,10 +29,9 @@
     1.4  
     1.5  
     1.6  int policy_init(xenpaging_t *paging);
     1.7 -int policy_choose_victim(xenpaging_t *paging, domid_t domain_id,
     1.8 -                         xenpaging_victim_t *victim);
     1.9 -void policy_notify_paged_out(domid_t domain_id, unsigned long gfn);
    1.10 -void policy_notify_paged_in(domid_t domain_id, unsigned long gfn);
    1.11 +int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim);
    1.12 +void policy_notify_paged_out(unsigned long gfn);
    1.13 +void policy_notify_paged_in(unsigned long gfn);
    1.14  
    1.15  #endif // __XEN_PAGING_POLICY_H__
    1.16  
     2.1 --- a/tools/xenpaging/policy_default.c	Tue Jan 11 10:30:46 2011 +0000
     2.2 +++ b/tools/xenpaging/policy_default.c	Tue Jan 11 10:31:33 2011 +0000
     2.3 @@ -67,16 +67,12 @@ int policy_init(xenpaging_t *paging)
     2.4      return rc;
     2.5  }
     2.6  
     2.7 -int policy_choose_victim(xenpaging_t *paging, domid_t domain_id,
     2.8 -                         xenpaging_victim_t *victim)
     2.9 +int policy_choose_victim(xenpaging_t *paging, xenpaging_victim_t *victim)
    2.10  {
    2.11      xc_interface *xch = paging->xc_handle;
    2.12      unsigned long wrap = current_gfn;
    2.13      ASSERT(victim != NULL);
    2.14  
    2.15 -    /* Domain to pick on */
    2.16 -    victim->domain_id = domain_id;
    2.17 -
    2.18      do
    2.19      {
    2.20          current_gfn++;
    2.21 @@ -96,13 +92,13 @@ int policy_choose_victim(xenpaging_t *pa
    2.22      return 0;
    2.23  }
    2.24  
    2.25 -void policy_notify_paged_out(domid_t domain_id, unsigned long gfn)
    2.26 +void policy_notify_paged_out(unsigned long gfn)
    2.27  {
    2.28      set_bit(gfn, bitmap);
    2.29      clear_bit(gfn, unconsumed);
    2.30  }
    2.31  
    2.32 -void policy_notify_paged_in(domid_t domain_id, unsigned long gfn)
    2.33 +void policy_notify_paged_in(unsigned long gfn)
    2.34  {
    2.35      unsigned long old_gfn = mru[i_mru & (MRU_SIZE - 1)];
    2.36  
     3.1 --- a/tools/xenpaging/xenpaging.c	Tue Jan 11 10:30:46 2011 +0000
     3.2 +++ b/tools/xenpaging/xenpaging.c	Tue Jan 11 10:31:33 2011 +0000
     3.3 @@ -171,7 +171,7 @@ xenpaging_t *xenpaging_init(domid_t doma
     3.4          goto err;
     3.5      }
     3.6  
     3.7 -    rc = xc_get_platform_info(xch, domain_id,
     3.8 +    rc = xc_get_platform_info(xch, paging->mem_event.domain_id,
     3.9                                paging->platform_info);
    3.10      if ( rc != 1 )
    3.11      {
    3.12 @@ -187,7 +187,7 @@ xenpaging_t *xenpaging_init(domid_t doma
    3.13          goto err;
    3.14      }
    3.15  
    3.16 -    rc = xc_domain_getinfolist(xch, domain_id, 1,
    3.17 +    rc = xc_domain_getinfolist(xch, paging->mem_event.domain_id, 1,
    3.18                                 paging->domain_info);
    3.19      if ( rc != 1 )
    3.20      {
    3.21 @@ -348,7 +348,7 @@ int xenpaging_evict_page(xenpaging_t *pa
    3.22      /* Map page */
    3.23      gfn = victim->gfn;
    3.24      ret = -EFAULT;
    3.25 -    page = xc_map_foreign_pages(xch, victim->domain_id,
    3.26 +    page = xc_map_foreign_pages(xch, paging->mem_event.domain_id,
    3.27                                  PROT_READ | PROT_WRITE, &gfn, 1);
    3.28      if ( page == NULL )
    3.29      {
    3.30 @@ -380,7 +380,7 @@ int xenpaging_evict_page(xenpaging_t *pa
    3.31      }
    3.32  
    3.33      /* Notify policy of page being paged out */
    3.34 -    policy_notify_paged_out(paging->mem_event.domain_id, victim->gfn);
    3.35 +    policy_notify_paged_out(victim->gfn);
    3.36  
    3.37   out:
    3.38      return ret;
    3.39 @@ -397,7 +397,7 @@ static int xenpaging_resume_page(xenpagi
    3.40  
    3.41      /* Notify policy of page being paged in */
    3.42      if ( notify_policy )
    3.43 -        policy_notify_paged_in(paging->mem_event.domain_id, rsp->gfn);
    3.44 +        policy_notify_paged_in(rsp->gfn);
    3.45  
    3.46      /* Tell Xen page is ready */
    3.47      ret = xc_mem_paging_resume(paging->xc_handle, paging->mem_event.domain_id,
    3.48 @@ -464,7 +464,7 @@ static int xenpaging_populate_page(xenpa
    3.49      return ret;
    3.50  }
    3.51  
    3.52 -static int evict_victim(xenpaging_t *paging, domid_t domain_id,
    3.53 +static int evict_victim(xenpaging_t *paging,
    3.54                          xenpaging_victim_t *victim, int fd, int i)
    3.55  {
    3.56      xc_interface *xch = paging->xc_handle;
    3.57 @@ -473,7 +473,7 @@ static int evict_victim(xenpaging_t *pag
    3.58  
    3.59      do
    3.60      {
    3.61 -        ret = policy_choose_victim(paging, domain_id, victim);
    3.62 +        ret = policy_choose_victim(paging, victim);
    3.63          if ( ret != 0 )
    3.64          {
    3.65              if ( ret != -ENOSPC )
    3.66 @@ -486,14 +486,13 @@ static int evict_victim(xenpaging_t *pag
    3.67              ret = -EINTR;
    3.68              goto out;
    3.69          }
    3.70 -        ret = xc_mem_paging_nominate(xch,
    3.71 -                                     paging->mem_event.domain_id, victim->gfn);
    3.72 +        ret = xc_mem_paging_nominate(xch, paging->mem_event.domain_id, victim->gfn);
    3.73          if ( ret == 0 )
    3.74              ret = xenpaging_evict_page(paging, victim, fd, i);
    3.75          else
    3.76          {
    3.77              if ( j++ % 1000 == 0 )
    3.78 -                if ( xc_mem_paging_flush_ioemu_cache(domain_id) )
    3.79 +                if ( xc_mem_paging_flush_ioemu_cache(paging->mem_event.domain_id) )
    3.80                      ERROR("Error flushing ioemu cache");
    3.81          }
    3.82      }
    3.83 @@ -578,7 +577,7 @@ int main(int argc, char *argv[])
    3.84      memset(victims, 0, sizeof(xenpaging_victim_t) * num_pages);
    3.85      for ( i = 0; i < num_pages; i++ )
    3.86      {
    3.87 -        rc = evict_victim(paging, domain_id, &victims[i], fd, i);
    3.88 +        rc = evict_victim(paging, &victims[i], fd, i);
    3.89          if ( rc == -ENOSPC )
    3.90              break;
    3.91          if ( rc == -EINTR )
    3.92 @@ -619,8 +618,7 @@ int main(int argc, char *argv[])
    3.93                  /* Find where in the paging file to read from */
    3.94                  for ( i = 0; i < num_pages; i++ )
    3.95                  {
    3.96 -                    if ( (victims[i].domain_id == paging->mem_event.domain_id) &&
    3.97 -                         (victims[i].gfn == req.gfn) )
    3.98 +                    if ( victims[i].gfn == req.gfn )
    3.99                          break;
   3.100                  }
   3.101      
   3.102 @@ -652,7 +650,7 @@ int main(int argc, char *argv[])
   3.103                  }
   3.104  
   3.105                  /* Evict a new page to replace the one we just paged in */
   3.106 -                evict_victim(paging, domain_id, &victims[i], fd, i);
   3.107 +                evict_victim(paging, &victims[i], fd, i);
   3.108              }
   3.109              else
   3.110              {
     4.1 --- a/tools/xenpaging/xenpaging.h	Tue Jan 11 10:30:46 2011 +0000
     4.2 +++ b/tools/xenpaging/xenpaging.h	Tue Jan 11 10:31:33 2011 +0000
     4.3 @@ -49,12 +49,8 @@ typedef struct xenpaging {
     4.4  
     4.5  
     4.6  typedef struct xenpaging_victim {
     4.7 -    /* the domain to evict a page from */
     4.8 -    domid_t domain_id;
     4.9      /* the gfn of the page to evict */
    4.10      unsigned long gfn;
    4.11 -    /* the mfn of evicted page */
    4.12 -    unsigned long mfn;
    4.13  } xenpaging_victim_t;
    4.14  
    4.15