direct-io.hg

changeset 15431:3362de397f1e

More getcpuinfo sysctl cleanup.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Wed Jun 27 21:43:43 2007 +0100 (2007-06-27)
parents 806dc0aca747
children d0608ecb56bc
files tools/libxc/xc_misc.c tools/libxc/xenctrl.h xen/common/sysctl.c xen/include/public/sysctl.h
line diff
     1.1 --- a/tools/libxc/xc_misc.c	Wed Jun 27 21:28:19 2007 +0100
     1.2 +++ b/tools/libxc/xc_misc.c	Wed Jun 27 21:43:43 2007 +0100
     1.3 @@ -101,30 +101,35 @@ int xc_perfc_control(int xc_handle,
     1.4  
     1.5      rc = do_sysctl(xc_handle, &sysctl);
     1.6  
     1.7 -    if (nbr_desc)
     1.8 +    if ( nbr_desc )
     1.9          *nbr_desc = sysctl.u.perfc_op.nr_counters;
    1.10 -    if (nbr_val)
    1.11 +    if ( nbr_val )
    1.12          *nbr_val = sysctl.u.perfc_op.nr_vals;
    1.13  
    1.14      return rc;
    1.15  }
    1.16  
    1.17 -int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus)
    1.18 +int xc_getcpuinfo(int xc_handle, int max_cpus,
    1.19 +                  xc_cpuinfo_t *info, int *nr_cpus)
    1.20  {
    1.21 -    int ret;
    1.22 +    int rc;
    1.23      DECLARE_SYSCTL;
    1.24  
    1.25 -    sysctl.cmd = XEN_SYSCTL_cpuinfo;
    1.26 -    sysctl.u.cpuinfo.max_cpus = max_cpus; 
    1.27 -    set_xen_guest_handle(sysctl.u.cpuinfo.buffer, info); 
    1.28 +    sysctl.cmd = XEN_SYSCTL_getcpuinfo;
    1.29 +    sysctl.u.getcpuinfo.max_cpus = max_cpus; 
    1.30 +    set_xen_guest_handle(sysctl.u.getcpuinfo.info, info); 
    1.31  
    1.32 -    if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
    1.33 -        return ret;
    1.34 +    if ( (rc = lock_pages(info, max_cpus*sizeof(*info))) != 0 )
    1.35 +        return rc;
    1.36  
    1.37 -    if(nr_cpus) 
    1.38 -        *nr_cpus = sysctl.u.cpuinfo.nr_cpus; 
    1.39 +    rc = do_sysctl(xc_handle, &sysctl);
    1.40  
    1.41 -    return 0;
    1.42 +    unlock_pages(info, max_cpus*sizeof(*info));
    1.43 +
    1.44 +    if ( nr_cpus )
    1.45 +        *nr_cpus = sysctl.u.getcpuinfo.nr_cpus; 
    1.46 +
    1.47 +    return rc;
    1.48  }
    1.49  
    1.50  
     2.1 --- a/tools/libxc/xenctrl.h	Wed Jun 27 21:28:19 2007 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Wed Jun 27 21:43:43 2007 +0100
     2.3 @@ -479,7 +479,9 @@ int xc_physinfo(int xc_handle,
     2.4  int xc_sched_id(int xc_handle,
     2.5                  int *sched_id);
     2.6  
     2.7 -int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus); 
     2.8 +typedef xen_sysctl_cpuinfo_t xc_cpuinfo_t;
     2.9 +int xc_getcpuinfo(int xc_handle, int max_cpus,
    2.10 +                  xc_cpuinfo_t *info, int *nr_cpus); 
    2.11  
    2.12  int xc_domain_setmaxmem(int xc_handle,
    2.13                          uint32_t domid,
     3.1 --- a/xen/common/sysctl.c	Wed Jun 27 21:28:19 2007 +0100
     3.2 +++ b/xen/common/sysctl.c	Wed Jun 27 21:43:43 2007 +0100
     3.3 @@ -136,13 +136,13 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
     3.4      }
     3.5      break;
     3.6  
     3.7 -    case XEN_SYSCTL_cpuinfo:
     3.8 +    case XEN_SYSCTL_getcpuinfo:
     3.9      {
    3.10          uint32_t i, nr_cpus;
    3.11 -        uint64_t idletime;
    3.12 +        struct xen_sysctl_cpuinfo cpuinfo;
    3.13          struct vcpu *v;
    3.14  
    3.15 -        nr_cpus = min_t(uint32_t, op->u.cpuinfo.max_cpus, NR_CPUS);
    3.16 +        nr_cpus = min_t(uint32_t, op->u.getcpuinfo.max_cpus, NR_CPUS);
    3.17  
    3.18          for ( i = 0; i < nr_cpus; i++ )
    3.19          {
    3.20 @@ -150,18 +150,18 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
    3.21              if ( (v = idle_vcpu[i]) == NULL )
    3.22                  break;
    3.23  
    3.24 -            idletime = v->runstate.time[RUNSTATE_running];
    3.25 +            cpuinfo.idletime = v->runstate.time[RUNSTATE_running];
    3.26              if ( v->is_running )
    3.27 -                idletime += NOW() - v->runstate.state_entry_time;
    3.28 +                cpuinfo.idletime += NOW() - v->runstate.state_entry_time;
    3.29  
    3.30 -            if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
    3.31 +            if ( copy_to_guest_offset(op->u.getcpuinfo.info, i, &cpuinfo, 1) )
    3.32              {
    3.33                  ret = -EFAULT;
    3.34                  break;
    3.35              }
    3.36          }
    3.37  
    3.38 -        op->u.cpuinfo.nr_cpus = i;
    3.39 +        op->u.getcpuinfo.nr_cpus = i;
    3.40          ret = 0;
    3.41  
    3.42          if ( copy_to_guest(u_sysctl, op, 1) )
     4.1 --- a/xen/include/public/sysctl.h	Wed Jun 27 21:28:19 2007 +0100
     4.2 +++ b/xen/include/public/sysctl.h	Wed Jun 27 21:43:43 2007 +0100
     4.3 @@ -140,9 +140,7 @@ struct xen_sysctl_getdomaininfolist {
     4.4  typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
     4.5  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
     4.6  
     4.7 -/*
     4.8 - * Inject debug keys into Xen.
     4.9 - */
    4.10 +/* Inject debug keys into Xen. */
    4.11  #define XEN_SYSCTL_debug_keys        7
    4.12  struct xen_sysctl_debug_keys {
    4.13      /* IN variables. */
    4.14 @@ -152,17 +150,22 @@ struct xen_sysctl_debug_keys {
    4.15  typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
    4.16  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
    4.17  
    4.18 -/* Get physical CPU information */
    4.19 -#define XEN_SYSCTL_cpuinfo           8
    4.20 +/* Get physical CPU information. */
    4.21 +#define XEN_SYSCTL_getcpuinfo        8
    4.22  struct xen_sysctl_cpuinfo {
    4.23 -    /* IN variables. */
    4.24 -    uint32_t                      max_cpus;
    4.25 -    XEN_GUEST_HANDLE_64(uint64_t) buffer;
    4.26 -    /* OUT variables. */
    4.27 -    uint32_t                      nr_cpus;
    4.28 -}; 
    4.29 +    uint64_t idletime;
    4.30 +};
    4.31  typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
    4.32  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); 
    4.33 +struct xen_sysctl_getcpuinfo {
    4.34 +    /* IN variables. */
    4.35 +    uint32_t max_cpus;
    4.36 +    XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
    4.37 +    /* OUT variables. */
    4.38 +    uint32_t nr_cpus;
    4.39 +}; 
    4.40 +typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
    4.41 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t); 
    4.42  
    4.43  struct xen_sysctl {
    4.44      uint32_t cmd;
    4.45 @@ -175,7 +178,7 @@ struct xen_sysctl {
    4.46          struct xen_sysctl_perfc_op          perfc_op;
    4.47          struct xen_sysctl_getdomaininfolist getdomaininfolist;
    4.48          struct xen_sysctl_debug_keys        debug_keys;
    4.49 -        struct xen_sysctl_cpuinfo           cpuinfo;
    4.50 +        struct xen_sysctl_getcpuinfo        getcpuinfo;
    4.51          uint8_t                             pad[128];
    4.52      } u;
    4.53  };