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-devel

[Xen-devel] [PATCH] export cpu idle time to guests

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] export cpu idle time to guests
From: Rik van Riel <riel@xxxxxxxxxx>
Date: Fri, 15 Jun 2007 11:38:06 -0400
Cc: Mark Langsdorf <mark.langsdorf@xxxxxxx>
Delivery-date: Fri, 15 Jun 2007 08:36:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Red Hat, Inc
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.7 (X11/20061008)
The attached patch exports cpu idle time to guests.  This is one of
the things necessary for cpu frequency scaling to work well.

It works, but has the problem that the sysctl hypercall is really
only designed to be used from userspace, so we would need a userspace
cpufreq daemon running in dom0.

Mark, does this look reasonable to you?

Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>

--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is.  Each group
calls the other unpatriotic.
diff -r 93f77a5a8437 xen/common/sysctl.c
--- a/xen/common/sysctl.c       Sun Jun 10 19:58:22 2007 +0100
+++ b/xen/common/sysctl.c       Wed Jun 13 15:42:24 2007 -0400
@@ -136,6 +136,33 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
     }
     break;
 
+    case XEN_SYSCTL_getidletime:
+    {
+        uint32_t cpu;
+        uint32_t max_cpus = op->u.getidletime.max_cpus;
+        uint64_t idletime;
+
+        for_each_online_cpu (cpu) {
+            if ( cpu >= max_cpus )
+                break;
+
+             idletime = idle_vcpu[cpu]->runstate.time[RUNSTATE_running];
+
+             if ( copy_to_guest_offset(op->u.getidletime.buffer, cpu,
+                                       &idletime, 1) ) {
+                 ret = -EFAULT;
+                 break;
+             }
+         }
+
+         op->u.getidletime.num_cpus = cpu;
+
+         if ( copy_to_guest(u_sysctl, op, 1) )
+             ret = -EFAULT;
+      }
+      break;
+            
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         break;
diff -r 93f77a5a8437 xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Sun Jun 10 19:58:22 2007 +0100
+++ b/xen/include/public/sysctl.h       Wed Jun 13 15:41:58 2007 -0400
@@ -152,6 +152,17 @@ 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);
 
+#define XEN_SYSCTL_getidletime 8
+struct xen_sysctl_getidletime {
+    /* IN variables. */
+    uint32_t                   max_cpus;
+    XEN_GUEST_HANDLE(uint64_t) buffer;
+    /* OUT variables. */
+    uint32_t                   num_cpus;
+};
+typedef struct xen_sysctl_getidletime xen_sysctl_getidletime_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getidletime_t);
+
 struct xen_sysctl {
     uint32_t cmd;
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
@@ -163,6 +174,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_getidletime       getidletime;
         uint8_t                             pad[128];
     } u;
 };
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>