From: Rik van Riel <riel@redhat.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: Mark Langsdorf <mark.langsdorf@amd.com>
Subject: [PATCH] export cpu idle time to guests
Date: Fri, 15 Jun 2007 11:38:06 -0400 [thread overview]
Message-ID: <4672B25E.3040804@redhat.com> (raw)
[-- 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
next reply other threads:[~2007-06-15 15:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-15 15:38 Rik van Riel [this message]
2007-06-18 16:10 ` [PATCH] export cpu idle time to guests Langsdorf, Mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4672B25E.3040804@redhat.com \
--to=riel@redhat.com \
--cc=mark.langsdorf@amd.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.