WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Add new sysctl to return runtime informat

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Add new sysctl to return runtime information about physical CPU utilization.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Jun 2007 18:01:13 -0700
Delivery-date: Wed, 27 Jun 2007 17:59:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Steven Hand <steven@xxxxxxxxxxxxx>
# Date 1182974468 -3600
# Node ID 4ab9e4bbd61b4748ccc76566af88d98cd4e7bbb1
# Parent  9590c9b48e07ad3308519e834c7dfe01e8845e49
Add new sysctl to return runtime information about physical CPU utilization.

Signed-off-by: Steven Hadn <steven@xxxxxxxxxxxxx>
---
 tools/libxc/xc_misc.c       |   19 +++++++++++++++++++
 tools/libxc/xenctrl.h       |    2 ++
 xen/common/schedule.c       |    8 ++++++--
 xen/common/sysctl.c         |   32 ++++++++++++++++++++++++++++++++
 xen/include/public/sysctl.h |   13 +++++++++++++
 5 files changed, 72 insertions(+), 2 deletions(-)

diff -r 9590c9b48e07 -r 4ab9e4bbd61b tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Wed Jun 27 20:56:25 2007 +0100
+++ b/tools/libxc/xc_misc.c     Wed Jun 27 21:01:08 2007 +0100
@@ -108,6 +108,25 @@ int xc_perfc_control(int xc_handle,
 
     return rc;
 }
+
+int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus)
+{
+    int ret;
+    DECLARE_SYSCTL;
+
+    sysctl.cmd = XEN_SYSCTL_cpuinfo;
+    sysctl.u.cpuinfo.max_cpus = max_cpus; 
+    set_xen_guest_handle(sysctl.u.cpuinfo.buffer, info); 
+
+    if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
+        return ret;
+
+    if(nr_cpus) 
+        *nr_cpus = sysctl.u.cpuinfo.nr_cpus; 
+
+    return 0;
+}
+
 
 int xc_hvm_set_pci_intx_level(
     int xc_handle, domid_t dom,
diff -r 9590c9b48e07 -r 4ab9e4bbd61b tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Wed Jun 27 20:56:25 2007 +0100
+++ b/tools/libxc/xenctrl.h     Wed Jun 27 21:01:08 2007 +0100
@@ -479,6 +479,8 @@ int xc_sched_id(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); 
+
 int xc_domain_setmaxmem(int xc_handle,
                         uint32_t domid,
                         unsigned int max_memkb);
diff -r 9590c9b48e07 -r 4ab9e4bbd61b xen/common/schedule.c
--- a/xen/common/schedule.c     Wed Jun 27 20:56:25 2007 +0100
+++ b/xen/common/schedule.c     Wed Jun 27 21:01:08 2007 +0100
@@ -72,8 +72,12 @@ static inline void vcpu_runstate_change(
     ASSERT(v->runstate.state != new_state);
     ASSERT(spin_is_locked(&per_cpu(schedule_data,v->processor).schedule_lock));
 
-    v->runstate.time[v->runstate.state] +=
-        new_entry_time - v->runstate.state_entry_time;
+    if(unlikely((v->runstate.state_entry_time - new_entry_time) > TIME_SLOP))
+        /* Local time on this CPU has been warped */
+        v->runstate.time[v->runstate.state] = new_entry_time; 
+    else 
+        v->runstate.time[v->runstate.state] +=
+            new_entry_time - v->runstate.state_entry_time;
     v->runstate.state_entry_time = new_entry_time;
     v->runstate.state = new_state;
 }
diff -r 9590c9b48e07 -r 4ab9e4bbd61b xen/common/sysctl.c
--- a/xen/common/sysctl.c       Wed Jun 27 20:56:25 2007 +0100
+++ b/xen/common/sysctl.c       Wed Jun 27 21:01:08 2007 +0100
@@ -136,6 +136,38 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
     }
     break;
 
+    case XEN_SYSCTL_cpuinfo:
+    {
+        uint32_t i, nr_cpus;
+        uint64_t idletime;
+
+        nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS :
+            op->u.cpuinfo.max_cpus;
+
+        for ( i = 0; i < nr_cpus; i++ )
+        {
+            if(!idle_vcpu[i])
+                /* XXX: assumes no further CPUs after first missing one */
+                break;
+
+            /* somewhat imprecise but should suffice */
+            idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] +
+                (NOW() - idle_vcpu[i]->runstate.state_entry_time);
+            if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
+            {
+                ret = -EFAULT;
+                break;
+            }
+        }
+
+        op->u.cpuinfo.nr_cpus = i;
+        ret = 0;
+
+        if( copy_to_guest (u_sysctl, op, 1) )
+            ret = -EFAULT;
+    }
+    break;
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         break;
diff -r 9590c9b48e07 -r 4ab9e4bbd61b xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Wed Jun 27 20:56:25 2007 +0100
+++ b/xen/include/public/sysctl.h       Wed Jun 27 21:01:08 2007 +0100
@@ -152,6 +152,18 @@ typedef struct xen_sysctl_debug_keys xen
 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
+struct xen_sysctl_cpuinfo {
+    /* IN variables. */
+    uint32_t                      max_cpus;
+    XEN_GUEST_HANDLE_64(uint64_t) buffer;
+    /* IN/OUT variables. */
+    uint32_t                      nr_cpus;
+}; 
+typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); 
+
 struct xen_sysctl {
     uint32_t cmd;
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
@@ -163,6 +175,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;
         uint8_t                             pad[128];
     } u;
 };

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Add new sysctl to return runtime information about physical CPU utilization., Xen patchbot-unstable <=