mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
More getcpuinfo sysctl cleanup.
Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
9ba645fd7d
commit
41b3adc925
4 files changed
+42
-32
No files matched your search
+17
-12
@@ -101,30 +101,35 @@ int xc_perfc_control(int xc_handle,
|
||||
|
||||
rc = do_sysctl(xc_handle, &sysctl);
|
||||
|
||||
if (nbr_desc)
|
||||
if ( nbr_desc )
|
||||
*nbr_desc = sysctl.u.perfc_op.nr_counters;
|
||||
if (nbr_val)
|
||||
if ( nbr_val )
|
||||
*nbr_val = sysctl.u.perfc_op.nr_vals;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus)
|
||||
int xc_getcpuinfo(int xc_handle, int max_cpus,
|
||||
xc_cpuinfo_t *info, int *nr_cpus)
|
||||
{
|
||||
int ret;
|
||||
int rc;
|
||||
DECLARE_SYSCTL;
|
||||
|
||||
sysctl.cmd = XEN_SYSCTL_cpuinfo;
|
||||
sysctl.u.cpuinfo.max_cpus = max_cpus;
|
||||
set_xen_guest_handle(sysctl.u.cpuinfo.buffer, info);
|
||||
sysctl.cmd = XEN_SYSCTL_getcpuinfo;
|
||||
sysctl.u.getcpuinfo.max_cpus = max_cpus;
|
||||
set_xen_guest_handle(sysctl.u.getcpuinfo.info, info);
|
||||
|
||||
if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
|
||||
return ret;
|
||||
if ( (rc = lock_pages(info, max_cpus*sizeof(*info))) != 0 )
|
||||
return rc;
|
||||
|
||||
if(nr_cpus)
|
||||
*nr_cpus = sysctl.u.cpuinfo.nr_cpus;
|
||||
rc = do_sysctl(xc_handle, &sysctl);
|
||||
|
||||
return 0;
|
||||
unlock_pages(info, max_cpus*sizeof(*info));
|
||||
|
||||
if ( nr_cpus )
|
||||
*nr_cpus = sysctl.u.getcpuinfo.nr_cpus;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -479,7 +479,9 @@ int xc_physinfo(int xc_handle,
|
||||
int xc_sched_id(int xc_handle,
|
||||
int *sched_id);
|
||||
|
||||
int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus);
|
||||
typedef xen_sysctl_cpuinfo_t xc_cpuinfo_t;
|
||||
int xc_getcpuinfo(int xc_handle, int max_cpus,
|
||||
xc_cpuinfo_t *info, int *nr_cpus);
|
||||
|
||||
int xc_domain_setmaxmem(int xc_handle,
|
||||
uint32_t domid,
|
||||
|
||||
+7
-7
@@ -136,13 +136,13 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
|
||||
}
|
||||
break;
|
||||
|
||||
case XEN_SYSCTL_cpuinfo:
|
||||
case XEN_SYSCTL_getcpuinfo:
|
||||
{
|
||||
uint32_t i, nr_cpus;
|
||||
uint64_t idletime;
|
||||
struct xen_sysctl_cpuinfo cpuinfo;
|
||||
struct vcpu *v;
|
||||
|
||||
nr_cpus = min_t(uint32_t, op->u.cpuinfo.max_cpus, NR_CPUS);
|
||||
nr_cpus = min_t(uint32_t, op->u.getcpuinfo.max_cpus, NR_CPUS);
|
||||
|
||||
for ( i = 0; i < nr_cpus; i++ )
|
||||
{
|
||||
@@ -150,18 +150,18 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
|
||||
if ( (v = idle_vcpu[i]) == NULL )
|
||||
break;
|
||||
|
||||
idletime = v->runstate.time[RUNSTATE_running];
|
||||
cpuinfo.idletime = v->runstate.time[RUNSTATE_running];
|
||||
if ( v->is_running )
|
||||
idletime += NOW() - v->runstate.state_entry_time;
|
||||
cpuinfo.idletime += NOW() - v->runstate.state_entry_time;
|
||||
|
||||
if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
|
||||
if ( copy_to_guest_offset(op->u.getcpuinfo.info, i, &cpuinfo, 1) )
|
||||
{
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
op->u.cpuinfo.nr_cpus = i;
|
||||
op->u.getcpuinfo.nr_cpus = i;
|
||||
ret = 0;
|
||||
|
||||
if ( copy_to_guest(u_sysctl, op, 1) )
|
||||
|
||||
+15
-12
@@ -140,9 +140,7 @@ struct xen_sysctl_getdomaininfolist {
|
||||
typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
|
||||
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
|
||||
|
||||
/*
|
||||
* Inject debug keys into Xen.
|
||||
*/
|
||||
/* Inject debug keys into Xen. */
|
||||
#define XEN_SYSCTL_debug_keys 7
|
||||
struct xen_sysctl_debug_keys {
|
||||
/* IN variables. */
|
||||
@@ -152,17 +150,22 @@ struct xen_sysctl_debug_keys {
|
||||
typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
|
||||
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
|
||||
|
||||
/* Get physical CPU information */
|
||||
#define XEN_SYSCTL_cpuinfo 8
|
||||
/* Get physical CPU information. */
|
||||
#define XEN_SYSCTL_getcpuinfo 8
|
||||
struct xen_sysctl_cpuinfo {
|
||||
/* IN variables. */
|
||||
uint32_t max_cpus;
|
||||
XEN_GUEST_HANDLE_64(uint64_t) buffer;
|
||||
/* OUT variables. */
|
||||
uint32_t nr_cpus;
|
||||
};
|
||||
uint64_t idletime;
|
||||
};
|
||||
typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
|
||||
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
|
||||
struct xen_sysctl_getcpuinfo {
|
||||
/* IN variables. */
|
||||
uint32_t max_cpus;
|
||||
XEN_GUEST_HANDLE_64(xen_sysctl_cpuinfo_t) info;
|
||||
/* OUT variables. */
|
||||
uint32_t nr_cpus;
|
||||
};
|
||||
typedef struct xen_sysctl_getcpuinfo xen_sysctl_getcpuinfo_t;
|
||||
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getcpuinfo_t);
|
||||
|
||||
struct xen_sysctl {
|
||||
uint32_t cmd;
|
||||
@@ -175,7 +178,7 @@ struct xen_sysctl {
|
||||
struct xen_sysctl_perfc_op perfc_op;
|
||||
struct xen_sysctl_getdomaininfolist getdomaininfolist;
|
||||
struct xen_sysctl_debug_keys debug_keys;
|
||||
struct xen_sysctl_cpuinfo cpuinfo;
|
||||
struct xen_sysctl_getcpuinfo getcpuinfo;
|
||||
uint8_t pad[128];
|
||||
} u;
|
||||
};
|
||||
|
||||