* [PATCH] export cpu idle time to guests
@ 2007-06-15 15:38 Rik van Riel
2007-06-18 16:10 ` Langsdorf, Mark
0 siblings, 1 reply; 2+ messages in thread
From: Rik van Riel @ 2007-06-15 15:38 UTC (permalink / raw)
To: xen-devel@lists.xensource.com; +Cc: Mark Langsdorf
[-- Attachment #1: Type: text/plain, Size: 562 bytes --]
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@redhat.com>
--
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.
[-- Attachment #2: xen-unstable-idletime.patch --]
[-- Type: text/x-patch, Size: 2191 bytes --]
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;
};
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] export cpu idle time to guests
2007-06-15 15:38 [PATCH] export cpu idle time to guests Rik van Riel
@ 2007-06-18 16:10 ` Langsdorf, Mark
0 siblings, 0 replies; 2+ messages in thread
From: Langsdorf, Mark @ 2007-06-18 16:10 UTC (permalink / raw)
To: Rik van Riel, xen-devel
> 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?
As a first pass toward enabling a solution, it looks acceptable.
It should be trivial to enable cpuspeed or powersave to use
a different call when running on dom0.
In the long run, I'd like to get ondemand working in dom0 so
that people don't need to do anything special to get cpufreq
support.
-Mark Langsdorf
Operating System Research Center
AMD
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-18 16:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-15 15:38 [PATCH] export cpu idle time to guests Rik van Riel
2007-06-18 16:10 ` Langsdorf, Mark
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.